Commit Graph

87 Commits

Author SHA1 Message Date
Michael Tremer
e595fa1176 unbound-dhcp-leases-bridge: Fix expiry check on leases
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
2024-11-05 09:12:30 +01:00
Michael Tremer
131bcfa999 unbound-dhcp-leases-bridge: Don't overwrite static leases
When we import all static leases, their remark will be used as hostname
(because WTF?) and might be overwritten if the device is not sending any
or even the same hostname.

This patch avoids that static leases will be modified.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Reviewed-by: Bernhard Bitsch <bbitsch@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
2024-11-05 09:12:17 +01:00
Michael Tremer
a81eefa265 unbound-dhcp-leases-bridge: Fix typo
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Reviewed-by: Bernhard Bitsch <bbitsch@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
2024-11-05 09:11:55 +01:00
Michael Tremer
17a9ad2f52 unbound-dhcp-leases-bridge: Don't export expired leases to Unbound
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Reviewed-by: Bernhard Bitsch <bbitsch@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
2024-11-05 09:11:43 +01:00
Michael Tremer
8ead2ddf3d unbound-dhcp-leases-bridge: Watch unbound
This patch adds a watcher thread which monitors if Unbound is still
alive. If not, it will wait until Unbound comes back, rewrite the leases
file and reload Unbound to get it back into sync.

Afterwards Unbound will receive updates as usual.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-08-21 10:10:33 +01:00
Michael Tremer
c2a389e9d4 unbound-dhcp-leases-bridge: Remove unused functions and module imports
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 17:53:22 +01:00
Michael Tremer
1908e3d070 unbound-dhcp-leases-bridge: Make expiry check work for stub leases
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 17:51:41 +01:00
Michael Tremer
ae49f55359 unbound-dhcp-leases-bridge: Remove unused code
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 17:51:26 +01:00
Michael Tremer
dac4464e91 unbound-dhcp-leases-bridge: Don't parse any inactive leases
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 17:47:44 +01:00
Michael Tremer
b79c0fc4ff unbound-dhcp-leases-bridge: Drop parsing MAC addresses
We will represent the current state in DNS and we won't filter out
anything that we think might be no longer valid.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 17:46:45 +01:00
Michael Tremer
8628d3e8d0 unbound-dhcp-leases-bridge: Remove fixed leases cache
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 17:40:27 +01:00
Michael Tremer
2e4432a8f5 unbound-dhcp-leases-bridge: Include traceback if the worker callback fails
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 17:36:40 +01:00
Michael Tremer
c2761068cc unbound-dhcp-leases-bridge: Log if a lease is not being added
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 17:31:25 +01:00
Michael Tremer
9ff53d5786 unbound-dhcp-leases-bridge: Remove leases to keep the store up to date
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 17:28:58 +01:00
Michael Tremer
8733b313de unbound-dhcp-leases-bridge: Skip updates if not necessary
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 17:25:13 +01:00
Michael Tremer
92e8358d46 unbound-dhcp-leases-bridge: Find existing leases to remove all data
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 17:20:30 +01:00
Michael Tremer
0e1ae247e7 unbound-dhcp-leases-bridge: Store leases in a globally accessible set()
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 17:16:13 +01:00
Michael Tremer
edcea3e1c9 unbound-dhcp-leases-bridge: Make Leases hashable and equal by IP address
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 17:07:23 +01:00
Michael Tremer
038c9db2bd unbound-dhcp-leases-bridge: Use IPv4Address to store IP addresses
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 17:04:43 +01:00
Michael Tremer
084795163e unbound-dhcp-leases-bridge: Implement a worker thread to handle all events
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 17:01:50 +01:00
Michael Tremer
d9348a16f1 unbound-dhcp-leases-bridge: Store all messages in a queue
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 16:32:07 +01:00
Michael Tremer
7397809eb4 unbound-dhcp-leases-client: A new script to send events to the bridge
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 16:06:23 +01:00
Michael Tremer
43f001cb5b unbound-dhcp-leases-bridge: Decode any incoming messages
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 14:50:30 +01:00
Michael Tremer
bf352bbbcb unbound-dhcp-leases-bridge: Remove running indicator
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 14:31:53 +01:00
Michael Tremer
193638f078 unbound-dhcp-leases-bridge: Reload on SIGHUP
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 14:29:31 +01:00
Michael Tremer
716c69eee4 unbound-dhcp-leases-bridge: No longer listen to any changed files
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 14:27:10 +01:00
Michael Tremer
b2787f168b unbound-dhcp-leases-bridge: Initialize at startup
When the process starts, we will now load all static hosts and leases
and reload Unbound to have a defined state to start with.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 14:25:53 +01:00
Michael Tremer
130606f039 unbound-dhcp-leases-bridge: Open a socket to listen for events
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 14:19:05 +01:00
Michael Tremer
72f4fccbe4 unbound-dhcp-leases-bridge: Terminate on SIGINT
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2024-05-10 14:18:12 +01:00
Michael Tremer
4bf50efa84 unbound-dhcp-leases-bridge: Make comparison work if old file does not exist
This patch catches any errors if the file did not previously exist and
therefore skips the comparison.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
2024-04-28 17:23:41 +00:00
Michael Tremer
749bf85902 unbound-dhcp-leases-bridge: Only reload if leases have actually changed
This patches changes that leases will always be written in
alphanumerical order so that we can later compare the newly generated
file with the previous version. If it has not changed, we skip reload
Unbound.

