f-86: agent: dummy, DNAT et open par VPC, DHCP 6 et 42, watchdog #86

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2026-10-25 20:45:24 +01:00
commit 2e24a5da0a
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
16 changed files with 565 additions and 13 deletions

View file

@ -7,13 +7,6 @@ import (
const LeaseTime = 12 * time.Hour
func DNSServers() []net.IP {
return []net.IP{
net.IPv4(1, 1, 1, 1),
net.IPv4(8, 8, 8, 8),
}
}
type SubnetConfig struct {
Network *net.IPNet
InterfaceIP net.IP

View file

@ -86,7 +86,8 @@ func BuildReply(c SubnetConfig, h Host, req *dhcpv4.DHCPv4) (*dhcpv4.DHCPv4, err
dhcpv4.WithNetmask(c.Network.Mask),
dhcpv4.WithLeaseTime(uint32(LeaseTime.Seconds())),
dhcpv4.WithOption(dhcpv4.OptServerIdentifier(c.InterfaceIP)),
dhcpv4.WithOption(dhcpv4.OptDNS(DNSServers()...)),
dhcpv4.WithOption(dhcpv4.OptDNS(c.InterfaceIP)),
dhcpv4.WithOption(dhcpv4.OptNTPServers(c.InterfaceIP)),
dhcpv4.WithOption(dhcpv4.OptClasslessStaticRoute(routes...)),
dhcpv4.WithOption(dhcpv4.OptGeneric(dhcpv4.OptionInterfaceMTU, dhcpv4.Uint16(c.InterfaceMTU()).ToBytes())),
}

View file

@ -244,8 +244,11 @@ func TestBuildReply_CarriesAddressMaskLeaseAndServerIdentifier(t *testing.T) {
if got := reply.ServerIdentifier(); !got.Equal(c.InterfaceIP) {
t.Errorf("server identifier = %s, want %s", got, c.InterfaceIP)
}
if got := reply.DNS(); len(got) != 2 || !got[0].Equal(net.IPv4(1, 1, 1, 1)) || !got[1].Equal(net.IPv4(8, 8, 8, 8)) {
t.Errorf("dns = %v, want 1.1.1.1 and 8.8.8.8", got)
if got := reply.DNS(); len(got) != 1 || !got[0].Equal(net.ParseIP("10.0.5.1")) {
t.Errorf("dns = %v, want only the interface ip 10.0.5.1, relayed by two-hostsvc", got)
}
if got := reply.NTPServers(); len(got) != 1 || !got[0].Equal(net.ParseIP("10.0.5.1")) {
t.Errorf("ntp = %v, want only the interface ip 10.0.5.1, relayed by two-hostsvc", got)
}
}