| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6706be1 commit 3a26db9
21 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -760,7 +760,7 @@ protoGetter('remoteAddress', function remoteAddress() { | |||
| 760 | 760 | }); | |
| 761 | 761 | ||
| 762 | 762 | protoGetter('remoteFamily', function remoteFamily() { | |
| 763 | - return this._getpeername().family; | ||
| 763 | + return `IPv${this._getpeername().family}`; | ||
| 764 | 764 | }); | |
| 765 | 765 | ||
| 766 | 766 | protoGetter('remotePort', function remotePort() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -216,7 +216,7 @@ function getCIDR(address, netmask, family) { | |||
| 216 | 216 | let groupLength = 8; | |
| 217 | 217 | let hasZeros = false; | |
| 218 | 218 | ||
| 219 | - if (family === 'IPv6') { | ||
| 219 | + if (family === 6) { | ||
| 220 | 220 | split = ':'; | |
| 221 | 221 | range = 16; | |
| 222 | 222 | groupLength = 16; | |
@@ -248,7 +248,7 @@ function getCIDR(address, netmask, family) { | |||
| 248 | 248 | * @returns {Record<string, Array<{ | |
| 249 | 249 | * address: string | |
| 250 | 250 | * netmask: string | |
| 251 | - * family: 'IPv4' | 'IPv6' | ||
| 251 | + * family: 4 | 6 | ||
| 252 | 252 | * mac: string | |
| 253 | 253 | * internal: boolean | |
| 254 | 254 | * scopeid: number | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -289,8 +289,6 @@ constexpr size_t kFsStatsBufferLength = | |||
| 289 | 289 | V(input_string, "input") \ | |
| 290 | 290 | V(internal_binding_string, "internalBinding") \ | |
| 291 | 291 | V(internal_string, "internal") \ | |
| 292 | - V(ipv4_string, "IPv4") \ | ||
| 293 | - V(ipv6_string, "IPv6") \ | ||
| 294 | 292 | V(isclosing_string, "isClosing") \ | |
| 295 | 293 | V(issuer_string, "issuer") \ | |
| 296 | 294 | V(issuercert_string, "issuerCertificate") \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -174,7 +174,8 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo<Value>& args) { | |||
| 174 | 174 | char ip[INET6_ADDRSTRLEN]; | |
| 175 | 175 | char netmask[INET6_ADDRSTRLEN]; | |
| 176 | 176 | std::array<char, 18> mac; | |
| 177 | - Local<String> name, family; | ||
| 177 | + Local<String> name; | ||
| 178 | + Local<Integer> family; | ||
| 178 | 179 | ||
| 179 | 180 | int err = uv_interface_addresses(&interfaces, &count); | |
| 180 | 181 | ||
@@ -214,14 +215,14 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo<Value>& args) { | |||
| 214 | 215 | if (interfaces[i].address.address4.sin_family == AF_INET) { | |
| 215 | 216 | uv_ip4_name(&interfaces[i].address.address4, ip, sizeof(ip)); | |
| 216 | 217 | uv_ip4_name(&interfaces[i].netmask.netmask4, netmask, sizeof(netmask)); | |
| 217 | - family = env->ipv4_string(); | ||
| 218 | + family = Integer::New(env->isolate(), 4); | ||
| 218 | 219 | } else if (interfaces[i].address.address4.sin_family == AF_INET6) { | |
| 219 | 220 | uv_ip6_name(&interfaces[i].address.address6, ip, sizeof(ip)); | |
| 220 | 221 | uv_ip6_name(&interfaces[i].netmask.netmask6, netmask, sizeof(netmask)); | |
| 221 | - family = env->ipv6_string(); | ||
| 222 | + family = Integer::New(env->isolate(), 6); | ||
| 222 | 223 | } else { | |
| 223 | 224 | strncpy(ip, "<unknown sa family>", INET6_ADDRSTRLEN); | |
| 224 | - family = env->unknown_string(); | ||
| 225 | + family = Integer::New(env->isolate(), 0); | ||
| 225 | 226 | } | |
| 226 | 227 | ||
| 227 | 228 | result.emplace_back(name); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -380,7 +380,7 @@ MaybeLocal<Object> AddressToJS(Environment* env, | |||
| 380 | 380 | OneByteString(env->isolate(), ip)).Check(); | |
| 381 | 381 | info->Set(env->context(), | |
| 382 | 382 | env->family_string(), | |
| 383 | - env->ipv6_string()).Check(); | ||
| 383 | + Integer::New(env->isolate(), 6)).Check(); | ||
| 384 | 384 | info->Set(env->context(), | |
| 385 | 385 | env->port_string(), | |
| 386 | 386 | Integer::New(env->isolate(), port)).Check(); | |
@@ -395,7 +395,7 @@ MaybeLocal<Object> AddressToJS(Environment* env, | |||
| 395 | 395 | OneByteString(env->isolate(), ip)).Check(); | |
| 396 | 396 | info->Set(env->context(), | |
| 397 | 397 | env->family_string(), | |
| 398 | - env->ipv4_string()).Check(); | ||
| 398 | + Integer::New(env->isolate(), 4)).Check(); | ||
| 399 | 399 | info->Set(env->context(), | |
| 400 | 400 | env->port_string(), | |
| 401 | 401 | Integer::New(env->isolate(), port)).Check(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -845,7 +845,7 @@ const common = { | |||
| 845 | 845 | const re = isWindows ? /Loopback Pseudo-Interface/ : /lo/; | |
| 846 | 846 | return Object.keys(iFaces).some((name) => { | |
| 847 | 847 | return re.test(name) && | |
| 848 | - iFaces[name].some(({ family }) => family === 'IPv6'); | ||
| 848 | + iFaces[name].some(({ family }) => family === 6); | ||
| 849 | 849 | }); | |
| 850 | 850 | }, | |
| 851 | 851 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,7 +16,7 @@ class FakeUDPWrap extends EventEmitter { | |||
| 16 | 16 | this._handle.onwrite = | |
| 17 | 17 | (wrap, buffers, addr) => this._write(wrap, buffers, addr); | |
| 18 | 18 | this._handle.getsockname = (obj) => { | |
| 19 | - Object.assign(obj, { address: '127.0.0.1', family: 'IPv4', port: 1337 }); | ||
| 19 | + Object.assign(obj, { address: '127.0.0.1', family: 4, port: 1337 }); | ||
| 20 | 20 | return 0; | |
| 21 | 21 | }; | |
| 22 | 22 | ||
@@ -72,8 +72,8 @@ class FakeUDPWrap extends EventEmitter { | |||
| 72 | 72 | ||
| 73 | 73 | let familyInt; | |
| 74 | 74 | switch (family) { | |
| 75 | - case 'IPv4': familyInt = 4; break; | ||
| 76 | - case 'IPv6': familyInt = 6; break; | ||
| 75 | + case 4: familyInt = 4; break; | ||
| 76 | + case 6: familyInt = 6; break; | ||
| 77 | 77 | default: throw new Error('bad family'); | |
| 78 | 78 | } | |
| 79 | 79 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,10 +39,10 @@ const internalInterfaces = Object.values(os.networkInterfaces()).flat().filter( | |||
| 39 | 39 | ); | |
| 40 | 40 | for (const iface of internalInterfaces) { | |
| 41 | 41 | testListeningOptions.push({ | |
| 42 | - hostname: iface?.family === 'IPv6' ? `[${iface?.address}]` : iface?.address, | ||
| 42 | + hostname: iface?.family === 6 ? `[${iface.address}]` : iface?.address, | ||
| 43 | 43 | listenOptions: { | |
| 44 | 44 | host: iface?.address, | |
| 45 | - ipv6Only: iface?.family === 'IPv6' | ||
| 45 | + ipv6Only: iface?.family === 6 | ||
| 46 | 46 | } | |
| 47 | 47 | }); | |
| 48 | 48 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,7 +47,7 @@ get_bindAddress: for (const name in networkInterfaces) { | |||
| 47 | 47 | const interfaces = networkInterfaces[name]; | |
| 48 | 48 | for (let i = 0; i < interfaces.length; i++) { | |
| 49 | 49 | const localInterface = interfaces[i]; | |
| 50 | - if (!localInterface.internal && localInterface.family === 'IPv4') { | ||
| 50 | + if (!localInterface.internal && localInterface.family === 4) { | ||
| 51 | 51 | bindAddress = localInterface.address; | |
| 52 | 52 | break get_bindAddress; | |
| 53 | 53 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,7 +49,7 @@ const TMPL = (tail) => `${NOW} - ${tail}`; | |||
| 49 | 49 | const interfaceAddress = ((networkInterfaces) => { | |
| 50 | 50 | for (const name in networkInterfaces) { | |
| 51 | 51 | for (const localInterface of networkInterfaces[name]) { | |
| 52 | - if (!localInterface.internal && localInterface.family === FAM) { | ||
| 52 | + if (!localInterface.internal && `IPv${localInterface.family}` === FAM) { | ||
| 53 | 53 | let interfaceAddress = localInterface.address; | |
| 54 | 54 | // On Windows, IPv6 would need: `%${localInterface.scopeid}` | |
| 55 | 55 | if (FAM === 'IPv6') | |
| Back | FazBrowse Home | New Git URL |
0 commit comments