aboutsummaryrefslogtreecommitdiffstats
path: root/hotspot-to-wpa-cleanup.rsc
diff options
context:
space:
mode:
Diffstat (limited to 'hotspot-to-wpa-cleanup.rsc')
-rw-r--r--hotspot-to-wpa-cleanup.rsc28
1 files changed, 19 insertions, 9 deletions
diff --git a/hotspot-to-wpa-cleanup.rsc b/hotspot-to-wpa-cleanup.rsc
index 15f63f9..b3aba11 100644
--- a/hotspot-to-wpa-cleanup.rsc
+++ b/hotspot-to-wpa-cleanup.rsc
@@ -13,26 +13,36 @@
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global LogPrintExit2;
+:global ParseKeyValueStore;
:global ScriptLock;
$ScriptLock $0 false 10;
+:local DHCPServers ({});
+:foreach Server in=[ /ip/dhcp-server/find where comment~"hotspot-to-wpa" ] do={
+ :local ServerVal [ /ip/dhcp-server/get $Server ]
+ :if (([ $ParseKeyValueStore ($ServerVal->"comment") ]->"hotspot-to-wpa") = "wpa") do={
+ :set ($DHCPServers->($ServerVal->"name")) 1;
+ }
+}
+
:foreach Client in=[ /caps-man/registration-table/find where comment~"^hotspot-to-wpa:" ] do={
:local ClientVal [ /caps-man/registration-table/get $Client ];
- :local Lease [ /ip/dhcp-server/lease/find where server~"wpa" dynamic \
- mac-address=($ClientVal->"mac-address") ];
- :if ([ :len $Lease ] > 0) do={
- $LogPrintExit2 info $0 ("Client with mac address " . ($ClientVal->"mac-address") . \
- " connected to WPA, making lease static.") false;
- /ip/dhcp-server/lease/make-static $Lease;
- /ip/dhcp-server/lease/set comment=($ClientVal->"comment") $Lease;
+ :foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic \
+ mac-address=($ClientVal->"mac-address") ] do={
+ :if (($DHCPServers->[ /ip/dhcp-server/lease/get $Lease server ]) = 1) do={
+ $LogPrintExit2 info $0 ("Client with mac address " . ($ClientVal->"mac-address") . \
+ " connected to WPA, making lease static.") false;
+ /ip/dhcp-server/lease/make-static $Lease;
+ /ip/dhcp-server/lease/set comment=($ClientVal->"comment") $Lease;
+ }
}
}
-:foreach Client in=[ /caps-man/access-list/find where comment~"^hotspot-to-wpa:" and \
+:foreach Client in=[ /caps-man/access-list/find where comment~"^hotspot-to-wpa:" \
!(comment~[ /system/clock/get date ]) ] do={
:local ClientVal [ /caps-man/access-list/get $Client ];
- :if ([ :len [ /ip/dhcp-server/lease/find where server~"wpa" !dynamic \
+ :if ([ :len [ /ip/dhcp-server/lease/find where !dynamic comment~"^hotspot-to-wpa:" \
mac-address=($ClientVal->"mac-address") ] ] = 0) do={
$LogPrintExit2 info $0 ("Client with mac address " . ($ClientVal->"mac-address") . \
" did not connect to WPA, removing from access list.") false;