Skip to content

Commit

Permalink
Attempts to fix nvm version for travis-ci in linux/osx; part five
Browse files Browse the repository at this point in the history
  • Loading branch information
jas- committed Mar 21, 2018
1 parent 6222edb commit e4b18ca
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ node_js:
- "8"

install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update && brew install nmap; npm install; node examples/discover.js; npm test; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update && brew install nmap; npm install; npm test; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update && sudo apt-get install -y nmap; npm install; npm test; fi

2 changes: 1 addition & 1 deletion examples/discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

const nmap = require('../');

nmap.discover({debug: true}, function(err, report) {
nmap.discover({verbose: true}, function(err, report) {
if (err) throw new Error(err);

for (let item in report) {
Expand Down
46 changes: 21 additions & 25 deletions lib/classes/networking.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,40 +141,36 @@ class network {
for (const iface in adapters) {

for (const dev in adapters[iface]) {
let netobj = adapters[iface][dev];
let adapter = adapters[iface][dev];

for (let adapter in netobj) {

// Skip if internal or missing netmask
if (adapter.internal || !adapter.netmask)
// Skip if internal
if (adapter.internal)
continue;

// If cidr provide use and continue
if (adapter.cidr) {
ret.push(`${adapter.cidr}`);
continue;
}

// If only netmask exists calculate the CIDR
if (adapter.netmask) {
// If cidr provide use and continue
if (adapter.cidr) {
ret.push(`${adapter.cidr}`);
continue;
}

subnet = adapter.netmask;
// If only netmask exists calculate the CIDR
if (adapter.netmask) {

if (validation.test(validation.patterns.IPv6, subnet)) {
subnet = adapter.netmask;

/* Convert netmask to CIDR notation if IPv6 */
subnet = new v6(netmask).subnet.substring(1);
} else {
if (validation.test(validation.patterns.IPv6, subnet)) {

/* Convert netmask to CIDR */
subnet = new netmask(`${adapter.address}/${subnet}`);
adapter.address = subnet.base;
subnet = subnet.bitmask;
}
/* Convert netmask to CIDR notation if IPv6 */
subnet = new v6(netmask).subnet.substring(1);
} else {

ret.push(`${adapter.address}/${subnet}`);
continue;
/* Convert netmask to CIDR */
subnet = new netmask(`${adapter.address}/${subnet}`);
adapter.address = subnet.base;
subnet = subnet.bitmask;
}

ret.push(`${adapter.address}/${subnet}`);
}
}
}
Expand Down

0 comments on commit e4b18ca

Please sign in to comment.