Skip to content

Commit

Permalink
Merge pull request #12 from gjermundgaraba/main
Browse files Browse the repository at this point in the history
Add flag to listen on 0.0.0.0
  • Loading branch information
tuxcanfly authored May 7, 2024
2 parents 592d9dd + 4959eff commit 55fe3c2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
3 changes: 0 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ run:

linters:
enable:
- deadcode
- errcheck
- gofmt
- goimports
Expand All @@ -15,10 +14,8 @@ linters:
- misspell
- revive
- staticcheck
- structcheck
- typecheck
- unused
- varcheck

issues:
exclude-use-default: false
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ should output

Which exposes the [go-da] interface over JSONRPC and can be accessed with an HTTP client like [xh][xh]:

You can also run mock-da with a `-listen-all` flag which will make the process listen on 0.0.0.0 so that it can be accessed from other machines.

```sh
$ ./mock-da -listen-all
2024/04/11 12:23:34 Listening on: 0.0.0.0:7980
```

### MaxBlobSize

```sh
Expand Down
20 changes: 12 additions & 8 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,20 +14,25 @@ import (
)

const (
// MockDAAddress is the mock address for the gRPC server
MockDAAddress = "grpc://localhost:7980"
defaultHost = "localhost"
defaultPort = "7980"
)

func main() {
var (
host string
port string
host string
port string
listenAll bool
)
addr, _ := url.Parse(MockDAAddress)
flag.StringVar(&port, "port", addr.Port(), "listening port")
flag.StringVar(&host, "host", addr.Hostname(), "listening address")
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()

if listenAll {
host = "0.0.0.0"
}

srv := proxy.NewServer(host, port, goDATest.NewDummyDA())
log.Printf("Listening on: %s:%s", host, port)
if err := srv.Start(context.Background()); err != nil {
Expand Down

0 comments on commit 55fe3c2

Please sign in to comment.