@@ -8,8 +8,18 @@ var serviceRegex =
8
8
/ ^ ( ( [ 0 - 9 ] | [ 1 - 9 ] [ 0 - 9 ] | 1 [ 0 - 9 ] { 2 } | 2 [ 0 - 4 ] [ 0 - 9 ] | 2 5 [ 0 - 5 ] ) \. ) { 3 } ( [ 0 - 9 ] | [ 1 - 9 ] [ 0 - 9 ] | 1 [ 0 - 9 ] { 2 } | 2 [ 0 - 4 ] [ 0 - 9 ] | 2 5 [ 0 - 5 ] ) : [ 0 - 9 ] + $ / ;
9
9
var ipV6prefix = Buffer . from ( '00000000000000000000ffff' , 'hex' ) ;
10
10
var emptyAddress = Buffer . alloc ( 18 ) ;
11
- var EMPTY_IPV6_ADDRESS = constants . EMPTY_IPV6_ADDRESS ;
12
- var EMPTY_IPV4_ADDRESS = constants . EMPTY_IPV4_ADDRESS ;
11
+ var EMPTY_FULL_IPV6_ADDRESS = '[0:0:0:0:0:0:0:0]:0' ;
12
+ var EMPTY_SHORT_IPV6_ADDRESS = '[::]:0' ;
13
+ var EMPTY_SHORT_ZERO_IPV6_ADDRESS = '[::0]:0' ;
14
+ var EMPTY_FULL_IPV4_ADDRESS = '0.0.0.0:0' ;
15
+ var EMPTY_SHORT_IPV4_ADDRESS = '0:0' ;
16
+ var EMPTY_ADDRESSES = [
17
+ EMPTY_FULL_IPV6_ADDRESS ,
18
+ EMPTY_SHORT_IPV6_ADDRESS ,
19
+ EMPTY_SHORT_ZERO_IPV6_ADDRESS ,
20
+ EMPTY_FULL_IPV4_ADDRESS ,
21
+ EMPTY_SHORT_IPV4_ADDRESS ,
22
+ ] ;
13
23
14
24
/**
15
25
* Maps ipv4:port to ipv6 buffer and port
@@ -56,7 +66,7 @@ function bufferToIPAndPort(buffer) {
56
66
var serviceString = ipV4string + ':' + String ( port ) ;
57
67
// This is a hack to match core implementation, which in case of an empty address returns ipv6 string
58
68
serviceString = isZeroAddress ( serviceString )
59
- ? EMPTY_IPV6_ADDRESS
69
+ ? EMPTY_FULL_IPV6_ADDRESS
60
70
: serviceString ;
61
71
return serviceString ;
62
72
}
@@ -75,7 +85,7 @@ function isIpV4(ipAndPortString) {
75
85
* @return {boolean }
76
86
*/
77
87
function isZeroAddress ( address ) {
78
- return address === EMPTY_IPV6_ADDRESS || address === EMPTY_IPV4_ADDRESS ;
88
+ return EMPTY_ADDRESSES . includes ( address ) ;
79
89
}
80
90
81
91
var ip = {
0 commit comments