remove deprecated github.com/mdlayher/raw
This commit is contained in:
parent
4919630ccc
commit
e61a713da6
3
go.mod
3
go.mod
|
@ -24,9 +24,6 @@ require (
|
||||||
github.com/mdlayher/ethernet v0.0.0-20220221185849-529eae5b6118
|
github.com/mdlayher/ethernet v0.0.0-20220221185849-529eae5b6118
|
||||||
github.com/mdlayher/netlink v1.7.2
|
github.com/mdlayher/netlink v1.7.2
|
||||||
github.com/mdlayher/packet v1.1.2
|
github.com/mdlayher/packet v1.1.2
|
||||||
// TODO(a.garipov): This package is deprecated; find a new one or use our
|
|
||||||
// own code for that. Perhaps, use gopacket.
|
|
||||||
github.com/mdlayher/raw v0.1.0
|
|
||||||
github.com/miekg/dns v1.1.61
|
github.com/miekg/dns v1.1.61
|
||||||
github.com/quic-go/quic-go v0.47.0
|
github.com/quic-go/quic-go v0.47.0
|
||||||
github.com/stretchr/testify v1.9.0
|
github.com/stretchr/testify v1.9.0
|
||||||
|
|
|
@ -16,18 +16,16 @@ import (
|
||||||
"github.com/insomniacslk/dhcp/dhcpv4"
|
"github.com/insomniacslk/dhcp/dhcpv4"
|
||||||
"github.com/insomniacslk/dhcp/dhcpv4/server4"
|
"github.com/insomniacslk/dhcp/dhcpv4/server4"
|
||||||
"github.com/mdlayher/ethernet"
|
"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
|
// dhcpUnicastAddr is the combination of MAC and IP addresses for responding to
|
||||||
// the unconfigured host.
|
// the unconfigured host.
|
||||||
type dhcpUnicastAddr struct {
|
type dhcpUnicastAddr struct {
|
||||||
// raw.Addr is embedded here to make *dhcpUcastAddr a net.Addr without
|
// packet.Addr is embedded here to make *dhcpUcastAddr a net.Addr without
|
||||||
// actually implementing all methods. It also contains the client's
|
// actually implementing all methods. It also contains the client's
|
||||||
// hardware address.
|
// hardware address.
|
||||||
raw.Addr
|
packet.Addr
|
||||||
|
|
||||||
// yiaddr is an IP address just allocated by server for the host.
|
// yiaddr is an IP address just allocated by server for the host.
|
||||||
yiaddr net.IP
|
yiaddr net.IP
|
||||||
|
@ -53,7 +51,7 @@ type dhcpConn struct {
|
||||||
// newDHCPConn creates the special connection for DHCP server.
|
// newDHCPConn creates the special connection for DHCP server.
|
||||||
func (s *v4Server) newDHCPConn(iface *net.Interface) (c net.PacketConn, err error) {
|
func (s *v4Server) newDHCPConn(iface *net.Interface) (c net.PacketConn, err error) {
|
||||||
var ucast net.PacketConn
|
var ucast net.PacketConn
|
||||||
if ucast, err = raw.ListenPacket(iface, uint16(ethernet.EtherTypeIPv4), nil); err != nil {
|
if ucast, err = packet.Listen(iface, packet.Raw, int(ethernet.EtherTypeIPv4), nil); err != nil {
|
||||||
return nil, fmt.Errorf("creating raw udp connection: %w", err)
|
return nil, fmt.Errorf("creating raw udp connection: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +257,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
|
// Unicast DHCPOFFER and DHCPACK messages to the client's hardware
|
||||||
// address and yiaddr.
|
// address and yiaddr.
|
||||||
peer = &dhcpUnicastAddr{
|
peer = &dhcpUnicastAddr{
|
||||||
Addr: raw.Addr{HardwareAddr: req.ClientHWAddr},
|
Addr: packet.Addr{HardwareAddr: req.ClientHWAddr},
|
||||||
yiaddr: resp.YourIPAddr,
|
yiaddr: resp.YourIPAddr,
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
package dhcpd
|
package dhcpd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/mdlayher/packet"
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -12,9 +13,6 @@ import (
|
||||||
"github.com/insomniacslk/dhcp/dhcpv4"
|
"github.com/insomniacslk/dhcp/dhcpv4"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"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) {
|
func TestDHCPConn_WriteTo_common(t *testing.T) {
|
||||||
|
@ -57,7 +55,7 @@ func TestBuildEtherPkt(t *testing.T) {
|
||||||
srcIP: net.IP{1, 2, 3, 4},
|
srcIP: net.IP{1, 2, 3, 4},
|
||||||
}
|
}
|
||||||
peer := &dhcpUnicastAddr{
|
peer := &dhcpUnicastAddr{
|
||||||
Addr: raw.Addr{HardwareAddr: net.HardwareAddr{6, 5, 4, 3, 2, 1}},
|
Addr: packet.Addr{HardwareAddr: net.HardwareAddr{6, 5, 4, 3, 2, 1}},
|
||||||
yiaddr: net.IP{4, 3, 2, 1},
|
yiaddr: net.IP{4, 3, 2, 1},
|
||||||
}
|
}
|
||||||
payload := (&dhcpv4.DHCPv4{}).ToBytes()
|
payload := (&dhcpv4.DHCPv4{}).ToBytes()
|
||||||
|
@ -102,7 +100,7 @@ func TestBuildEtherPkt(t *testing.T) {
|
||||||
t.Run("serializing_error", func(t *testing.T) {
|
t.Run("serializing_error", func(t *testing.T) {
|
||||||
// Create a peer with invalid MAC.
|
// Create a peer with invalid MAC.
|
||||||
badPeer := &dhcpUnicastAddr{
|
badPeer := &dhcpUnicastAddr{
|
||||||
Addr: raw.Addr{HardwareAddr: net.HardwareAddr{5, 4, 3, 2, 1}},
|
Addr: packet.Addr{HardwareAddr: net.HardwareAddr{5, 4, 3, 2, 1}},
|
||||||
yiaddr: net.IP{4, 3, 2, 1},
|
yiaddr: net.IP{4, 3, 2, 1},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +163,7 @@ func TestV4Server_Send(t *testing.T) {
|
||||||
req: &dhcpv4.DHCPv4{ClientHWAddr: knownMAC},
|
req: &dhcpv4.DHCPv4{ClientHWAddr: knownMAC},
|
||||||
resp: &dhcpv4.DHCPv4{YourIPAddr: knownIP},
|
resp: &dhcpv4.DHCPv4{YourIPAddr: knownIP},
|
||||||
want: &dhcpUnicastAddr{
|
want: &dhcpUnicastAddr{
|
||||||
Addr: raw.Addr{HardwareAddr: knownMAC},
|
Addr: packet.Addr{HardwareAddr: knownMAC},
|
||||||
yiaddr: knownIP,
|
yiaddr: knownIP,
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
|
|
Loading…
Reference in New Issue