Files
netbird/client/internal/dns
Riccardo Manfrin 7420c97930 [client] Keep the resolv.conf watch armed while repairing DNS in file mode (#8207)
* [client] Split resolv.conf parsing from file reading

Pure refactor, no behavior change. parseResolvConf parses content that
was already read, so a caller can compare and parse the same snapshot
of the file instead of reading it twice.

* [client] Return the written content from the resolv.conf update function

Pure refactor, no behavior change. The repair watcher needs to know what
NetBird wrote so it can tell its own write apart from a third party's.
Callers ignore the content for now.

* [client] Keep the resolv.conf watch armed while repairing

In file mode the repair watcher removed its inotify watch, rewrote
resolv.conf and re-added the watch, without looking at the file again.
A second third-party write landing in that window raised no event, so
the file stayed on the upstream resolver until something else touched
it. systemd-resolved with the stub listener off, the Amazon Linux 2023
default, writes the file twice in a row on restart and does not rewrite
it on an unchanged DHCP renewal, so the host stayed off NetBird DNS
while the client reported connected.

The watch now stays armed during the repair. NetBird's own write is
recognized by comparing the file with the content it wrote, which also
covers a write whose search list was truncated to the resolv.conf
limits and would otherwise fail the parameter check forever. The
watcher checks the file once when it is armed, since a change made
before that produced no event.

* [client] Consume inotify errors in the resolv.conf watcher

fsnotify blocks its reader until an error is received. The watcher
never read the Errors channel, so a single error, such as an event
queue overflow, stopped all further events and silently disabled the
repair. The watcher now consumes errors and checks the file, since an
overflow means events were dropped.

* [client] Parse resolv.conf one line at a time

Pure refactor, no behavior change. The per-line handling moves into
parseResolvConfLine, which keeps parseResolvConf under the cognitive
complexity limit.

* [client] Drop the comment restating parseResolvConfLine
2026-10-20 13:35:15 +02:00
..
2024-06-13 13:24:24 +02:00
2024-06-13 13:24:24 +02:00
2023-07-14 21:56:22 +02:00
2023-12-18 11:46:58 +01:00
2024-06-13 13:24:24 +02:00