berikut ini adalah script untuk melakukan login pada mikrotik
bisa dicb script ini di profilenya :
on-login
======
:local mac
:set mac $"mac-address"
:log warning ("wellcome $user ( $address )")
:local profile [/ip hotspot user get [find name="$user"] profile]
:local rateLimit [/ip hotspot user profile get [find name="$profile"] rate-limit]
:local parent [/ip hotspot user profile get [find name="$profile"] parent]
:local queue [/ip hotspot user profile get [find name="$profile"] queue]
:if ([:len [/queue simple find name="$user-shared"]] > 0) do={
/queue simple remove [find name="$user-$mac"]
/queue simple add max-limit="$rateLimit" name="$user-$mac" parent="$user-shared" queue="$queue/$queue" target="$address"
:local xx 1;
:local targetsimple "";
:foreach y in=[ /queue simple find parent="$user-shared"] do={
:if (xx=1) do={
:set targetsimple [/queue simple get value-name=target "$y"];
} else={
:set targetsimple ($targetsimple . "," . [/queue simple get value-name=target "$y"]);
}
:set xx ($xx+1);
}
/queue simple set [find name="$user-shared"] target="$targetsimple"
} else={
/queue simple add max-limit="$rateLimit" name="$user-shared" parent="$parent" queue="$queue/$queue" target="$address"
/queue simple remove [find name="$user-$mac"]
/queue simple add max-limit="$rateLimit" name="$user-$mac" parent="$user-shared" queue="$queue/$queue" target="$address"
}
/queue simple remove [find where name~"-$user"]
on-logout
=======
:local mac
:set mac $"mac-address"
:log warning ("goodbye $user ( $address )")
/queue simple remove [find name="$user-$mac"]
:if ([/queue simple find parent="$user-shared"] = "" ) do={
:log warning ("delete parent $user-shared, nothing child-queue")
/queue simple remove [find name="$user-shared"]
} else={
:local xx 1;
:local targetsimple "";
:foreach y in=[ /queue simple find parent="$user-shared"] do={
:if (xx=1) do={
:set targetsimple [/queue simple get value-name=target "$y"];
} else={
:set targetsimple ($targetsimple . "," . [/queue simple get value-name=target "$y"]);
}
:set xx ($xx+1);
}
/queue simple set [find name="$user-shared"] target="$targetsimple"
}
note :
====
diprofile harap di set max-limit, parent dan queue-type
on-login
======
:local mac
:set mac $"mac-address"
:log warning ("wellcome $user ( $address )")
:local profile [/ip hotspot user get [find name="$user"] profile]
:local rateLimit [/ip hotspot user profile get [find name="$profile"] rate-limit]
:local parent [/ip hotspot user profile get [find name="$profile"] parent]
:local queue [/ip hotspot user profile get [find name="$profile"] queue]
:if ([:len [/queue simple find name="$user-shared"]] > 0) do={
/queue simple remove [find name="$user-$mac"]
/queue simple add max-limit="$rateLimit" name="$user-$mac" parent="$user-shared" queue="$queue/$queue" target="$address"
:local xx 1;
:local targetsimple "";
:foreach y in=[ /queue simple find parent="$user-shared"] do={
:if (xx=1) do={
:set targetsimple [/queue simple get value-name=target "$y"];
} else={
:set targetsimple ($targetsimple . "," . [/queue simple get value-name=target "$y"]);
}
:set xx ($xx+1);
}
/queue simple set [find name="$user-shared"] target="$targetsimple"
} else={
/queue simple add max-limit="$rateLimit" name="$user-shared" parent="$parent" queue="$queue/$queue" target="$address"
/queue simple remove [find name="$user-$mac"]
/queue simple add max-limit="$rateLimit" name="$user-$mac" parent="$user-shared" queue="$queue/$queue" target="$address"
}
/queue simple remove [find where name~"-$user"]
on-logout
=======
:local mac
:set mac $"mac-address"
:log warning ("goodbye $user ( $address )")
/queue simple remove [find name="$user-$mac"]
:if ([/queue simple find parent="$user-shared"] = "" ) do={
:log warning ("delete parent $user-shared, nothing child-queue")
/queue simple remove [find name="$user-shared"]
} else={
:local xx 1;
:local targetsimple "";
:foreach y in=[ /queue simple find parent="$user-shared"] do={
:if (xx=1) do={
:set targetsimple [/queue simple get value-name=target "$y"];
} else={
:set targetsimple ($targetsimple . "," . [/queue simple get value-name=target "$y"]);
}
:set xx ($xx+1);
}
/queue simple set [find name="$user-shared"] target="$targetsimple"
}
note :
====
diprofile harap di set max-limit, parent dan queue-type