aboutsummaryrefslogtreecommitdiffstats
path: root/collect-wireless-mac.capsman
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2021-07-01 09:56:34 +0200
committerGravatar Christian Hesse <mail@eworm.de>2021-07-01 22:52:38 +0200
commit877e95d4be240835e2153ba4ce5fe615a127eda1 (patch)
tree88117adc641dcf19ca6177d9ddec95bd6fc589e9 /collect-wireless-mac.capsman
parent5f357fd242c8798769e505817bb075eb9abf8a88 (diff)
collect-wireless-mac: properly handle vanished device
Diffstat (limited to 'collect-wireless-mac.capsman')
-rw-r--r--collect-wireless-mac.capsman21
1 files changed, 15 insertions, 6 deletions
diff --git a/collect-wireless-mac.capsman b/collect-wireless-mac.capsman
index 3137aa6..0e65dcd 100644
--- a/collect-wireless-mac.capsman
+++ b/collect-wireless-mac.capsman
@@ -31,9 +31,21 @@ $ScriptLock $0 false 10;
:local PlaceBefore ([ / caps-man access-list find where comment="--- collected above ---" disabled ]->0);
:foreach RegTbl in=[ / caps-man registration-table find ] do={
- :local Mac [ / caps-man registration-table get $RegTbl mac-address ];
- :local AccessList ([ / caps-man access-list find where mac-address=$Mac ]->0);
- :if ([ :len $AccessList ] = 0) do={
+ :local Mac;
+ :local AccessList;
+ :do {
+ :set Mac [ / caps-man registration-table get $RegTbl mac-address ];
+ :set AccessList ([ / caps-man access-list find where mac-address=$Mac ]->0);
+ } on-error={
+ $LogPrintExit2 debug $0 ("Device already gone... Ignoring.") false;
+ }
+
+ :if ([ :len $AccessList ] > 0) do={
+ $LogPrintExit2 debug $0 ("MAC address " . $Mac . " already known: " . \
+ [ / caps-man access-list get $AccessList comment ]) false;
+ }
+
+ :if ([ :typeof $Mac ] = "str" && [ :len $AccessList ] = 0) do={
:local Address "no dhcp lease";
:local DnsName "no dhcp lease";
:local HostName "no dhcp lease";
@@ -70,8 +82,5 @@ $ScriptLock $0 false 10;
"Address: " . $Address . "\n" . \
"DNS name: " . $DnsName . "\n" . \
"Date: " . $DateTime) });
- } else={
- $LogPrintExit2 debug $0 ("MAC address " . $Mac . " already known: " . \
- [ / caps-man access-list get $AccessList comment ]) false;
}
}