aboutsummaryrefslogtreecommitdiffstats
path: root/update-tunnelbroker.rsc
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2023-06-23 09:36:52 +0200
committerGravatar Christian Hesse <mail@eworm.de>2023-06-23 09:49:34 +0200
commitec7adcf78e2533a81c43145023aaeaf3740fe729 (patch)
treeccab976fa6cbeea88625ee7d5eaf988490fb40bb /update-tunnelbroker.rsc
parenteb3b4d169ef57a60c95cb91105bbd9401cc6ae37 (diff)
update-tunnelbroker: rework the retry-loop
Diffstat (limited to 'update-tunnelbroker.rsc')
-rw-r--r--update-tunnelbroker.rsc21
1 files changed, 11 insertions, 10 deletions
diff --git a/update-tunnelbroker.rsc b/update-tunnelbroker.rsc
index a1d5e5e..d0a2d16 100644
--- a/update-tunnelbroker.rsc
+++ b/update-tunnelbroker.rsc
@@ -25,27 +25,28 @@ $ScriptLock $0;
}
:foreach Interface in=[ /interface/6to4/find where comment~"^tunnelbroker" !disabled ] do={
- :local I 0;
- :local Response "";
+ :local Data false;
:local InterfaceVal [ /interface/6to4/get $Interface ];
:local Comment [ $ParseKeyValueStore ($InterfaceVal->"comment") ];
- :while ($I < 3 && $Response = "") do={
- :do {
- :set Response ([ /tool/fetch check-certificate=yes-without-crl \
+ :for I from=2 to=0 do={
+ :if ($Data = false) do={
+ :do {
+ :set Data ([ /tool/fetch check-certificate=yes-without-crl \
("https://ipv4.tunnelbroker.net/nic/update\?hostname=" . $Comment->"id") \
user=($Comment->"user") password=($Comment->"pass") output=user as-value ]->"data");
- } on-error={
- :delay 10s;
- :set I ($I + 1);
+ } on-error={
+ $LogPrintExit2 debug $0 ("Failed downloading, " . $I . " retries pending.") false;
+ :delay 2s;
+ }
}
}
- :if (!($Response~"^(good|nochg) ")) do={
+ :if (!($Data ~ "^(good|nochg) ")) do={
$LogPrintExit2 error $0 ("Failed sending the local address to tunnelbroker or unexpected response!") true;
}
- :local PublicAddress [ :pick $Response ([ :find $Response " " ] + 1) [ :find $Response "\n" ] ];
+ :local PublicAddress [ :pick $Data ([ :find $Data " " ] + 1) [ :find $Data "\n" ] ];
:if ($PublicAddress != $InterfaceVal->"local-address") do={
:if ([ :len [ /ip/address find where address~("^" . $PublicAddress . "/") ] ] < 1) do={