mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
global-functions: add $GetRandom
This commit is contained in:
parent
25a22e2e1c
commit
f49b67f5e7
1 changed files with 13 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue