Browse Source

test case for IPv6 any ip

Darien Raymond 6 years ago
parent
commit
9a7177c82c
2 changed files with 11 additions and 0 deletions
  1. 3 0
      common/net/address.go
  2. 8 0
      common/net/address_test.go

+ 3 - 0
common/net/address.go

@@ -18,6 +18,9 @@ var (
 
 	// LocalHostIPv6 is a constant value for localhost IP in IPv6.
 	LocalHostIPv6 = IPAddress([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1})
+
+	// AnyIPv6 is a constant value for any IP in IPv6.
+	AnyIPv6 = IPAddress([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})
 )
 
 // AddressFamily is the type of address.

+ 8 - 0
common/net/address_test.go

@@ -85,6 +85,14 @@ func TestAddressProperty(t *testing.T) {
 			},
 		},
 		{
+			Input: ParseAddress("::0"),
+			Output: addrProprty{
+				IP:     AnyIPv6.IP(),
+				Family: AddressFamilyIPv6,
+				String: "[::]",
+			},
+		},
+		{
 			Input: ParseAddress("[::ffff:123.151.71.143]"),
 			Output: addrProprty{
 				IP:     []byte{123, 151, 71, 143},