Suggested-by: Nick Howitt <nick@howitts.co.uk>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
2024-04-28 17:23:41 +00:00
Michael Tremer
c3cabfa09c unbound-dhcp-leases-bridge: Implement atomic file replacement
This change no longer renames the file, but removes the old link and
creates a new link for the temporary file. That helps us to jump out of
the code at any point without worrying about cleaning up the temporary
file.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
2024-04-28 17:23:41 +00:00
Michael Tremer
f20ca78eff unbound-dhcp-leases-bridge: Reload unbound to import leases
This changes the old "diff" algorithm that we needed to have before
Unbound was able to reload its own configuration.

Now, it can do this even without dropping the cache. This should
hopefully perform much better and be more reliable than the old way.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Acked-by: Peter Müller <peter.mueller@ipfire.org>
2023-07-13 14:26:52 +00:00
Michael Tremer
ca4de26318 unbound-dhcp-leases-bridge: Fall back to the default domain
When the bridge cannot detect a domain name for any of the leases, it
uses localdomain which is not always the best choice. So instead, this
patches changes the behaviour that we read the default domain of the
firewall.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Reviewed-by: Bernhard Bitsch <bbitsch@ipfire.org>
2022-10-04 14:48:26 +00:00
Peter Müller
80745fb58f unbound.conf: Aggressive NSEC is enabled by default since Unbound 1.15.0
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
2022-06-13 15:50:10 +00:00
Michael Tremer
1918174dbb unbound-dhcp-leases-bridge: Don't open stderr on daemonization
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2022-04-04 20:07:15 +00:00
Michael Tremer
f961135513 unbound-dhcp-leases-bridge: Initialize logging after daemonization
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2022-04-04 20:07:15 +00:00
Michael Tremer
091cb62ada unbound-dhcp-leases-bridge: Read configuration only once
This saves some resources when we re-read the same configuration file
too often.

Suggested-by: Anthony Heading <ajrh@ajrh.net>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2022-04-04 20:07:15 +00:00
Michael Tremer
6d6e7949cf unbound-dhcp-leases-bridge: Fix inotify handling
This patch changes that the script will listen to changes to the
directory instead of the file which got complicated when files got
renamed.

It also processes all changes at the same time and tries finding out
what actions have to be performed in order to avoid unnecessary
iterations.

The script is also limited to process any changes only once every five
seconds to keep resource usage in check on busy systems.

Suggested-by: Anthony Heading <ajrh@ajrh.net>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2022-04-04 20:07:15 +00:00
Michael Tremer
29a3603610 unbound-dhcp-leases-bridge: Improve logging
This improves logging and enables logging to the console.

Suggested-by: Anthony Heading <ajrh@ajrh.net>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2022-04-04 20:07:15 +00:00
Michael Tremer
83e5f67256 unbound-dhcp-leases-bridge: Fix exception when running without debug
Fixes: https://bugzilla.ipfire.org/show_bug.cgi?id=12622
Fixes: #12622
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2021-05-17 15:33:13 +00:00
Michael Tremer
a8b1843bf7 unbound-dhcp-leases-bridge: Fix shebang
Reported-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2021-05-14 13:22:37 +00:00
Michael Tremer
96c86cf621 unbound-dhcp-leases-bridge: Migrate to Python 3
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2021-05-14 11:54:21 +00:00
Peter Müller
89b0449185 unbound.conf: do not set defaults again
These are meanwhile set by Unbound upstream as well, so there is no need
to do things twice here.

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2021-02-02 10:54:31 +00:00
Jonatan Schlag
211b6bc16e unbound: keep probing when servers are down
Till now when a server was in the "blocking regime" there was one probe
made every 15 min, to see if this server is up again. In situations
where all servers where down (e.g. because of a massive package loss)
it could take up to 15 min to have a working dns again.

This patch changes this behaviour in a way that a server marked down is
probed every 2 min.

Fixes: #12557

Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2021-01-06 15:31:05 +00:00
Michael Tremer
9700617aeb unbound: Disable using mixed case for DNS queries
This seems to cause that some resolvers do not respond
to queries any more until unbound falls back.

To ensure better DNS performance, we disabled this.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
2020-03-04 21:47:37 +00:00
Peter Müller
e737776db5 unbound.conf: Do not set defaults explicitly
In order to keep configuration files small and easy to review/audit,
omitting defaults makes more sense than configure them explicitly (have
changed my mind here).

Unbound comes with a good default confiuration, and we should only make
changes when they are necessary. In addition, this patch updates the
documentation's URL to the current one.

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Cc: Michael Tremer <michael.tremer@ipfire.org>
Reviewed-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
2020-03-04 21:46:48 +00:00
Arne Fitzenreiter
61cc563558 Merge remote-tracking branch 'ms/next-dns-ng' into next 2020-01-13 21:42:49 +00:00
Michael Tremer
7be4822f3d unbound: Make dhcp-leases.conf readable for everyone
unbound runs as nobody and cannot reload its configuration
when this file is only readable for root.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2020-01-13 21:43:27 +01:00
Michael Tremer
6137797cb3 unbound: Write hosts to unbound configuration file
This will allow us to read more hosts in a shorter time.

Fixes: #11743
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2020-01-13 21:10:18 +01:00