Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
0f1a6d6661 | |||
9d42fb9b5e | |||
0fe7bd8eed | |||
a8416e1a27 | |||
d7715d1cdf | |||
36e1f8ffaf | |||
cf885a3bdd | |||
ba0bfc7d42 | |||
d0f22a8ed2 | |||
a021a5d469 | |||
9fe4300976 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
.idea
|
||||
node_modules
|
||||
/yarn.lock
|
||||
|
@ -47,7 +47,7 @@ The tool returns an array with objects, each object representing a network with
|
||||
|
||||
* channel: WiFi channel
|
||||
* ssid: SSID of the network (if available)
|
||||
* mac: MAC Address of the network access point
|
||||
* mac: MAC Address of the network access point (if available, otherwise empty string)
|
||||
* rssi: signal strength
|
||||
|
||||
In contrary to other wifi scanners no information about security is returned. This is due to the very different implementation
|
||||
|
@ -7,8 +7,6 @@ const tool = '/System/Library/PrivateFrameworks/Apple80211.framework/Version
|
||||
const cmdLine = tool + ' -s';
|
||||
const detector = tool + ' -getInfo';
|
||||
|
||||
const macRegex = /([0-9a-zA-Z]{1}[0-9a-zA-Z]{1}[:]{1}){5}[0-9a-zA-Z]{1}[0-9a-zA-Z]{1}/;
|
||||
|
||||
/**
|
||||
* Parsing the output of airport (Mac OS X)
|
||||
* @param str output of the tool
|
||||
@ -22,17 +20,13 @@ function parseOutput(str, callback) {
|
||||
let lines = str.split('\n');
|
||||
|
||||
for (let i = 1, l = lines.length; i < l; i++) {
|
||||
let mac = lines[i].match(macRegex);
|
||||
if (!mac) {
|
||||
continue;
|
||||
}
|
||||
let macStart = lines[i].indexOf(mac[0]);
|
||||
let elements = lines[i].substr(macStart).split(/[ ]+/);
|
||||
if (lines[i] === '') continue;
|
||||
let elements = lines[i].substring(51).split(/[ ]+/);
|
||||
wifis.push({
|
||||
'ssid' : lines[i].substr(0, macStart).trim(),
|
||||
'mac' : elements[0].trim(),
|
||||
'channel': parseInt(elements[2].trim(), 10),
|
||||
'rssi' : parseInt(elements[1].trim(), 10)
|
||||
'ssid' : lines[i].substring(0, 32).trim(),
|
||||
'mac' : '', // There is no more mac on a mac
|
||||
'channel': parseInt(elements[1].trim(), 10),
|
||||
'rssi' : parseInt(elements[0].trim(), 10)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
3779
package-lock.json
generated
3779
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "node-wifi-scanner",
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.3",
|
||||
"description": "node.js module for WiFi network detection",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@ -35,12 +35,12 @@
|
||||
"test": "mocha test"
|
||||
},
|
||||
"dependencies": {
|
||||
"async": "3.1.0",
|
||||
"lodash": "4.17.15"
|
||||
"async": "3.2.4",
|
||||
"lodash": "4.17.21"
|
||||
},
|
||||
"devDependencies": {
|
||||
"grunt": "^1.0.3",
|
||||
"grunt": "1.5.3",
|
||||
"grunt-bump": "0.8.0",
|
||||
"mocha": "6.2.0"
|
||||
"mocha": "10.2.0"
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ describe('airport', () => {
|
||||
assert.equal(info.length, 36);
|
||||
|
||||
let ap = info[0];
|
||||
assert.equal(ap.mac, '00:35:1a:90:56:03');
|
||||
assert.equal(ap.mac, '');
|
||||
assert.equal(ap.ssid, 'OurTest');
|
||||
assert.equal(ap.rssi, -70);
|
||||
assert.strictEqual(ap.channel, 112);
|
||||
|
2
test/fixtures/airport/airport01.txt
vendored
2
test/fixtures/airport/airport01.txt
vendored
@ -1,5 +1,5 @@
|
||||
SSID BSSID RSSI CHANNEL HT CC SECURITY (auth/unicast/group)
|
||||
OurTest 00:35:1a:90:56:03 -70 112 Y CH WPA2(PSK/AES/AES)
|
||||
OurTest -70 112 Y CH WPA2(PSK/AES/AES)
|
||||
OurDev 00:35:1a:90:56:04 -70 112 Y CH WPA2(PSK/AES/AES)
|
||||
PDANet1 00:35:1a:90:56:09 -70 112 Y CH WPA2(PSK/AES/AES)
|
||||
TEST-Wifi 00:35:1a:90:56:0f -70 112 Y CH WPA2(PSK/AES/AES)
|
||||
|
Reference in New Issue
Block a user