mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-05-03 06:22:56 +03:00
cherry-pick: 4836-revert-dhcp-upd
Updates #4836. Squashed commit of the following: commit 6fe1721d44be1c23e524d477e28b5f7cc5dd2dc6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Aug 15 17:48:41 2022 +0300 dhcpd: reverd mod upd
This commit is contained in:
parent
3c52a021b9
commit
6ea4788f56
6 changed files with 24 additions and 20 deletions
internal/dhcpd
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue