-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nsqadmin: Fix handling of IPv6 broadcast addresses
Fixes nsqio#815
- Loading branch information
1 parent
0e61d05
commit b66580d
Showing
2 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package clusterinfo | ||
|
||
import "testing" | ||
|
||
func TestHostNameAddresses(t *testing.T) { | ||
p := &Producer{ | ||
BroadcastAddress: "host.domain.com", | ||
TCPPort: 4150, | ||
HTTPPort: 4151, | ||
} | ||
|
||
if p.HTTPAddress() != "host.domain.com:4151" { | ||
t.Errorf("Incorrect HTTPAddress: %s", p.HTTPAddress()) | ||
} | ||
if p.TCPAddress() != "host.domain.com:4150" { | ||
t.Errorf("Incorrect TCPAddress: %s", p.TCPAddress()) | ||
} | ||
} | ||
|
||
func TestIPv4Addresses(t *testing.T) { | ||
p := &Producer{ | ||
BroadcastAddress: "192.168.1.17", | ||
TCPPort: 4150, | ||
HTTPPort: 4151, | ||
} | ||
|
||
if p.HTTPAddress() != "192.168.1.17:4151" { | ||
t.Errorf("Incorrect IPv4 HTTPAddress: %s", p.HTTPAddress()) | ||
} | ||
if p.TCPAddress() != "192.168.1.17:4150" { | ||
t.Errorf("Incorrect IPv4 TCPAddress: %s", p.TCPAddress()) | ||
} | ||
} | ||
|
||
func TestIPv6Addresses(t *testing.T) { | ||
p := &Producer{ | ||
BroadcastAddress: "fd4a:622f:d2f2::1", | ||
TCPPort: 4150, | ||
HTTPPort: 4151, | ||
} | ||
if p.HTTPAddress() != "[fd4a:622f:d2f2::1]:4151" { | ||
t.Errorf("Incorrect IPv6 HTTPAddress: %s", p.HTTPAddress()) | ||
} | ||
if p.TCPAddress() != "[fd4a:622f:d2f2::1]:4150" { | ||
t.Errorf("Incorrect IPv6 TCPAddress: %s", p.TCPAddress()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters