47 Commits

Author SHA1 Message Date
Timmy Welch
fc2e21cfd6 Fix nft run 2024-12-24 11:09:11 -08:00
Timmy Welch
bf58d46748 Merge remote-tracking branch 'github/master' 2024-01-20 11:49:11 -08:00
Timmy Welch
996061b126 Merge remote-tracking branch 'github/master' 2023-09-23 17:56:39 -07:00
Michael Stapelberg
b2db10d68b dhcp4d: allow handing out static leases outside of the pool 2023-03-12 09:06:02 +01:00
lordwelch
9c800af52e dhcp4d: Add vendor Identifier to mqtt
Add username and password for mqtt server
2022-05-01 18:56:51 -07:00
Michael Stapelberg
2014da4ca3 dhcp4d: display active devices based on LastACK
This has the advantage that it also works for static DHCP leases,
provided the device obtains a DHCP lease at all (and isn’t configured with a
static IP address, like the shelly motion sensors for example).
2022-03-12 17:38:16 +01:00
lordwelch
c5a72342f2 Add time and vendor information to leases 2022-03-04 13:49:50 -08:00
lordwelch
67711ee2c7 Merge branch 'master' of https://github.com/rtr7/router7 2022-03-04 13:30:38 -08:00
Matt Layher
6d41b077a9
internal/dhcp*: switch to github.com/mdlayher/packet (#70)
* internal/dhcp*: switch to github.com/mdlayher/packet
* internal/dhcp4d: update test constructor name to avoid packet conflict

Signed-off-by: Matt Layher <mdlayher@gmail.com>
2022-02-21 23:39:06 +01:00
lordwelch
ef50f7c2e4 Merge remote-tracking branch 'origin/master' 2021-03-15 22:44:39 -07:00
Robert Obryk
0507d93b3d
dhcp4d: ensure that SetHostname operates on the correct lease (#64)
Previously SetHostname could operate on an expired lease, or even on a
lease for a different hwaddr, if the lease for the correct hwaddr
expired and the same lease ID was given away to someone else.

That's though mostly a theoretical concern, given the actual usage of
SetHostname and the time scales involved.
2020-11-23 09:32:42 +01:00
Michael Stapelberg
7f135438b8 dhcp4d: mention apple-suggested lease time of 1 hour 2020-11-01 19:24:24 +01:00
lordwelch
04ee69ce02 go mod tidy
Update deps
2020-08-10 18:26:07 -07:00
lordwelch
7923e58428 dhcp4d: add an options argument for the dhcp server 2020-08-10 18:12:35 -07:00
Michael Stapelberg
4a5f55a5de defense in depth: verify hex.DecodeString length
related to #49
2020-05-27 09:50:04 +02:00
Matt Layher
7aeb51e9ec
internal/dhcp4d: handle DHCPDECLINE and fix bug regarding MacBook declining leases (#48)
Fixes #40

Signed-off-by: Matt Layher <mdlayher@gmail.com>
2020-05-23 20:53:13 +02:00
Michael Stapelberg
53c495091e quirk: enforce minimum lease time of 1 hour for Nintendo devices
The Nintendo Switch has been observed to hold on to IP addresses even after
their expiration. My guess is that this is an oversight: likely the device
enters power saving mode with a configured IP address and just sleeps through
the expiration time.

As the device seems to wake up once every hour, we enforce a minimum lease time
of 1 hour, but only for affected devices. The rest of the network gets short
lease times.

https://twitter.com/zekjur/status/1263949112036282374
2020-05-23 09:07:17 +02:00
Matt Layher
e1f2b975a1
internal/dhcp4d: fix staticcheck issues
Signed-off-by: Matt Layher <mdlayher@gmail.com>
2020-05-09 16:51:32 -04:00
Michael Stapelberg
2b6ab5b2bd dhcp4d: make hostname override settable from status page 2020-04-12 10:33:11 +02:00
Michael Stapelberg
a543cb9a34 dhcp4d: add header describing whether lease is active
Should be interpreted by the DHCP server so that other programs don’t need to
hard-code the lease time.
2020-01-31 19:11:08 +01:00
Michael Stapelberg
41985d6378 dhcp4d: reduce lease period to 20 minutes
This forces devices to renew the lease more often, which is nice when you want
to tie home automation behavior to DHCP lease validity.
2020-01-31 18:23:50 +01:00
Michael Stapelberg
fa82132962 dhcp4d: add HostnameOverride field
This can be used to permanently override a hostname, regardless of whether the
lease is static or not. We use a separate field because we want devices to be
able to change their hostname themselves, until we override it.
2019-08-30 09:06:21 +02:00
Michael Stapelberg
975f05d7ac fix dhcp4d_test.go 2019-07-20 11:30:52 +02:00
Michael Stapelberg
c602f1d6b6 dhcp4d: introduce -interface flag 2019-07-20 10:50:30 +02:00
Michael Stapelberg
c7be96ac2e dhcp4d: fix IP address comparison
AFAICT, this wasn’t actually a bug: canLease performs the correct check.
2019-01-01 10:45:03 +01:00
Michael Stapelberg
0d2e89cebf dhcp4d_test: fix message to match comparison 2019-01-01 10:44:03 +01:00
Michael Stapelberg
b923f145a5 dhcp4d: don’t incorrectly _offer_ reused addresses
Turns out a5d9e03dd3212f7f0c11dd856b308a16a58a3cdf was not entirely sufficient:
even though reused addresses would not be handed out anymore, they would still
be offered, which results in the client not being able to obtain an address.
2019-01-01 10:41:29 +01:00
Michael Stapelberg
a5d9e03dd3 dhcp4d: don’t incorrectly hand out reused addresses
fixes #18
2018-12-15 12:44:09 +01:00
Michael Stapelberg
e01a38ff78 commit debug statements 2018-10-22 18:58:40 +02:00
Michael Stapelberg
c037bf9c5f dhcp4d: fix panic when receiving unsupported requests 2018-10-22 18:39:25 +02:00
Michael Stapelberg
f606e70250 dhcp4d: respect broadcast bit
Mac’s Internet Recovery DHCP client requires broadcast responses and will ignore
unicast responses outright.
2018-10-07 17:36:00 +02:00
Michael Stapelberg
49a59779f5 dhcp4d: don’t offer expired leases 2018-07-15 18:33:11 +02:00
Michael Stapelberg
b347ed74c5 update import paths 2018-07-09 08:54:04 +02:00
Michael Stapelberg
ff7aa8f2cb add copyright notices 2018-06-28 20:08:23 +02:00
Michael Stapelberg
ae15230da3 dhcp4d: log in leases callback 2018-06-24 11:56:39 +02:00
Michael Stapelberg
3ba84074c7 dhcp4d: send replies as unicast using raw sockets
Preferring unicast over multicast (which hogs a lot of airtime on WiFi networks)
is a best practice.

Some device/access point vendor combinations even seem to entirely eat (some?)
broadcast traffic (sometimes), e.g. my Apple iPhone SE/Ubiquiti UAP-AC-HD, so
that using unicast is required for reliable WiFi.
2018-06-23 17:46:53 +02:00
Michael Stapelberg
301d4c0d00 dhcp4d: always set broadcast flag for DHCPOFFERs
We always broadcast them, so we should signal that.
2018-06-22 18:35:23 +02:00
Michael Stapelberg
5e11eae951 fix dhcp4d_test for larger pool 2018-06-19 09:46:29 +02:00
Michael Stapelberg
957e4de03a no-op: only one branch results in DHCPNAK 2018-06-18 19:29:58 +02:00
Michael Stapelberg
34d494b85c dhcp4d: increase lease range to cover existing leases 2018-06-18 19:29:42 +02:00
Michael Stapelberg
32dd03c7f2 dhcp4d: copy reqIP, its backing storage gets reused 2018-06-15 09:56:07 +02:00
Michael Stapelberg
4c69109db5 dhcp4d: implement permanent leases (no expiration) 2018-06-12 08:21:07 +02:00
Michael Stapelberg
d21822f531 dhcp4d: implement loading leases files from persistent storage 2018-06-09 15:18:01 +02:00
Michael Stapelberg
f9c3c23b16 dhcp4d: implement lease expiration 2018-06-09 15:04:54 +02:00
Michael Stapelberg
3561ec3708 dhcp4d: offer requested address if available 2018-06-07 08:39:47 +02:00
Michael Stapelberg
2ef8bf6ea0 dnsd/dhcp4d: listen on configured address (not hard-coded) 2018-06-04 08:22:45 +02:00
Michael Stapelberg
6b9ce5728a Initial commit 2018-05-27 17:30:42 +02:00