Compare commits

...

2 commits

Author SHA1 Message Date
Christian Hesse
cc56680206 log-forward: try to mitigate a race condition
The old code looped over all new messages, then updated the variable
to the newest message - at that time! Messages in between were lost.
2026-01-14 15:19:12 +01:00
Christian Hesse
6fd28bf8f7 netwatch-dns: check the certificate is available for fetch
That trust is not needed for DNS functionality (that was checked before),
but for our hacky check with fetch.
2026-01-14 15:05:07 +01:00
2 changed files with 9 additions and 4 deletions

View file

@ -62,7 +62,11 @@
:set LogForwardInclude [ $EitherOr $LogForwardInclude [] ];
:set LogForwardIncludeMessage [ $EitherOr $LogForwardIncludeMessage [] ];
:local LogAll [ /log/find ];
:local MaxId ($LogAll->([ :len $LogAll ] - 1));
:local MaxNum [ $HexToNum $MaxId ];
:local LogForwardFilterLogForwardingCached [ $EitherOr [ $LogForwardFilterLogForwarding ] ("\$^") ];
:foreach Message in=[ /log/find where (!(message="") and \
!(message~$LogForwardFilterLogForwardingCached) and \
!(topics~$LogForwardFilter) and !(message~$LogForwardFilterMessage)) or \
@ -70,7 +74,8 @@
:set MessageVal [ /log/get $Message ];
:local Bullet "information";
:if ($Last < [ $HexToNum ($MessageVal->".id") ]) do={
:local Current [ $HexToNum ($MessageVal->".id") ];
:if ($Last < $Current && $Current <= $MaxNum) do={
:local DupCount ($MessageDups->($MessageVal->"message"));
:if ($MessageVal->"topics" ~ "(warning)") do={
:set Warning true;
@ -106,8 +111,7 @@
:set LogForwardRateLimit [ $MAX 0 ($LogForwardRateLimit - 1) ];
}
:local LogAll [ /log/find ];
:set LogForwardLast ($LogAll->([ :len $LogAll ] - 1) );
:set LogForwardLast $MaxId;
} do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err;
}

View file

@ -104,7 +104,8 @@
:foreach DohServer in=$DohServers do={
:if ([ :len ($DohServer->"doh-cert") ] > 0) do={
:if ([ $CertificateAvailable ($DohServer->"doh-cert") "dns" ] = false) do={
:if ([ $CertificateAvailable ($DohServer->"doh-cert") "fetch" ] = false || \
[ $CertificateAvailable ($DohServer->"doh-cert") "dns" ] = false) do={
$LogPrint warning $ScriptName ("Downloading certificate failed, trying without.");
}
}