mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
global-functions: add $GetMacVendor
This commit is contained in:
parent
2505e5d42f
commit
ee5eefefc3
|
@ -9,6 +9,7 @@
|
|||
:global "identity";
|
||||
|
||||
:global CertificateAvailable;
|
||||
:global GetMacVendor;
|
||||
:global SendNotification;
|
||||
|
||||
:local "place-before" [ / caps-man access-list find where comment="--- collected above ---" disabled ];
|
||||
|
@ -37,14 +38,7 @@
|
|||
:local interface [ / caps-man registration-table get $regentry interface ];
|
||||
:local ssid [ / caps-man registration-table get $regentry ssid ];
|
||||
:local datetime ([ / system clock get date ] . " " . [ / system clock get time ]);
|
||||
:local vendor;
|
||||
:do {
|
||||
$CertificateAvailable "Let's Encrypt Authority X3" "letsencrypt";
|
||||
:set vendor ([ / tool fetch mode=https check-certificate=yes-without-crl \
|
||||
url=("https://api.macvendors.com/" . [ :pick $mac 0 8 ]) output=user as-value ]->"data");
|
||||
} on-error={
|
||||
:set vendor "unknown vendor";
|
||||
}
|
||||
:local vendor [ $GetMacVendor $mac ];
|
||||
:local message ("unknown MAC address " . $mac . " (" . $vendor . ", " . $hostname . ") " . \
|
||||
"first seen on " . $datetime . " connected to SSID " . $ssid . ", interface " . $interface);
|
||||
/ log info $message;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
:global "identity";
|
||||
|
||||
:global CertificateAvailable;
|
||||
:global GetMacVendor;
|
||||
:global SendNotification;
|
||||
|
||||
:local "place-before" [ / interface wireless access-list find where comment="--- collected above ---" disabled ];
|
||||
|
@ -37,14 +38,7 @@
|
|||
:local interface [ / interface wireless registration-table get $regentry interface ];
|
||||
:local ssid [ / interface wireless get [ find where name=$interface ] ssid ];
|
||||
:local datetime ([ / system clock get date ] . " " . [ / system clock get time ]);
|
||||
:local vendor;
|
||||
:do {
|
||||
$CertificateAvailable "Let's Encrypt Authority X3" "letsencrypt";
|
||||
:set vendor ([ / tool fetch mode=https check-certificate=yes-without-crl \
|
||||
url=("https://api.macvendors.com/" . [ :pick $mac 0 8 ]) output=user as-value ]->"data");
|
||||
} on-error={
|
||||
:set vendor "unknown vendor";
|
||||
}
|
||||
:local vendor [ $GetMacVendor $mac ];
|
||||
:local message ("unknown MAC address " . $mac . " (" . $vendor . ", " . $hostname . ") " . \
|
||||
"first seen on " . $datetime . " connected to SSID " . $ssid . ", interface " . $interface);
|
||||
/ log info $message;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
:global "identity";
|
||||
|
||||
:global CertificateAvailable;
|
||||
:global GetMacVendor;
|
||||
:global SendNotification;
|
||||
|
||||
:local "place-before" [ / %PATH% access-list find where comment="--- collected above ---" disabled ];
|
||||
|
@ -39,14 +40,7 @@
|
|||
:local ssid [ / caps-man registration-table get $regentry ssid ];
|
||||
:local ssid [ / interface wireless get [ find where name=$interface ] ssid ];
|
||||
:local datetime ([ / system clock get date ] . " " . [ / system clock get time ]);
|
||||
:local vendor;
|
||||
:do {
|
||||
$CertificateAvailable "Let's Encrypt Authority X3" "letsencrypt";
|
||||
:set vendor ([ / tool fetch mode=https check-certificate=yes-without-crl \
|
||||
url=("https://api.macvendors.com/" . [ :pick $mac 0 8 ]) output=user as-value ]->"data");
|
||||
} on-error={
|
||||
:set vendor "unknown vendor";
|
||||
}
|
||||
:local vendor [ $GetMacVendor $mac ];
|
||||
:local message ("unknown MAC address " . $mac . " (" . $vendor . ", " . $hostname . ") " . \
|
||||
"first seen on " . $datetime . " connected to SSID " . $ssid . ", interface " . $interface);
|
||||
/ log info $message;
|
||||
|
|
|
@ -92,3 +92,18 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
# get MAC vendor
|
||||
:global GetMacVendor do={
|
||||
:local mac [ :tostr $1 ];
|
||||
|
||||
:do {
|
||||
:local vendor;
|
||||
$CertificateAvailable "Let's Encrypt Authority X3" "letsencrypt";
|
||||
:set vendor ([ / tool fetch mode=https check-certificate=yes-without-crl \
|
||||
url=("https://api.macvendors.com/" . [ :pick $mac 0 8 ]) output=user as-value ]->"data");
|
||||
:return $vendor;
|
||||
} on-error={
|
||||
:return "unknown vendor";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue