mirror of
https://github.com/MrUnknownDE/utools.git
synced 2026-04-23 07:53:45 +02:00
try again mac-lookup
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// backend/utils.js
|
||||
const net = require('net'); // Node.js built-in module for IP validation
|
||||
const { spawn } = require('child_process');
|
||||
const pino = require('pino'); // Import pino for logging within utils if needed
|
||||
@@ -65,6 +66,20 @@ function isValidDomain(domain) {
|
||||
return domainRegex.test(domain.trim());
|
||||
}
|
||||
|
||||
/**
|
||||
* Validiert eine MAC-Adresse.
|
||||
* @param {string} mac - Die zu validierende MAC-Adresse.
|
||||
* @returns {boolean} True, wenn das Format gültig ist, sonst false.
|
||||
*/
|
||||
function isValidMacAddress(mac) {
|
||||
if (!mac || typeof mac !== 'string') {
|
||||
return false;
|
||||
}
|
||||
// This regex matches common MAC address formats (e.g., 00:1A:2B:3C:4D:5E, 00-1A-2B-3C-4D-5E, 001A2B3C4D5E)
|
||||
const macRegex = /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$|^([0-9A-Fa-f]{12})$/;
|
||||
return macRegex.test(mac.trim());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Bereinigt eine IP-Adresse (z.B. entfernt ::ffff: Präfix von IPv4-mapped IPv6).
|
||||
@@ -302,6 +317,7 @@ module.exports = {
|
||||
isValidIp,
|
||||
isPrivateIp,
|
||||
isValidDomain,
|
||||
isValidMacAddress,
|
||||
getCleanIp,
|
||||
executeCommand,
|
||||
parsePingOutput,
|
||||
|
||||
Reference in New Issue
Block a user