Hi, Have a good day.
introduction
RB3011UiAs v6.44.3
We have worked capsman, worked sms auth throw usb modem. Everything working fine with HTTP.
Problem
We have hotspot users session limit in 15 minutes. Internet connection must be lost after limit time finished. If user would insert something http page in the browser, he would be redirected to login page HTTP://hotspot.kdp8.ru. We noticed that user would not be redirected if he would try to enter any HTTPS address. To resolve this problem, we’ve made self sighned cetrificate by mikrotik, and our HTTPS login page became working. BUT sms auth stopped working. When we’ve entered sms password, mikrotik logged failed https auth with wrong login or pass. Login page reloaded, and we’ve got another sms, again and again.
What the problem, How to fix it?
I’ve made some video to show you the problem:
HTTP auth:
https://youtu.be/jFH26rE9iI8
HTTPS auth
https://youtu.be/S_dZ0Og4758
SMS Script
#Search number in log hotspot
:foreach line in=[/log find buffer=hotspot message~“login failed”] do={
:do {:local content [/log get $line message];
:put $content;
:local pos1 [:find $content " (" 0];
:put $pos1;
:if ($pos1 != " ") do={
:local uname “”;
:local uname7 “”;
:local uname8 “”;
:local uname9 “”;
:local phone “”;
:if ([:pick $content ($pos1-10)] = “9”) do={
:set uname [:pick $content ($pos1-10) ($pos1-0)];
:set uname8 [:put (“8” . {$uname})]
#Password generation
:local date [/system clock get time];
:local hour [:pick $date 0 2];
:local min [:pick $date 3 5];
:local sec [:pick $date 6 8];
:local usernumber [:pick $content ($pos1-7) ($pos1-5)];
:put $usernumber;
:global pass 27394;
:set pass ($hour * $min * $sec - $usernumber);
:if ($pass < 100) do={
:set pass 6524;
}
:put $pass;
#Add user to hotspot / user-manager
do {/ip hotspot user add name=$uname} on-error={};
do {/ip hotspot user set password=$pass numbers=[find name=$uname]} on-error={};
do {/tool sms send port=usb2 channel=0 phone-number=“$uname8” message=“login $uname password $pass”} on-error={};
Hotspot user profile
/ip hotspot user profile
set [ find default=yes ] add-mac-cookie=no address-pool=dhcp_pool_hotspot
keepalive-timeout=1m on-login=“:local a $user\r
\n:local nas [/system identity get name];\r
\n:local today [/system clock get date];\r
\n:local time1 [/system clock get time ];\r
\n:local time2 [/system clock get time ];\r
\n:local ipuser [/ip hotspot active get [find user=$a] address];\r
\n:local usermac [/ip hotspot active get [find user=$a] mac-address]\r
\n:local usermac2 [/ip hotspot active get [find user=$a] mac-address]\r
\n:put $today\r
\n:put $time1\r
\n:local hour [:pick $time1 0 2];\r
\n:local min [:pick $time1 3 5];\r
\n:local sec [:pick $time1 6 8];\r
\n:set $time1 [:put ({hour} . {min} . {sec})]\r
\n:local mac1 [:pick $usermac 0 2];\r
\n:local mac2 [:pick $usermac 3 5];\r
\n:local mac3 [:pick $usermac 6 8];\r
\n:local mac4 [:pick $usermac 9 11];\r
\n:local mac5 [:pick $usermac 12 14];\r
\n:local mac6 [:pick $usermac 15 17];\r
\n:set $usermac [:put ({mac1} . {mac2} . {mac3} . {mac4} . {mac5} . {mac6
})]\r
\n:put $time1\r
\n/ip firewall address-list add list=$today address="log-in.$time1.$a.
$usermac.$ipuser"\r
\n/tool fetch url="http://IPSQL/hotspot/hotspot.php\?t=%22$ti
me2%22&l=$a&m=%22$usermac2%22&i=%22$ipuser%22&s=1"\r
\n/file remove "hotspot.php\?t=%22$time2%22&l=$a&m=%22$usermac2%22&i
=%22$ipuser%22&s=1"” on-logout=“:local nas [/system identity get name];
\r
\n:local today [/system clock get date];\r
\n:local time1 [/system clock get time ];\r
\n:local time2 [/system clock get time ];\r
\n:put $today\r
\n:put $time1\r
\n:local hour [:pick $time1 0 2];\r
\n:local min [:pick $time1 3 5];\r
\n:local sec [:pick $time1 6 8];\r
\n:set $time1 [:put ({hour} . {min} . {sec})]\r
\n:put $time1\r
\n/ip firewall address-list add list=$today address="log-out.$time1.$u
ser"\r
\n/tool fetch url="http://IPSQL/hotspot/hotspot.php\?t=%22$ti
me2%22&l=$user&s=0"\r
\n/file remove "hotspot.php\?t=%22$time2%22&l=$user&s=0"\r
\n” session-timeout=15m
IF needed something else, a can post.