mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2024-05-11 05:55:19 +00:00
global-functions: add $GetRandom
This commit is contained in:
@@ -245,3 +245,16 @@
|
||||
}
|
||||
:return $Result;
|
||||
}
|
||||
|
||||
# generate random number
|
||||
# Warning: This is a *very* weak algorithm and in *no way*
|
||||
# useful for cryptography or similar!
|
||||
:global GetRandom do={
|
||||
:local Max ([ :tonum $1 ] + 1);
|
||||
:local Sum 0;
|
||||
|
||||
:foreach Interface in=[ /interface find ] do={
|
||||
:set Sum ($Sum + [ /interface get $Interface tx-byte ]);
|
||||
}
|
||||
:return ($Sum % $Max);
|
||||
}
|
||||
|
Reference in New Issue
Block a user