94 Commits

Author SHA1 Message Date
lordwelch
67711ee2c7 Merge branch 'master' of https://github.com/rtr7/router7 2022-03-04 13:30:38 -08:00
Michael Stapelberg
3ad9d03460 gofmt for go:build 2021-09-19 11:46:57 +02:00
Michael Stapelberg
a5a012dd96 dhcp4: increase number of unhealthy cycles 2021-09-19 11:45:04 +02:00
Michael Stapelberg
cbadfe5128 dhcp4: ensure MQTT topic names are printable (for mosquitto_sub) 2021-06-03 21:06:03 +02:00
lordwelch
ef50f7c2e4 Merge remote-tracking branch 'origin/master' 2021-03-15 22:44:39 -07:00
Michael Stapelberg
3834acfa2b dhcp4d: ensure MQTT topic names are valid UTF-8
https://twitter.com/zekjur/status/1347295676909158400
2021-01-07 22:52:58 +01:00
Michael Stapelberg
5f25043b94 dhcp4d: only publish to MQTT when channel is ready to prevent deadlocks 2020-12-31 16:42:12 +01:00
Michael Stapelberg
c3c531931c retry MQTT connections, even if initial connection attempt fails 2020-12-31 16:42:01 +01:00
Michael Stapelberg
04f2be01d9 dhcp4d: optionally publish DHCP leases to MQTT
Enable using:

  mkdir -p /perm/dhcp4d
  echo 'tcp://10.0.0.54:1883' > /perm/dhcp4d/mqtt-broker.txt
2020-12-19 13:34:46 +01: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
99c4046ebf diagd: import net/http/pprof 2020-09-14 22:10:07 +02:00
Michael Stapelberg
efbe826a4e diagd: -interface flag for easier testing 2020-09-14 22:10:07 +02:00
Michael Stapelberg
f8d79d0ecc dhcp4: close healthiness checking connection 2020-09-14 12:54:14 +02:00
Michael Stapelberg
fddfe80222 dhcp4: start from scratch after 5 minutes of continued unhealthiness
fixes #58
2020-09-14 09:06:05 +02:00
Michael Stapelberg
93fe6457b3 dnsd: serve DNS on tcp/53 as well (DNS must work over TCP)
fixes #59
2020-09-12 19:21:58 +02:00
lordwelch
55ac682d36 Fix flag.parse 2020-08-17 23:13:26 -07:00
lordwelch
5f01503df6 Use the correct NTP dhcp4 option 2020-08-16 18:19:34 -07:00
lordwelch
ce29a6f436 fix ip length 2020-08-10 22:05:40 -07:00
lordwelch
7923e58428 dhcp4d: add an options argument for the dhcp server 2020-08-10 18:12:35 -07:00
lordwelch
169bc5c3e7 DNS changes
go mod tidy
2020-08-10 18:12:34 -07:00
lordwelch
3c451f06ca Add the ability to run router7 on a normal Linux distribution 2020-08-10 18:12:34 -07:00
Michael Stapelberg
f86e20be53 dhcp6: port dhcp4 backoff logic 2020-07-02 22:07:26 +02:00
Michael Stapelberg
f1e4ee0662 dyndns: don’t crashloop when config does not exist
related to #46
2020-05-28 09:46:37 +02:00
Matt Layher
ead58ad72c
cmd/dyndns: prototype for dynamic DNS daemon (#50)
Updates #46.

Signed-off-by: Matt Layher <mdlayher@gmail.com>
2020-05-23 23:06:21 +02:00
Matt Layher
988aa405be
cmd/dhcp4d: make use of unused assignment
Signed-off-by: Matt Layher <mdlayher@gmail.com>
2020-05-09 16:58:57 -04:00
Michael Stapelberg
2b6ab5b2bd dhcp4d: make hostname override settable from status page 2020-04-12 10:33:11 +02:00
Michael Stapelberg
e67fb4dd71 diagd: make output look good in a terminal, too
curl diagd.router7/
2020-03-11 22:12:00 +01:00
Michael Stapelberg
e34148d4e7 dhcp4d: add some leeway for lease activity 2020-02-06 18:48:19 +01: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
a2ea8c2f95 cmd/dhcp4d: refactor for testing, add /lease/ test 2020-01-31 19:00:51 +01:00
Michael Stapelberg
4558cb61b4 dhcp4d: serve lease json data at /lease/<hostname> 2020-01-31 18:30:18 +01:00
Michael Stapelberg
3707ba290c dhcp4d: move http.HandleFunc into logic 2020-01-31 18:25:02 +01:00
Michael Stapelberg
e76886dab4 dhcp4d: protect leases with a mutex
The HTTP handler runs in a separate goroutine.
2020-01-31 18:23:19 +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
323cc42b8e dhcp4d: polish status page, actually update it upon changes 2019-07-20 11:07:11 +02:00
Michael Stapelberg
c602f1d6b6 dhcp4d: introduce -interface flag 2019-07-20 10:50:30 +02:00
Michael Stapelberg
c211763b5d dhcp4d: indent leases.json for easier human editing 2019-07-20 10:49:53 +02:00
Michael Stapelberg
373c83196d dhcp4: make interface and state directory configurable
This is useful for manual testing on separate interfaces.
2019-06-06 07:52:08 +02:00
Michael Stapelberg
3dad1e9a23 dhcp4: use the configured (not the current) MAC address
This fixes a race where dhcp4 started before netconfigd had a chance to change
the hardware address on the uplink0 interface.

fiber7’s port security feature may result in an about hour-long internet outage
without this commit.
2019-02-19 09:39:16 +01:00
Michael Stapelberg
abeddabbb7 dhcp4d: restrict lease details page to internal IPs 2019-02-19 07:50:39 +01:00
Michael Stapelberg
6320b6c3a7 dhcp4d: display MAC vendor of each lease’s HardwareAddr 2019-01-06 18:02:01 +01:00
Michael Stapelberg
8df6329209 use renameio to write files atomically 2019-01-06 15:25:33 +01:00
Michael Stapelberg
f67d4ec93f radvd: load extra prefixes from /perm/radvd/prefixes.json 2019-01-06 15:12:22 +01:00
Michael Stapelberg
bd8fc63b0e dns: implement per-DHCP-lease dyndns
The HTTP API is easy to use from the command line or from Go:

% curl --data "host=sub&ip=192.168.33.44" -4 http://router7:8053/dyndns
ok
% host sub.$(hostname)
sub.midna has address 192.168.33.44

This can be used in combination with https://github.com/gokrazy/gdns
2019-01-06 14:41:26 +01:00
Michael Stapelberg
8c55c5ba44 dhcp4: switch to github.com/rtr7/dhcp4
All existing DHCPv4 packages I looked at were unappealing for one reason or
another, so we’re now using a little helper to glue github.com/google/gopacket
and github.com/mdlayher/raw together, which suffices for our use-case and gives
us more control.
2018-11-21 08:18:58 +01:00
Michael Stapelberg
fac1bf231e netconfigd: notify dhcp4d to update its listeners 2018-10-29 18:14:01 +01:00
Michael Stapelberg
7d278289f0 captured: directly call NextPacket() to prevent hanging reads
Using Packets() spawns off a separate goroutine which calls NextPacket in a loop
until io.EOF is returned. This goroutine will stick around after Close()
returned, resulting in only the first wireshark connection working.
2018-10-23 09:56:07 +02:00
Michael Stapelberg
d9f5d95812 dhcp4d: export number of non-expired DHCP leases 2018-10-23 08:49:29 +02:00
Michael Stapelberg
ea4ffa7bec OpenEthernet → NewEthernetHandle, remove kludge 2018-09-07 00:50:41 +02:00
Michael Stapelberg
b03596f1c5 nftables: use stateful object counters
This way, we can atomically get and reset them.

fixes https://github.com/rtr7/router7/issues/3
2018-08-08 23:15:21 +02:00