diff --git a/CHANGELOG.md b/CHANGELOG.md index 00b2820d..edee3432 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,6 +78,7 @@ See also the [v0.107.9 GitHub milestone][ms-v0.107.9]. ### Fixed +- DHCP not working on most OSes ([#4836]). - Several UI issues ([#4775], [#4776], [#4782]). ### Removed @@ -89,6 +90,7 @@ See also the [v0.107.9 GitHub milestone][ms-v0.107.9]. [#4775]: https://github.com/AdguardTeam/AdGuardHome/issues/4775 [#4776]: https://github.com/AdguardTeam/AdGuardHome/issues/4776 [#4782]: https://github.com/AdguardTeam/AdGuardHome/issues/4782 +[#4836]: https://github.com/AdguardTeam/AdGuardHome/issues/4836 [go-1.18.5]: https://groups.google.com/g/golang-announce/c/YqYYG87xB10 [ms-v0.107.9]: https://github.com/AdguardTeam/AdGuardHome/milestone/45?closed=1 diff --git a/go.mod b/go.mod index 43f2847c..53e5eb1b 100644 --- a/go.mod +++ b/go.mod @@ -21,10 +21,9 @@ require ( github.com/lucas-clemente/quic-go v0.28.1 github.com/mdlayher/ethernet v0.0.0-20220221185849-529eae5b6118 github.com/mdlayher/netlink v1.6.0 - github.com/mdlayher/packet v1.0.0 // TODO(a.garipov): This package is deprecated; find a new one or use - // our own code for that. - github.com/mdlayher/raw v0.1.0 // indirect + // our own code for that. Perhaps, use gopacket. + github.com/mdlayher/raw v0.1.0 github.com/miekg/dns v1.1.50 github.com/stretchr/testify v1.7.1 github.com/ti-mo/netfilter v0.4.0 @@ -52,6 +51,7 @@ require ( github.com/marten-seemann/qtls-go1-17 v0.1.2 // indirect github.com/marten-seemann/qtls-go1-18 v0.1.2 // indirect github.com/marten-seemann/qtls-go1-19 v0.1.0-beta.1 // indirect + github.com/mdlayher/packet v1.0.0 // indirect github.com/mdlayher/socket v0.2.3 // indirect github.com/nxadm/tail v1.4.8 // indirect github.com/onsi/ginkgo v1.16.5 // indirect diff --git a/internal/dhcpd/conn_unix.go b/internal/dhcpd/conn_unix.go index 837211af..1ed2105a 100644 --- a/internal/dhcpd/conn_unix.go +++ b/internal/dhcpd/conn_unix.go @@ -16,16 +16,18 @@ import ( "github.com/insomniacslk/dhcp/dhcpv4" "github.com/insomniacslk/dhcp/dhcpv4/server4" "github.com/mdlayher/ethernet" - "github.com/mdlayher/packet" + + //lint:ignore SA1019 See the TODO in go.mod. + "github.com/mdlayher/raw" ) // dhcpUnicastAddr is the combination of MAC and IP addresses for responding to // the unconfigured host. type dhcpUnicastAddr struct { - // packet.Addr is embedded here to make *dhcpUcastAddr a net.Addr without + // raw.Addr is embedded here to make *dhcpUcastAddr a net.Addr without // actually implementing all methods. It also contains the client's // hardware address. - packet.Addr + raw.Addr // yiaddr is an IP address just allocated by server for the host. yiaddr net.IP @@ -51,13 +53,7 @@ type dhcpConn struct { // newDHCPConn creates the special connection for DHCP server. func (s *v4Server) newDHCPConn(iface *net.Interface) (c net.PacketConn, err error) { var ucast net.PacketConn - ucast, err = packet.Listen( - iface, - packet.Raw, - int(ethernet.EtherTypeIPv4), - nil, - ) - if err != nil { + if ucast, err = raw.ListenPacket(iface, uint16(ethernet.EtherTypeIPv4), nil); err != nil { return nil, fmt.Errorf("creating raw udp connection: %w", err) } diff --git a/internal/dhcpd/conn_unix_test.go b/internal/dhcpd/conn_unix_test.go index 66899af6..84020acd 100644 --- a/internal/dhcpd/conn_unix_test.go +++ b/internal/dhcpd/conn_unix_test.go @@ -11,9 +11,11 @@ import ( "github.com/google/gopacket" "github.com/google/gopacket/layers" "github.com/insomniacslk/dhcp/dhcpv4" - "github.com/mdlayher/packet" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + //lint:ignore SA1019 See the TODO in go.mod. + "github.com/mdlayher/raw" ) func TestDHCPConn_WriteTo_common(t *testing.T) { @@ -56,7 +58,7 @@ func TestBuildEtherPkt(t *testing.T) { srcIP: net.IP{1, 2, 3, 4}, } peer := &dhcpUnicastAddr{ - Addr: packet.Addr{HardwareAddr: net.HardwareAddr{6, 5, 4, 3, 2, 1}}, + Addr: raw.Addr{HardwareAddr: net.HardwareAddr{6, 5, 4, 3, 2, 1}}, yiaddr: net.IP{4, 3, 2, 1}, } payload := (&dhcpv4.DHCPv4{}).ToBytes() @@ -102,7 +104,7 @@ func TestBuildEtherPkt(t *testing.T) { t.Run("serializing_error", func(t *testing.T) { // Create a peer with invalid MAC. badPeer := &dhcpUnicastAddr{ - Addr: packet.Addr{HardwareAddr: net.HardwareAddr{5, 4, 3, 2, 1}}, + Addr: raw.Addr{HardwareAddr: net.HardwareAddr{5, 4, 3, 2, 1}}, yiaddr: net.IP{4, 3, 2, 1}, } diff --git a/internal/dhcpd/v4.go b/internal/dhcpd/v4.go index 5639837f..17881d2c 100644 --- a/internal/dhcpd/v4.go +++ b/internal/dhcpd/v4.go @@ -20,7 +20,9 @@ import ( "github.com/go-ping/ping" "github.com/insomniacslk/dhcp/dhcpv4" "github.com/insomniacslk/dhcp/dhcpv4/server4" - "github.com/mdlayher/packet" + + //lint:ignore SA1019 See the TODO in go.mod. + "github.com/mdlayher/raw" ) // v4Server is a DHCPv4 server. @@ -992,7 +994,7 @@ func (s *v4Server) send(peer net.Addr, conn net.PacketConn, req, resp *dhcpv4.DH // Unicast DHCPOFFER and DHCPACK messages to the client's // hardware address and yiaddr. peer = &dhcpUnicastAddr{ - Addr: packet.Addr{HardwareAddr: req.ClientHWAddr}, + Addr: raw.Addr{HardwareAddr: req.ClientHWAddr}, yiaddr: resp.YourIPAddr, } default: diff --git a/internal/dhcpd/v4_test.go b/internal/dhcpd/v4_test.go index be9259d8..3c241a4a 100644 --- a/internal/dhcpd/v4_test.go +++ b/internal/dhcpd/v4_test.go @@ -12,9 +12,11 @@ import ( "github.com/AdguardTeam/golibs/stringutil" "github.com/AdguardTeam/golibs/testutil" "github.com/insomniacslk/dhcp/dhcpv4" - "github.com/mdlayher/packet" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + //lint:ignore SA1019 See the TODO in go.mod. + "github.com/mdlayher/raw" ) var ( @@ -554,7 +556,7 @@ func TestV4Server_Send(t *testing.T) { req: &dhcpv4.DHCPv4{ClientHWAddr: knownMAC}, resp: &dhcpv4.DHCPv4{YourIPAddr: knownIP}, want: &dhcpUnicastAddr{ - Addr: packet.Addr{HardwareAddr: knownMAC}, + Addr: raw.Addr{HardwareAddr: knownMAC}, yiaddr: knownIP, }, }, {