Skip to content

Commit

Permalink
Fail starting a tcp_transport with no ip (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
shou1dwe authored Jun 29, 2020
1 parent 5927dcd commit ae3f4f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tcp_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func newTCPTransport(bindAddr string,
list.Close()
return nil, errNotTCP
}
if addr.IP.IsUnspecified() {
if addr.IP == nil || addr.IP.IsUnspecified() {
list.Close()
return nil, errNotAdvertisable
}
Expand Down
7 changes: 7 additions & 0 deletions tcp_transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ func TestTCPTransport_BadAddr(t *testing.T) {
}
}

func TestTCPTransport_EmptyAddr(t *testing.T) {
_, err := NewTCPTransportWithLogger(":0", nil, 1, 0, newTestLogger(t))
if err != errNotAdvertisable {
t.Fatalf("err: %v", err)
}
}

func TestTCPTransport_WithAdvertise(t *testing.T) {
addr := &net.TCPAddr{IP: []byte{127, 0, 0, 1}, Port: 12345}
trans, err := NewTCPTransportWithLogger("0.0.0.0:0", addr, 1, 0, newTestLogger(t))
Expand Down

0 comments on commit ae3f4f2

Please sign in to comment.