forked from haf-decent/arpping
-
Notifications
You must be signed in to change notification settings - Fork 0
/
macLookup.js
53 lines (49 loc) · 1.05 KB
/
macLookup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const addresses = {
"Apple": [
"2:f:b5",
"1c:36:bb",
"8c:85:90",
"8:66:98",
"dc:2b:2a",
"34:8:bc",
"e0:ac:cb",
"dc:a9:04",
"dc:a9:4"
],
"RaspberryPi": [
"b8:27:eb"
],
"ParticlePhoton": [
"e0:4f:43"
],
"Sonos": [
"94:9f:3e",
"78:28:ca"
],
"Netgear": [
"a0:40:a0"
],
"Roku": [
"20:f5:43"
]
}
const stringAddresses = JSON.stringify(addresses);
/**
* Cross references provided mac address with lookup table (incomplete)
* @param {String} mac
* @param {String} type
*
* @returns {String}
*/
function macLookup(mac, type) {
const leading = mac.split(':').slice(0, 3).join(':');
if (type && addresses[ type ]) {
if (addresses[ type ].includes(leading)) return type;
}
if (!stringAddresses.includes(leading)) return null;
for (const vendor in addresses) {
if (addresses[ vendor ].includes(leading)) return vendor;
}
return null;
}
module.exports = macLookup;