Skip to content

Commit 16e9301

Browse files
committed
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.
1 parent ebaa9b6 commit 16e9301

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

update-tunnelbroker

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,26 @@
3232
:local InterfaceVal [ /interface/6to4/get $Interface ];
3333

3434
:if ($PublicAddress != $InterfaceVal->"local-address") do={
35+
:local I 0;
36+
:local Success false;
3537
:local Comment [ $ParseKeyValueStore ($InterfaceVal->"comment") ];
3638

3739
:if ([ $CertificateAvailable "Starfield Secure Certificate Authority - G2" ] = false) do={
3840
$LogPrintExit2 error $0 ("Downloading required certificate failed.") true;
3941
}
4042
$LogPrintExit2 info $0 ("Local address changed, sending UPDATE to tunnelbroker! New address: " . $PublicAddress) false;
41-
:do {
42-
/tool/fetch check-certificate=yes-without-crl \
43-
("https://ipv4.tunnelbroker.net/nic/update\?hostname=" . $Comment->"id") \
44-
user=($Comment->"user") password=($Comment->"pass") output=none as-value;
45-
} on-error={
43+
:while ($I < 3 && $Success = false) do={
44+
:do {
45+
/tool/fetch check-certificate=yes-without-crl \
46+
("https://ipv4.tunnelbroker.net/nic/update\?hostname=" . $Comment->"id") \
47+
user=($Comment->"user") password=($Comment->"pass") output=none as-value;
48+
:set Success true;
49+
} on-error={
50+
:delay 10s;
51+
:set I ($I + 1);
52+
}
53+
}
54+
:if ($Success = false) do={
4655
$LogPrintExit2 error $0 ("Failed sending the local address to tunnelbroker! Wrong credentials?") true;
4756
}
4857
/interface/6to4/set $Interface local-address=$PublicAddress;

0 commit comments

Comments
 (0)