Skip to content

Commit

Permalink
change network filter from ip4 to ip
Browse files Browse the repository at this point in the history
  • Loading branch information
wildum committed Sep 6, 2023
1 parent dae9eed commit 4babdec
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion node.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func NewNode(cli *http.Client, cfg Config) (*Node, error) {
return nil, fmt.Errorf("failed to read advertise address: %w", err)
}

advertiseIP, err := net.ResolveIPAddr("ip4", advertiseAddr)
advertiseIP, err := net.ResolveIPAddr("ip", advertiseAddr)
if err != nil {
return nil, fmt.Errorf("failed to lookup advertise address %q: %w", advertiseAddr, err)
}
Expand Down
34 changes: 34 additions & 0 deletions node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,3 +369,37 @@ func TestNode_Peers(t *testing.T) {
require.ElementsMatch(t, expectPeers, a.Peers())
})
}

func TestNewNodeIPv6(t *testing.T) {
t.Helper()
l := testlogger.New(t)
name := "node-a"

if l == nil {
l = log.NewNopLogger()
}

lis, err := net.Listen("tcp", "[::1]:0")
require.NoError(t, err)

cfg := Config{
Name: name,
AdvertiseAddr: lis.Addr().String(),
Log: log.With(l, "node", name),
}

cli := &http.Client{
Transport: &http2.Transport{
AllowHTTP: true,
DialTLS: func(network, addr string, _ *tls.Config) (net.Conn, error) {
return net.Dial(network, addr)
},
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
},
}

_, err = NewNode(cli, cfg)
require.NoError(t, err)
}

0 comments on commit 4babdec

Please sign in to comment.