Skip to content

Commit

Permalink
flags: use boolvar; rename default vars
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxcanfly committed May 7, 2024
1 parent ef2ce72 commit a40e5d2
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions cmd/mock-da/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"flag"
"fmt"
"log"
"net/url"
"os"
"os/signal"
"syscall"
Expand All @@ -15,28 +14,24 @@ import (
)

const (
// MockDAPort is the port used for the mock DA gRPC server
MockDAPort = 7980
defaultHost = "localhost"
defaultPort = "7980"
)

var listenAll = flag.Bool("listen-all", false, "Listen on all network interfaces (0.0.0.0) instead of just localhost")

func main() {
var (
host string
port string
host string
port string
listenAll bool
)
flag.StringVar(&port, "port", defaultPort, "listening port")
flag.StringVar(&host, "host", defaultHost, "listening address")
flag.BoolVar(&listenAll, "listen-all", false, "listen on all network interfaces (0.0.0.0) instead of just localhost")
flag.Parse()
ip := "localhost"
if *listenAll {
ip = "0.0.0.0"
}
address := fmt.Sprintf("grpc://%s:%d", ip, MockDAPort)

addr, _ := url.Parse(address)
flag.StringVar(&port, "port", addr.Port(), "listening port")
flag.StringVar(&host, "host", addr.Hostname(), "listening address")
flag.Parse()
if listenAll {
host = "0.0.0.0"
}

srv := proxy.NewServer(host, port, goDATest.NewDummyDA())
log.Printf("Listening on: %s:%s", host, port)
Expand Down

0 comments on commit a40e5d2

Please sign in to comment.