From 16e93018ef4de9400421a335b4493bee9cd198ef Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Sat, 8 Oct 2022 23:03:29 +0200 Subject: update-tunnelbroker: work around timing issue Looks like fetch command has a timing issue with the tunnelbroker endpoint... We have to try several times to work around this. Consider the update failed on third error. --- update-tunnelbroker | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/update-tunnelbroker b/update-tunnelbroker index 93a829c..eecd02b 100644 --- a/update-tunnelbroker +++ b/update-tunnelbroker @@ -32,17 +32,26 @@ :local InterfaceVal [ /interface/6to4/get $Interface ]; :if ($PublicAddress != $InterfaceVal->"local-address") do={ + :local I 0; + :local Success false; :local Comment [ $ParseKeyValueStore ($InterfaceVal->"comment") ]; :if ([ $CertificateAvailable "Starfield Secure Certificate Authority - G2" ] = false) do={ $LogPrintExit2 error $0 ("Downloading required certificate failed.") true; } $LogPrintExit2 info $0 ("Local address changed, sending UPDATE to tunnelbroker! New address: " . $PublicAddress) false; - :do { - /tool/fetch check-certificate=yes-without-crl \ - ("https://ipv4.tunnelbroker.net/nic/update\?hostname=" . $Comment->"id") \ - user=($Comment->"user") password=($Comment->"pass") output=none as-value; - } on-error={ + :while ($I < 3 && $Success = false) do={ + :do { + /tool/fetch check-certificate=yes-without-crl \ + ("https://ipv4.tunnelbroker.net/nic/update\?hostname=" . $Comment->"id") \ + user=($Comment->"user") password=($Comment->"pass") output=none as-value; + :set Success true; + } on-error={ + :delay 10s; + :set I ($I + 1); + } + } + :if ($Success = false) do={ $LogPrintExit2 error $0 ("Failed sending the local address to tunnelbroker! Wrong credentials?") true; } /interface/6to4/set $Interface local-address=$PublicAddress; -- cgit v1.2.3-70-g09d2