feat: Add MAC address vendor lookup API endpoint and dependencies

This commit is contained in:
2026-01-02 18:14:53 +01:00
parent eec2ed1adb
commit cde424e881
3 changed files with 11 additions and 32 deletions

View File

@@ -15,8 +15,8 @@
"dotenv": "^16.4.7",
"express": "^4.21.2",
"express-rate-limit": "^7.5.0",
"mac-oui-lookup": "^1.1.4",
"macaddress": "^0.5.3",
"oui": "^13.1.1",
"pino": "^9.6.0",
"pino-pretty": "^13.0.0",
"qs": "^6.14.1",
@@ -1567,6 +1567,12 @@
"lower-case": "^1.1.2"
}
},
"node_modules/mac-oui-lookup": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/mac-oui-lookup/-/mac-oui-lookup-1.1.4.tgz",
"integrity": "sha512-VuzR8PnMef92j86Mspx8gRwEtW3DjIR2xu2G5x3ezszdopEjVhrrI0r9SpkfPqJMQbsbWRnJrFxTKMXiUaJHHQ==",
"license": "MIT"
},
"node_modules/macaddress": {
"version": "0.5.3",
"resolved": "https://registry.npmjs.org/macaddress/-/macaddress-0.5.3.tgz",
@@ -1736,24 +1742,6 @@
"wrappy": "1"
}
},
"node_modules/oui": {
"version": "13.1.1",
"resolved": "https://registry.npmjs.org/oui/-/oui-13.1.1.tgz",
"integrity": "sha512-kv8YMm3UT8Rn5g2N7laIZfgcuWFhuLdyO3D9y3tTe1uBPNaNJMdLSkeb0l8C9jl7H4vgJ3GFfUv9gjVP9CQDmg==",
"license": "BSD-2-Clause",
"dependencies": {
"oui-data": "^1.1.428"
},
"bin": {
"oui": "dist/index.js"
}
},
"node_modules/oui-data": {
"version": "1.1.476",
"resolved": "https://registry.npmjs.org/oui-data/-/oui-data-1.1.476.tgz",
"integrity": "sha512-TTcraRcKV4TTLex4261J2w0AMjq8X5Mj0u4FfIBqLXPSCz+sh37Zdk5g383i7fidoMW+SSfQ1POunNrYenYzKQ==",
"license": "BSD-2-Clause"
},
"node_modules/p-limit": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",

View File

@@ -16,11 +16,11 @@
"dotenv": "^16.4.7",
"express": "^4.21.2",
"express-rate-limit": "^7.5.0",
"mac-oui-lookup": "^1.1.4",
"macaddress": "^0.5.3",
"oui": "^13.1.1",
"pino": "^9.6.0",
"pino-pretty": "^13.0.0",
"qs": "^6.14.1",
"whois-json": "^2.0.4"
}
}
}

View File

@@ -1,6 +1,7 @@
const express = require('express');
const Sentry = require("@sentry/node");
const pino = require('pino');
const { getVendor } = require('mac-oui-lookup');
const { isValidMacAddress } = require('../utils');
const logger = pino({ level: process.env.LOG_LEVEL || 'info' });
@@ -19,17 +20,7 @@ router.get('/', async (req, res) => {
}
try {
// Dynamic import for ESM-only 'oui' module. Pointing to dist/index.js explicitly.
const ouiModule = await import('oui/dist/index.js');
const oui = ouiModule.default;
const ouiData = oui(mac);
// oui returns a string (Vendor Name) or null if not found
let vendor = null;
if (ouiData) {
vendor = typeof ouiData === 'string' ? ouiData : ouiData.split('\n')[0];
}
const vendor = getVendor(mac);
if (vendor) {
logger.info({ requestIp, mac, vendor }, 'MAC lookup successful');