Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
libp2plog "github.com/ipfs/go-log/v2"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"golang.org/x/net/idna"

"github.com/obolnetwork/charon/app"
"github.com/obolnetwork/charon/app/errors"
Expand Down Expand Up @@ -174,6 +175,10 @@ func bindP2PFlags(cmd *cobra.Command, config *p2p.Config) {
cmd.Flags().BoolVar(&config.DisableReuseport, "p2p-disable-reuseport", false, "Disables TCP port reuse for outgoing libp2p connections.")

wrapPreRunE(cmd, func(cmd *cobra.Command, args []string) error { //nolint:revive // keep args variable name for clarity
if _, err := idna.Lookup.ToASCII(config.ExternalHost); err != nil {
return errors.Wrap(err, "invalid hostname", z.Str("hostname", config.ExternalHost))
}

for _, relay := range config.Relays {
u, err := url.Parse(relay)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions cmd/run_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ func TestBindRunFlagsValidation(t *testing.T) {
Name: "valid vc tls cert and key files",
Args: slice("run", "--beacon-node-endpoints", "http://beacon.node", "--vc-tls-cert-file", certFile.Name(), "--vc-tls-key-file", keyFile.Name()),
},
{
Name: "invalid hostname",
Args: slice("run", "--beacon-node-endpoints", "http://beacon.node", "--p2p-external-hostname", "--p2p-tcp-address"),
Err: "invalid hostname",
},
}

for _, test := range tests {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ require (
go.uber.org/goleak v1.3.0
go.uber.org/zap v1.27.0
golang.org/x/crypto v0.40.0
golang.org/x/net v0.42.0
golang.org/x/sync v0.16.0
golang.org/x/term v0.33.0
golang.org/x/text v0.28.0
Expand Down Expand Up @@ -277,7 +278,6 @@ require (
go.uber.org/zap/exp v0.3.0 // indirect
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
golang.org/x/mod v0.26.0 // indirect
golang.org/x/net v0.42.0 // indirect
golang.org/x/sys v0.34.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 // indirect
Expand Down
Loading