Skip to content

Commit

Permalink
Merge d05072d into 0e1b4ac
Browse files Browse the repository at this point in the history
  • Loading branch information
nodech committed Dec 27, 2021
2 parents 0e1b4ac + d05072d commit 84cb471
Show file tree
Hide file tree
Showing 5 changed files with 720 additions and 95 deletions.
7 changes: 7 additions & 0 deletions lib/inet.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,13 @@ function family(str) {
return 0;
}

/**
* IPv4 Mapped - RFC 2765
* @param {Buffer} raw
* @param {Number} off
* @returns {Boolean}
*/

function mapped(raw, off) {
if (off == null)
off = 0;
Expand Down
15 changes: 9 additions & 6 deletions lib/ip.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const binet = exports;
*/

const ZERO_IP = Buffer.from('00000000000000000000000000000000', 'hex');
const ZERO_IPV4 = Buffer.from('00000000000000000000ffff00000000', 'hex');
const LOCAL_IP = Buffer.from('00000000000000000000000000000001', 'hex');
const RFC6052 = Buffer.from('0064ff9b0000000000000000', 'hex');
const RFC4862 = Buffer.from('fe80000000000000', 'hex');
Expand Down Expand Up @@ -1300,9 +1301,9 @@ binet.getReachability = function getReachability(src, dest) {
const destNet = binet.getNetwork(dest);

switch (destNet) {
case networks.IPV4:
case networks.INET4:
switch (srcNet) {
case networks.IPV4:
case networks.INET4:
return IPV4;
default:
return DEFAULT;
Expand All @@ -1312,7 +1313,7 @@ binet.getReachability = function getReachability(src, dest) {
switch (srcNet) {
case networks.TEREDO:
return TEREDO;
case networks.IPV4:
case networks.INET4:
return IPV4;
case networks.INET6:
if (binet.isRFC3964(src)
Expand All @@ -1328,7 +1329,7 @@ binet.getReachability = function getReachability(src, dest) {
break;
case networks.ONION:
switch (srcNet) {
case networks.IPV4:
case networks.INET4:
return IPV4;
case networks.ONION:
return PRIVATE;
Expand All @@ -1342,7 +1343,7 @@ binet.getReachability = function getReachability(src, dest) {
return TEREDO;
case networks.INET6:
return IPV6_WEAK;
case networks.IPV4:
case networks.INET4:
return IPV4;
default:
return DEFAULT;
Expand All @@ -1354,7 +1355,7 @@ binet.getReachability = function getReachability(src, dest) {
return TEREDO;
case networks.INET6:
return IPV6_WEAK;
case networks.IPV4:
case networks.INET4:
return IPV4;
case networks.ONION:
return PRIVATE;
Expand Down Expand Up @@ -1602,5 +1603,7 @@ binet.ip = binet;
binet.types = types;
binet.networks = networks;
binet.ZERO_IP = ZERO_IP;
binet.ZERO_IPV6 = ZERO_IP;
binet.ZERO_IPV4 = ZERO_IPV4;
binet.onion = onion;
binet.inet = inet;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"author": "Christopher Jeffrey <chjjeffrey@gmail.com>",
"main": "./lib/binet.js",
"scripts": {
"lint": "eslint lib/ test/ || exit 0",
"lint": "eslint lib/ test/",
"test": "bmocha --reporter spec test/*-test.js",
"test-ci": "nyc --reporter lcov bmocha -- --reporter spec test/*.js"
},
Expand Down

0 comments on commit 84cb471

Please sign in to comment.