I've had the script below (reload the endpoint's DNS) set in scheduler to run every 30 minutes.
Lately I've noticed that the "if...do" is triggered (i.e., the "if" resolves to "yes") every time the script is run, despite $LastHandshake being less than 5m. Pretty sure $LastHandshake resolves to ""
I didn't write the script, and I don't understand when $LastHandshake would resolve to ""
Can I just take out the condition: ([:tostr $LastHandshake] = "")
I vaguely remember mention that more recent versions of RouterOS do not need this DNS re-resolve -- and I dreaming this or is it true?
Thanks!
Lately I've noticed that the "if...do" is triggered (i.e., the "if" resolves to "yes") every time the script is run, despite $LastHandshake being less than 5m. Pretty sure $LastHandshake resolves to ""
I didn't write the script, and I don't understand when $LastHandshake would resolve to ""
Can I just take out the condition: ([:tostr $LastHandshake] = "")
I vaguely remember mention that more recent versions of RouterOS do not need this DNS re-resolve -- and I dreaming this or is it true?
Thanks!
Code:
:foreach i in=[/interface/wireguard/peers/find where disabled=no endpoint-address~"[a-z]\$"] do={ :local LastHandshake [/interface/wireguard/peers/get $i last-handshake] :if (([:tostr $LastHandshake] = "") or ($LastHandshake > [:totime "5m"])) do={ :log info "WG-iface-restart script found WG peers with last handshake greater than 5 minutes; then reset the endpoint-address to reload dns of endpoint" /interface/wireguard/peers/set $i endpoint-address=[/interface/wireguard/peers/get $i endpoint-address] :local endpoint [/interface/wireguard/peers/get $i endpoint-address] :log info "WG-iface-restart script found WG peer with last handshake greater than 5 minutes; then reset the endpoint-address to reload dns of endpoint: $endpoint" }}
Statistics: Posted by Josephny — Tue Apr 02, 2024 1:37 pm