feat(api): improve token generation in mikrotik-install script
Build and Push EvoFirewall Docker Image / build-and-push (push) Successful in 1m40s
Build and Push EvoFirewall Docker Image / create-release (push) Skipped

- Updated the token generation logic in `mikrotik-install.rsc` to use a portable random string method, ensuring compatibility with RouterOS 7+.
- Enhanced the token format to include a random number for better uniqueness, improving security and reliability during agent installation.

These changes enhance the robustness of the installation process for agents, ensuring more reliable token generation.
This commit is contained in:
Denozordec
2026-07-23 20:35:45 +07:00
parent d43aaf12b9
commit 94812edab3
@@ -24,9 +24,10 @@
} on-error={}
:if ($already = 0) do={
:local token ("evofw_" . [/certificate scep-server nonce generate])
# Portable token: :rndstr is RouterOS 7+; avoid /certificate scep-server nonce (often missing).
:local token ("evofw_" . [:rndstr length=32 from="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"])
:if ([:len $token] < 20) do={
:set token ("evofw_" . [:tostr [/system clock get time]] . [:tostr [/system resource get cpu-load]] . [:tostr [/system resource get free-memory]])
:set token ("evofw_" . [:tostr [/system clock get time]] . [:tostr [/system resource get cpu-load]] . [:tostr [/system resource get free-memory]] . [:tostr [:rndnum from=100000 to=999999]])
}
:local body ("{\"name\":\"" . $EvofwName . "\",\"hostname\":\"" . [/system identity get name] . "\",\"platform\":\"mikrotik\",\"token\":\"" . $token . "\",\"client_version\":\"rsc/1\"")