Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change network filter from ip4 to ip #29

Merged
merged 1 commit into from
Sep 6, 2023
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
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)
}