mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-12-25 08:08:18 +03:00
da86620288
Merge in DNS/adguard-home from 3443-dhcp-broadcast-vol.2 to master Closes #3443. Squashed commit of the following: commit a85af89cb43f2489126fe3c12366fc034e89f59d Merge:72eb3a88
a4e07827
Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Sep 30 18:08:19 2021 +0300 Merge branch 'master' into 3443-dhcp-broadcast-vol.2 commit 72eb3a8853540b06ee1096decf50e836b539fe45 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Sep 30 18:03:19 2021 +0300 dhcpd: imp code readability commit 2d1fbc40d04a4125855d6be9f02e09d15430150d Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Sep 30 14:16:59 2021 +0300 dhcpd: imp tests commit 889fad3084ad2b81edfc12100e2ce29d323227ba Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Sep 29 20:09:25 2021 +0300 dhcpd: imp code, docs commit 1fd6b2346ff66e033bceaa169aed751be5822ca8 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Sep 23 16:08:18 2021 +0300 dhcpd: unicast to mac address
31 lines
1.1 KiB
Go
31 lines
1.1 KiB
Go
//go:build aix || darwin || dragonfly || linux || netbsd || solaris
|
|
// +build aix darwin dragonfly linux netbsd solaris
|
|
|
|
package dhcpd
|
|
|
|
import (
|
|
"net"
|
|
)
|
|
|
|
// broadcast sends resp to the broadcast address specific for network interface.
|
|
func (c *dhcpConn) broadcast(respData []byte, peer *net.UDPAddr) (n int, err error) {
|
|
// This write to 0xffffffff reverts some behavior changes made in
|
|
// https://github.com/AdguardTeam/AdGuardHome/issues/3289. The DHCP
|
|
// server should broadcast the message to 0xffffffff but it's
|
|
// inconsistent with the actual mental model of DHCP implementation
|
|
// which requires the network interface selection to bind to.
|
|
//
|
|
// See https://github.com/AdguardTeam/AdGuardHome/issues/3480 and
|
|
// https://github.com/AdguardTeam/AdGuardHome/issues/3366.
|
|
//
|
|
// See also https://github.com/AdguardTeam/AdGuardHome/issues/3539.
|
|
if n, err = c.udpConn.WriteTo(respData, peer); err != nil {
|
|
return n, err
|
|
}
|
|
|
|
// Broadcast the message one more time using the interface-specific
|
|
// broadcast address.
|
|
peer.IP = c.bcastIP
|
|
|
|
return c.udpConn.WriteTo(respData, peer)
|
|
}
|