mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-08-01 14:11:35 +00:00
Compare commits
2 commits
f2bffb1c68
...
2d13c066f3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d13c066f3 | ||
|
|
fd50428e1f |
6 changed files with 29 additions and 47 deletions
|
|
@ -43,13 +43,10 @@
|
|||
:continue;
|
||||
}
|
||||
|
||||
:local MacAddress $"mac-address";
|
||||
:local UserName $username;
|
||||
|
||||
:local Date [ /system/clock/get date ];
|
||||
:local UserVal ({});
|
||||
:if ([ :len [ /ip/hotspot/user/find where name=$UserName ] ] > 0) do={
|
||||
:set UserVal [ /ip/hotspot/user/get [ find where name=$UserName ] ];
|
||||
:if ([ :len [ /ip/hotspot/user/find where name=($LeaseVal->"username") ] ] > 0) do={
|
||||
:set UserVal [ /ip/hotspot/user/get [ find where name=($LeaseVal->"username") ] ];
|
||||
}
|
||||
:local UserInfo [ $ParseKeyValueStore ($UserVal->"comment") ];
|
||||
|
||||
|
|
@ -61,15 +58,15 @@
|
|||
:local Template [ /caps-man/access-list/get ([ find where \
|
||||
comment=("hotspot-to-wpa template " . $LeaseVal->"hotspot") disabled ]->0) ];
|
||||
|
||||
$LogPrint info $ScriptName ("Adding/updating access-list entry for mac address " . $MacAddress . \
|
||||
" (user " . $UserName . ").");
|
||||
/caps-man/access-list/remove [ find where mac-address=$MacAddress comment~"^hotspot-to-wpa: " ];
|
||||
$LogPrint info $ScriptName ("Adding/updating access-list entry for mac address " . $LeaseVal->"mac-address" . \
|
||||
" (user " . $LeaseVal->"username" . ").");
|
||||
/caps-man/access-list/remove [ find where mac-address=($LeaseVal->"mac-address") comment~"^hotspot-to-wpa: " ];
|
||||
/caps-man/access-list/add private-passphrase=($UserVal->"password") ssid-regexp="-wpa\$" \
|
||||
mac-address=$MacAddress comment=("hotspot-to-wpa: " . $UserName . ", " . $MacAddress . ", " . $Date) \
|
||||
action=reject place-before=$PlaceBefore;
|
||||
mac-address=($LeaseVal->"mac-address") comment=("hotspot-to-wpa: " . $LeaseVal->"username" . \
|
||||
", " . $LeaseVal->"mac-address" . ", " . $Date) action=reject place-before=$PlaceBefore;
|
||||
|
||||
:local Entry [ /caps-man/access-list/find where mac-address=$MacAddress \
|
||||
comment=("hotspot-to-wpa: " . $UserName . ", " . $MacAddress . ", " . $Date) ];
|
||||
:local Entry [ /caps-man/access-list/find where mac-address=($LeaseVal->"mac-address") \
|
||||
comment=("hotspot-to-wpa: " . $LeaseVal->"username" . ", " . $LeaseVal->"mac-address" . ", " . $Date) ];
|
||||
:local PrivatePassphrase [ $EitherOr ($UserInfo->"private-passphrase") ($Template->"private-passphrase") ];
|
||||
:if ([ :len $PrivatePassphrase ] > 0) do={
|
||||
:if ($PrivatePassphrase = "ignore") do={
|
||||
|
|
|
|||
|
|
@ -47,13 +47,10 @@
|
|||
:continue;
|
||||
}
|
||||
|
||||
:local MacAddress $"mac-address";
|
||||
:local UserName $username;
|
||||
|
||||
:local Date [ /system/clock/get date ];
|
||||
:local UserVal ({});
|
||||
:if ([ :len [ /ip/hotspot/user/find where name=$UserName ] ] > 0) do={
|
||||
:set UserVal [ /ip/hotspot/user/get [ find where name=$UserName ] ];
|
||||
:if ([ :len [ /ip/hotspot/user/find where name=($LeaseVal->"username") ] ] > 0) do={
|
||||
:set UserVal [ /ip/hotspot/user/get [ find where name=($LeaseVal->"username") ] ];
|
||||
}
|
||||
:local UserInfo [ $ParseKeyValueStore ($UserVal->"comment") ];
|
||||
|
||||
|
|
@ -68,18 +65,18 @@
|
|||
:local Template [ /interface/wifi/access-list/get ([ find where \
|
||||
comment=("hotspot-to-wpa template " . $LeaseVal->"hotspot") disabled ]->0) ];
|
||||
|
||||
$LogPrint info $ScriptName ("Adding/updating access-list entry for mac address " . $MacAddress . \
|
||||
" (user " . $UserName . ").");
|
||||
/caps-man/access-list/remove [ find where mac-address=$MacAddress comment~"^hotspot-to-wpa: " ];
|
||||
/interface/wifi/access-list/remove [ find where mac-address=$MacAddress comment~"^hotspot-to-wpa: " ];
|
||||
$LogPrint info $ScriptName ("Adding/updating access-list entry for mac address " . $LeaseVal->"mac-address" . \
|
||||
" (user " . $LeaseVal->"username" . ").");
|
||||
/caps-man/access-list/remove [ find where mac-address=($LeaseVal->"mac-address") comment~"^hotspot-to-wpa: " ];
|
||||
/interface/wifi/access-list/remove [ find where mac-address=($LeaseVal->"mac-address") comment~"^hotspot-to-wpa: " ];
|
||||
/caps-man/access-list/add private-passphrase=($UserVal->"password") ssid-regexp="-wpa\$" \
|
||||
/interface/wifi/access-list/add passphrase=($UserVal->"password") ssid-regexp="-wpa\$" \
|
||||
mac-address=$MacAddress comment=("hotspot-to-wpa: " . $UserName . ", " . $MacAddress . ", " . $Date) \
|
||||
action=reject place-before=$PlaceBefore;
|
||||
mac-address=($LeaseVal->"mac-address") comment=("hotspot-to-wpa: " . $LeaseVal->"username" . \
|
||||
", " . $LeaseVal->"mac-address" . ", " . $Date) action=reject place-before=$PlaceBefore;
|
||||
|
||||
:local Entry [ /caps-man/access-list/find where mac-address=$MacAddress \
|
||||
:local Entry [ /interface/wifi/access-list/find where mac-address=$MacAddress \
|
||||
comment=("hotspot-to-wpa: " . $UserName . ", " . $MacAddress . ", " . $Date) ];
|
||||
:local Entry [ /caps-man/access-list/find where mac-address=($LeaseVal->"mac-address") \
|
||||
:local Entry [ /interface/wifi/access-list/find where mac-address=($LeaseVal->"mac-address") \
|
||||
comment=("hotspot-to-wpa: " . $LeaseVal->"username" . ", " . $LeaseVal->"mac-address" . ", " . $Date) ];
|
||||
# NOT /caps-man/ #
|
||||
:set ($Template->"private-passphrase") ($Template->"passphrase");
|
||||
# NOT /caps-man/ #
|
||||
|
|
|
|||
|
|
@ -43,13 +43,10 @@
|
|||
:continue;
|
||||
}
|
||||
|
||||
:local MacAddress $"mac-address";
|
||||
:local UserName $username;
|
||||
|
||||
:local Date [ /system/clock/get date ];
|
||||
:local UserVal ({});
|
||||
:if ([ :len [ /ip/hotspot/user/find where name=$UserName ] ] > 0) do={
|
||||
:set UserVal [ /ip/hotspot/user/get [ find where name=$UserName ] ];
|
||||
:if ([ :len [ /ip/hotspot/user/find where name=($LeaseVal->"username") ] ] > 0) do={
|
||||
:set UserVal [ /ip/hotspot/user/get [ find where name=($LeaseVal->"username") ] ];
|
||||
}
|
||||
:local UserInfo [ $ParseKeyValueStore ($UserVal->"comment") ];
|
||||
|
||||
|
|
@ -61,15 +58,15 @@
|
|||
:local Template [ /interface/wifi/access-list/get ([ find where \
|
||||
comment=("hotspot-to-wpa template " . $LeaseVal->"hotspot") disabled ]->0) ];
|
||||
|
||||
$LogPrint info $ScriptName ("Adding/updating access-list entry for mac address " . $MacAddress . \
|
||||
" (user " . $UserName . ").");
|
||||
/interface/wifi/access-list/remove [ find where mac-address=$MacAddress comment~"^hotspot-to-wpa: " ];
|
||||
$LogPrint info $ScriptName ("Adding/updating access-list entry for mac address " . $LeaseVal->"mac-address" . \
|
||||
" (user " . $LeaseVal->"username" . ").");
|
||||
/interface/wifi/access-list/remove [ find where mac-address=($LeaseVal->"mac-address") comment~"^hotspot-to-wpa: " ];
|
||||
/interface/wifi/access-list/add passphrase=($UserVal->"password") ssid-regexp="-wpa\$" \
|
||||
mac-address=$MacAddress comment=("hotspot-to-wpa: " . $UserName . ", " . $MacAddress . ", " . $Date) \
|
||||
action=reject place-before=$PlaceBefore;
|
||||
mac-address=($LeaseVal->"mac-address") comment=("hotspot-to-wpa: " . $LeaseVal->"username" . \
|
||||
", " . $LeaseVal->"mac-address" . ", " . $Date) action=reject place-before=$PlaceBefore;
|
||||
|
||||
:local Entry [ /interface/wifi/access-list/find where mac-address=$MacAddress \
|
||||
comment=("hotspot-to-wpa: " . $UserName . ", " . $MacAddress . ", " . $Date) ];
|
||||
:local Entry [ /interface/wifi/access-list/find where mac-address=($LeaseVal->"mac-address") \
|
||||
comment=("hotspot-to-wpa: " . $LeaseVal->"username" . ", " . $LeaseVal->"mac-address" . ", " . $Date) ];
|
||||
:set ($Template->"private-passphrase") ($Template->"passphrase");
|
||||
:local PrivatePassphrase [ $EitherOr ($UserInfo->"private-passphrase") ($Template->"private-passphrase") ];
|
||||
:if ([ :len $PrivatePassphrase ] > 0) do={
|
||||
|
|
|
|||
|
|
@ -30,15 +30,12 @@
|
|||
}
|
||||
|
||||
:local Lease [ /ip/dhcp-server/lease/find where mac-address=$MacAddress address=$Address ];
|
||||
|
||||
:if ([ :len $Lease ] != 1) do={
|
||||
:log warning ($ScriptName . ": Did not find exactly one lease for " . $MacAddress . "!");
|
||||
:set ExitOK true;
|
||||
:error false;
|
||||
}
|
||||
|
||||
:local Hotspot [ /ip/hotspot/host/get [ find where mac-address=$MacAddress authorized ] server ];
|
||||
|
||||
/ip/dhcp-server/lease/set \
|
||||
comment=[ :serialize to=json ({ \
|
||||
"hotspot-to-wpa"=true; \
|
||||
|
|
|
|||
|
|
@ -32,15 +32,12 @@
|
|||
}
|
||||
|
||||
:local Lease [ /ip/dhcp-server/lease/find where mac-address=$MacAddress address=$Address ];
|
||||
|
||||
:if ([ :len $Lease ] != 1) do={
|
||||
:log warning ($ScriptName . ": Did not find exactly one lease for " . $MacAddress . "!");
|
||||
:set ExitOK true;
|
||||
:error false;
|
||||
}
|
||||
|
||||
:local Hotspot [ /ip/hotspot/host/get [ find where mac-address=$MacAddress authorized ] server ];
|
||||
|
||||
/ip/dhcp-server/lease/set \
|
||||
comment=[ :serialize to=json ({ \
|
||||
"hotspot-to-wpa"=true; \
|
||||
|
|
|
|||
|
|
@ -30,15 +30,12 @@
|
|||
}
|
||||
|
||||
:local Lease [ /ip/dhcp-server/lease/find where mac-address=$MacAddress address=$Address ];
|
||||
|
||||
:if ([ :len $Lease ] != 1) do={
|
||||
:log warning ($ScriptName . ": Did not find exactly one lease for " . $MacAddress . "!");
|
||||
:set ExitOK true;
|
||||
:error false;
|
||||
}
|
||||
|
||||
:local Hotspot [ /ip/hotspot/host/get [ find where mac-address=$MacAddress authorized ] server ];
|
||||
|
||||
/ip/dhcp-server/lease/set \
|
||||
comment=[ :serialize to=json ({ \
|
||||
"hotspot-to-wpa"=true; \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue