mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-08 17:14:29 +02:00
global-functions: add $GetMacVendor
This commit is contained in:
parent
2505e5d42f
commit
ee5eefefc3
4 changed files with 21 additions and 24 deletions
|
@ -9,6 +9,7 @@
|
||||||
:global "identity";
|
:global "identity";
|
||||||
|
|
||||||
:global CertificateAvailable;
|
:global CertificateAvailable;
|
||||||
|
:global GetMacVendor;
|
||||||
:global SendNotification;
|
:global SendNotification;
|
||||||
|
|
||||||
:local "place-before" [ / caps-man access-list find where comment="--- collected above ---" disabled ];
|
: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 interface [ / caps-man registration-table get $regentry interface ];
|
||||||
:local ssid [ / caps-man registration-table get $regentry ssid ];
|
:local ssid [ / caps-man registration-table get $regentry ssid ];
|
||||||
:local datetime ([ / system clock get date ] . " " . [ / system clock get time ]);
|
:local datetime ([ / system clock get date ] . " " . [ / system clock get time ]);
|
||||||
:local vendor;
|
:local vendor [ $GetMacVendor $mac ];
|
||||||
: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 message ("unknown MAC address " . $mac . " (" . $vendor . ", " . $hostname . ") " . \
|
:local message ("unknown MAC address " . $mac . " (" . $vendor . ", " . $hostname . ") " . \
|
||||||
"first seen on " . $datetime . " connected to SSID " . $ssid . ", interface " . $interface);
|
"first seen on " . $datetime . " connected to SSID " . $ssid . ", interface " . $interface);
|
||||||
/ log info $message;
|
/ log info $message;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
:global "identity";
|
:global "identity";
|
||||||
|
|
||||||
:global CertificateAvailable;
|
:global CertificateAvailable;
|
||||||
|
:global GetMacVendor;
|
||||||
:global SendNotification;
|
:global SendNotification;
|
||||||
|
|
||||||
:local "place-before" [ / interface wireless access-list find where comment="--- collected above ---" disabled ];
|
: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 interface [ / interface wireless registration-table get $regentry interface ];
|
||||||
:local ssid [ / interface wireless get [ find where name=$interface ] ssid ];
|
:local ssid [ / interface wireless get [ find where name=$interface ] ssid ];
|
||||||
:local datetime ([ / system clock get date ] . " " . [ / system clock get time ]);
|
:local datetime ([ / system clock get date ] . " " . [ / system clock get time ]);
|
||||||
:local vendor;
|
:local vendor [ $GetMacVendor $mac ];
|
||||||
: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 message ("unknown MAC address " . $mac . " (" . $vendor . ", " . $hostname . ") " . \
|
:local message ("unknown MAC address " . $mac . " (" . $vendor . ", " . $hostname . ") " . \
|
||||||
"first seen on " . $datetime . " connected to SSID " . $ssid . ", interface " . $interface);
|
"first seen on " . $datetime . " connected to SSID " . $ssid . ", interface " . $interface);
|
||||||
/ log info $message;
|
/ log info $message;
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
:global "identity";
|
:global "identity";
|
||||||
|
|
||||||
:global CertificateAvailable;
|
:global CertificateAvailable;
|
||||||
|
:global GetMacVendor;
|
||||||
:global SendNotification;
|
:global SendNotification;
|
||||||
|
|
||||||
:local "place-before" [ / %PATH% access-list find where comment="--- collected above ---" disabled ];
|
: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 [ / caps-man registration-table get $regentry ssid ];
|
||||||
:local ssid [ / interface wireless get [ find where name=$interface ] ssid ];
|
:local ssid [ / interface wireless get [ find where name=$interface ] ssid ];
|
||||||
:local datetime ([ / system clock get date ] . " " . [ / system clock get time ]);
|
:local datetime ([ / system clock get date ] . " " . [ / system clock get time ]);
|
||||||
:local vendor;
|
:local vendor [ $GetMacVendor $mac ];
|
||||||
: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 message ("unknown MAC address " . $mac . " (" . $vendor . ", " . $hostname . ") " . \
|
:local message ("unknown MAC address " . $mac . " (" . $vendor . ", " . $hostname . ") " . \
|
||||||
"first seen on " . $datetime . " connected to SSID " . $ssid . ", interface " . $interface);
|
"first seen on " . $datetime . " connected to SSID " . $ssid . ", interface " . $interface);
|
||||||
/ log info $message;
|
/ 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…
Add table
Add a link
Reference in a new issue