docstring_tokens
stringlengths 18
16.9k
| code_tokens
stringlengths 75
1.81M
| html_url
stringlengths 74
116
| file_name
stringlengths 3
311
|
---|---|---|---|
keep keep keep add keep keep keep keep keep | <mask> "encoding/json"
<mask> "fmt"
<mask> "io"
<mask> "net"
<mask> "syscall"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghos"
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/golibs/log"
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove "net"
</s> add "net/netip" </s> remove "net"
</s> add </s> add "net/netip" </s> add "net/netip" </s> remove "github.com/AdguardTeam/golibs/netutil"
</s> add </s> add "net/netip" | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net.go |
keep keep keep keep replace keep keep keep keep keep | <mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghos"
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> "github.com/AdguardTeam/golibs/netutil"
<mask> )
<mask>
<mask> // Variables and functions to substitute in tests.
<mask> var (
<mask> // aghosRunCommand is the function to run shell commands.
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> add "net/netip" </s> remove DefaultRangeStart = net.IP{192, 168, 10, 100}
DefaultRangeEnd = net.IP{192, 168, 10, 200}
DefaultGatewayIP = net.IP{192, 168, 10, 1}
DefaultSelfIP = net.IP{192, 168, 10, 2}
DefaultSubnetMask = net.IP{255, 255, 255, 0}
</s> add DefaultRangeStart = netip.MustParseAddr("192.168.10.100")
DefaultRangeEnd = netip.MustParseAddr("192.168.10.200")
DefaultGatewayIP = netip.MustParseAddr("192.168.10.1")
DefaultSelfIP = netip.MustParseAddr("192.168.10.2")
DefaultSubnetMask = netip.MustParseAddr("255.255.255.0") </s> remove "net"
</s> add "net/netip" </s> remove "github.com/AdguardTeam/golibs/netutil"
</s> add </s> remove dnsIPAddrs: []net.IP{DefaultSelfIP},
</s> add dnsIPAddrs: []netip.Addr{DefaultSelfIP}, </s> add "net/netip" | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net.go |
keep keep keep add keep keep keep keep keep | <mask> // ErrNoStaticIPInfo is returned by IfaceHasStaticIP when no information about
<mask> // the IP being static is available.
<mask> const ErrNoStaticIPInfo errors.Error = "no information about static ip"
<mask>
<mask> // IfaceHasStaticIP checks if interface is configured to have static IP address.
<mask> // If it can't give a definitive answer, it returns false and an error for which
<mask> // errors.Is(err, ErrNoStaticIPInfo) is true.
<mask> func IfaceHasStaticIP(ifaceName string) (has bool, err error) {
<mask> return ifaceHasStaticIP(ifaceName)
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove func handleStaticIP(ip net.IP, set bool) staticIPJSON {
</s> add func handleStaticIP(ip netip.Addr, set bool) staticIPJSON { </s> remove // ensureV4 returns a 4-byte version of ip. An error is returned if the passed
// ip is not an IPv4.
func ensureV4(ip net.IP) (ip4 net.IP, err error) {
if ip == nil {
return nil, fmt.Errorf("%v is not an IP address", ip)
}
ip4 = ip.To4()
if ip4 == nil {
return nil, fmt.Errorf("%v is not an IPv4 address", ip)
</s> add // ensureV4 returns an unmapped version of ip. An error is returned if the
// passed ip is not an IPv4.
func ensureV4(ip netip.Addr, kind string) (ip4 netip.Addr, err error) {
ip4 = ip.Unmap()
if !ip4.IsValid() || !ip4.Is4() {
return netip.Addr{}, fmt.Errorf("%v is not an IPv4 %s", ip, kind) </s> remove func dhcpcdConfIface(ifaceName string, ipNet *net.IPNet, gwIP net.IP) (conf string) {
</s> add func dhcpcdConfIface(ifaceName string, subnet netip.Prefix, gateway netip.Addr) (conf string) { </s> remove return nil, fmt.Errorf("interface %s has no ipv4 addresses", iface.Name)
</s> add return netip.Prefix{}, fmt.Errorf("interface %s has no ipv4 addresses", iface.Name) </s> remove func appendDNSAddrsWithIfaces(dst []string, src []net.IP) (res []string, err error) {
</s> add func appendDNSAddrsWithIfaces(dst []string, src []netip.Addr) (res []string, err error) { </s> remove var subnet *net.IPNet
</s> add var subnet netip.Prefix | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net.go |
keep keep keep keep replace keep keep keep keep replace keep keep keep keep | <mask> // GatewayIP returns IP address of interface's gateway.
<mask> //
<mask> // TODO(e.burkov): Investigate if the gateway address may be fetched in another
<mask> // way since not every machine has the software installed.
<mask> func GatewayIP(ifaceName string) (ip net.IP) {
<mask> code, out, err := aghosRunCommand("ip", "route", "show", "dev", ifaceName)
<mask> if err != nil {
<mask> log.Debug("%s", err)
<mask>
<mask> return nil
<mask> } else if code != 0 {
<mask> log.Debug("fetching gateway ip: unexpected exit code: %d", code)
<mask>
<mask> return nil
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove return nil
</s> add return netip.Addr{} </s> remove func InterfaceByIP(ip net.IP) (ifaceName string) {
</s> add func InterfaceByIP(ip netip.Addr) (ifaceName string) { </s> remove func GetSubnet(ifaceName string) *net.IPNet {
</s> add func GetSubnet(ifaceName string) (p netip.Prefix) { </s> remove // Discard interfaces with no addresses.
if len(netIface.Addresses) != 0 {
netIfaces = append(netIfaces, netIface)
</s> add ones, _ := n.Mask.Size()
p := netip.PrefixFrom(ip, ones)
niface.Addresses = append(niface.Addresses, ip)
niface.Subnets = append(niface.Subnets, p)
}
return niface, nil
}
// GetValidNetInterfacesForWeb returns interfaces that are eligible for DNS and
// WEB only we do not return link-local addresses here.
//
// TODO(e.burkov): Can't properly test the function since it's nontrivial to
// substitute net.Interface.Addrs and the net.InterfaceAddrs can't be used.
func GetValidNetInterfacesForWeb() (nifaces []*NetInterface, err error) {
ifaces, err := net.Interfaces()
if err != nil {
return nil, fmt.Errorf("getting interfaces: %w", err)
} else if len(ifaces) == 0 {
return nil, errors.Error("no legible interfaces")
}
for i := range ifaces {
var niface *NetInterface
niface, err = NetInterfaceFrom(&ifaces[i])
if err != nil {
return nil, err
} else if len(niface.Addresses) != 0 {
// Discard interfaces with no addresses.
nifaces = append(nifaces, niface) </s> remove // GetValidNetInterfacesForWeb returns interfaces that are eligible for DNS and
// WEB only we do not return link-local addresses here.
//
// TODO(e.burkov): Can't properly test the function since it's nontrivial to
// substitute net.Interface.Addrs and the net.InterfaceAddrs can't be used.
func GetValidNetInterfacesForWeb() (netIfaces []*NetInterface, err error) {
ifaces, err := net.Interfaces()
</s> add func NetInterfaceFrom(iface *net.Interface) (niface *NetInterface, err error) {
niface = &NetInterface{
Name: iface.Name,
HardwareAddr: iface.HardwareAddr,
Flags: iface.Flags,
MTU: iface.MTU,
}
addrs, err := iface.Addrs() | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net.go |
keep keep keep keep replace keep keep keep keep keep | <mask> return nil
<mask> } else if code != 0 {
<mask> log.Debug("fetching gateway ip: unexpected exit code: %d", code)
<mask>
<mask> return nil
<mask> }
<mask>
<mask> fields := bytes.Fields(out)
<mask> // The meaningful "ip route" command output should contain the word
<mask> // "default" at first field and default gateway IP address at third field.
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove return nil
</s> add return netip.Addr{} </s> remove return nil
</s> add return netip.Addr{} </s> remove broadcastIP net.IP
</s> add broadcastIP netip.Addr </s> remove GatewayIP net.IP `yaml:"gateway_ip" json:"gateway_ip"`
SubnetMask net.IP `yaml:"subnet_mask" json:"subnet_mask"`
</s> add GatewayIP netip.Addr `yaml:"gateway_ip" json:"gateway_ip"`
SubnetMask netip.Addr `yaml:"subnet_mask" json:"subnet_mask"` </s> remove func GatewayIP(ifaceName string) (ip net.IP) {
</s> add func GatewayIP(ifaceName string) (ip netip.Addr) { </s> remove } else if gwIP := s.conf.GatewayIP; gwIP.Equal(ip) {
</s> add } else if gwIP := s.conf.GatewayIP; gwIP == netip.AddrFrom4(*(*[4]byte)(ip)) { | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net.go |
keep replace keep keep replace keep keep keep keep | <mask> if len(fields) < 3 || string(fields[0]) != "default" {
<mask> return nil
<mask> }
<mask>
<mask> return net.ParseIP(string(fields[2]))
<mask> }
<mask>
<mask> // CanBindPrivilegedPorts checks if current process can bind to privileged
<mask> // ports.
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove err := aghnet.CheckPort("tcp", net.IP{127, 0, 0, 1}, defaultPortDNS)
</s> add err := aghnet.CheckPort("tcp", netip.AddrPortFrom(aghnet.IPv4Localhost(), defaultPortDNS)) </s> remove restartHTTP = !config.BindHost.Equal(req.Web.IP) || config.BindPort != req.Web.Port
</s> add restartHTTP = config.BindHost != req.Web.IP || config.BindPort != req.Web.Port </s> remove if ipNet.IP == nil {
</s> add if !ipNet.Addr().IsValid() { </s> remove return Context.web.httpsServer.server != nil ||
aghnet.CheckPort("tcp", config.BindHost, port) == nil
</s> add if Context.web.httpsServer.server != nil {
return true
}
return aghnet.CheckPort("tcp", netip.AddrPortFrom(config.BindHost, uint16(port))) == nil </s> remove if opts.bindHost != nil {
</s> add if opts.bindHost.IsValid() { | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net.go |
keep keep keep keep replace keep replace keep | <mask>
<mask> // NetInterface represents an entry of network interfaces map.
<mask> type NetInterface struct {
<mask> // Addresses are the network interface addresses.
<mask> Addresses []net.IP `json:"ip_addresses,omitempty"`
<mask> // Subnets are the IP networks for this network interface.
<mask> Subnets []*net.IPNet `json:"-"`
<mask> Name string `json:"name"`
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove Name string `json:"name"`
HardwareAddr string `json:"hardware_address"`
Flags string `json:"flags"`
GatewayIP net.IP `json:"gateway_ip"`
Addrs4 []net.IP `json:"ipv4_addresses"`
Addrs6 []net.IP `json:"ipv6_addresses"`
</s> add Name string `json:"name"`
HardwareAddr string `json:"hardware_address"`
Flags string `json:"flags"`
GatewayIP netip.Addr `json:"gateway_ip"`
Addrs4 []netip.Addr `json:"ipv4_addresses"`
Addrs6 []netip.Addr `json:"ipv6_addresses"` </s> remove func appendDNSAddrsWithIfaces(dst []string, src []net.IP) (res []string, err error) {
</s> add func appendDNSAddrsWithIfaces(dst []string, src []netip.Addr) (res []string, err error) { </s> remove func GetSubnet(ifaceName string) *net.IPNet {
</s> add func GetSubnet(ifaceName string) (p netip.Prefix) { </s> remove IP []net.IP `json:"ip"`
Port int `json:"port"`
</s> add IP []netip.Addr `json:"ip"`
Port int `json:"port"` </s> remove // Collect network interface addresses.
for _, addr := range addrs {
ipNet, ok := addr.(*net.IPNet)
if !ok {
// Should be net.IPNet, this is weird.
return nil, fmt.Errorf("got %s that is not net.IPNet, it is %T", addr, addr)
}
// Ignore link-local.
if ipNet.IP.IsLinkLocalUnicast() {
</s> add ip = ip.Unmap()
if ip.IsLinkLocalUnicast() {
// Ignore link-local IPv4.
if ip.Is4() { | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net.go |
keep keep replace replace replace replace replace replace replace keep replace replace replace keep keep | <mask> }
<mask>
<mask> // GetValidNetInterfacesForWeb returns interfaces that are eligible for DNS and
<mask> // WEB only we do not return link-local addresses here.
<mask> //
<mask> // TODO(e.burkov): Can't properly test the function since it's nontrivial to
<mask> // substitute net.Interface.Addrs and the net.InterfaceAddrs can't be used.
<mask> func GetValidNetInterfacesForWeb() (netIfaces []*NetInterface, err error) {
<mask> ifaces, err := net.Interfaces()
<mask> if err != nil {
<mask> return nil, fmt.Errorf("couldn't get interfaces: %w", err)
<mask> } else if len(ifaces) == 0 {
<mask> return nil, errors.Error("couldn't find any legible interface")
<mask> }
<mask>
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove // Discard interfaces with no addresses.
if len(netIface.Addresses) != 0 {
netIfaces = append(netIfaces, netIface)
</s> add ones, _ := n.Mask.Size()
p := netip.PrefixFrom(ip, ones)
niface.Addresses = append(niface.Addresses, ip)
niface.Subnets = append(niface.Subnets, p)
}
return niface, nil
}
// GetValidNetInterfacesForWeb returns interfaces that are eligible for DNS and
// WEB only we do not return link-local addresses here.
//
// TODO(e.burkov): Can't properly test the function since it's nontrivial to
// substitute net.Interface.Addrs and the net.InterfaceAddrs can't be used.
func GetValidNetInterfacesForWeb() (nifaces []*NetInterface, err error) {
ifaces, err := net.Interfaces()
if err != nil {
return nil, fmt.Errorf("getting interfaces: %w", err)
} else if len(ifaces) == 0 {
return nil, errors.Error("no legible interfaces")
}
for i := range ifaces {
var niface *NetInterface
niface, err = NetInterfaceFrom(&ifaces[i])
if err != nil {
return nil, err
} else if len(niface.Addresses) != 0 {
// Discard interfaces with no addresses.
nifaces = append(nifaces, niface) </s> remove for _, iface := range ifaces {
var addrs []net.Addr
addrs, err = iface.Addrs()
if err != nil {
return nil, fmt.Errorf("failed to get addresses for interface %s: %w", iface.Name, err)
</s> add // Collect network interface addresses.
for _, addr := range addrs {
n, ok := addr.(*net.IPNet)
if !ok {
// Should be *net.IPNet, this is weird.
return nil, fmt.Errorf("expected %[2]s to be %[1]T, got %[2]T", n, addr)
} else if ip4 := n.IP.To4(); ip4 != nil {
n.IP = ip4 </s> remove addrs = appendDNSAddrs(addrs, net.IP{127, 0, 0, 1})
</s> add addr := aghnet.IPv4Localhost()
addrs = appendDNSAddrs(addrs, addr) </s> remove func GetSubnet(ifaceName string) *net.IPNet {
</s> add func GetSubnet(ifaceName string) (p netip.Prefix) { </s> remove func InterfaceByIP(ip net.IP) (ifaceName string) {
</s> add func InterfaceByIP(ip netip.Addr) (ifaceName string) { | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net.go |
keep replace replace replace replace replace keep keep replace replace replace replace replace keep | <mask>
<mask> for _, iface := range ifaces {
<mask> var addrs []net.Addr
<mask> addrs, err = iface.Addrs()
<mask> if err != nil {
<mask> return nil, fmt.Errorf("failed to get addresses for interface %s: %w", iface.Name, err)
<mask> }
<mask>
<mask> netIface := &NetInterface{
<mask> MTU: iface.MTU,
<mask> Name: iface.Name,
<mask> HardwareAddr: iface.HardwareAddr,
<mask> Flags: iface.Flags,
<mask> }
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove return nil, fmt.Errorf("couldn't get interfaces: %w", err)
} else if len(ifaces) == 0 {
return nil, errors.Error("couldn't find any legible interface")
</s> add return nil, fmt.Errorf("failed to get addresses for interface %s: %w", iface.Name, err) </s> remove // GetValidNetInterfacesForWeb returns interfaces that are eligible for DNS and
// WEB only we do not return link-local addresses here.
//
// TODO(e.burkov): Can't properly test the function since it's nontrivial to
// substitute net.Interface.Addrs and the net.InterfaceAddrs can't be used.
func GetValidNetInterfacesForWeb() (netIfaces []*NetInterface, err error) {
ifaces, err := net.Interfaces()
</s> add func NetInterfaceFrom(iface *net.Interface) (niface *NetInterface, err error) {
niface = &NetInterface{
Name: iface.Name,
HardwareAddr: iface.HardwareAddr,
Flags: iface.Flags,
MTU: iface.MTU,
}
addrs, err := iface.Addrs() </s> remove return nil, err
</s> add return netip.Prefix{}, err </s> remove // Collect network interface addresses.
for _, addr := range addrs {
ipNet, ok := addr.(*net.IPNet)
if !ok {
// Should be net.IPNet, this is weird.
return nil, fmt.Errorf("got %s that is not net.IPNet, it is %T", addr, addr)
}
// Ignore link-local.
if ipNet.IP.IsLinkLocalUnicast() {
</s> add ip = ip.Unmap()
if ip.IsLinkLocalUnicast() {
// Ignore link-local IPv4.
if ip.Is4() { </s> remove func ifaceIPv4Subnet(iface *net.Interface) (subnet *net.IPNet, err error) {
</s> add func ifaceIPv4Subnet(iface *net.Interface) (subnet netip.Prefix, err error) { | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net.go |
keep keep keep keep replace replace replace replace replace replace replace replace replace replace keep keep keep replace replace keep | <mask> HardwareAddr: iface.HardwareAddr,
<mask> Flags: iface.Flags,
<mask> }
<mask>
<mask> // Collect network interface addresses.
<mask> for _, addr := range addrs {
<mask> ipNet, ok := addr.(*net.IPNet)
<mask> if !ok {
<mask> // Should be net.IPNet, this is weird.
<mask> return nil, fmt.Errorf("got %s that is not net.IPNet, it is %T", addr, addr)
<mask> }
<mask>
<mask> // Ignore link-local.
<mask> if ipNet.IP.IsLinkLocalUnicast() {
<mask> continue
<mask> }
<mask>
<mask> netIface.Addresses = append(netIface.Addresses, ipNet.IP)
<mask> netIface.Subnets = append(netIface.Subnets, ipNet)
<mask> }
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove netIface := &NetInterface{
MTU: iface.MTU,
Name: iface.Name,
HardwareAddr: iface.HardwareAddr,
Flags: iface.Flags,
</s> add ip, ok := netip.AddrFromSlice(n.IP)
if !ok {
return nil, fmt.Errorf("bad address %s", n.IP) </s> remove for _, iface := range ifaces {
var addrs []net.Addr
addrs, err = iface.Addrs()
if err != nil {
return nil, fmt.Errorf("failed to get addresses for interface %s: %w", iface.Name, err)
</s> add // Collect network interface addresses.
for _, addr := range addrs {
n, ok := addr.(*net.IPNet)
if !ok {
// Should be *net.IPNet, this is weird.
return nil, fmt.Errorf("expected %[2]s to be %[1]T, got %[2]T", n, addr)
} else if ip4 := n.IP.To4(); ip4 != nil {
n.IP = ip4 </s> remove // Discard interfaces with no addresses.
if len(netIface.Addresses) != 0 {
netIfaces = append(netIfaces, netIface)
</s> add ones, _ := n.Mask.Size()
p := netip.PrefixFrom(ip, ones)
niface.Addresses = append(niface.Addresses, ip)
niface.Subnets = append(niface.Subnets, p)
}
return niface, nil
}
// GetValidNetInterfacesForWeb returns interfaces that are eligible for DNS and
// WEB only we do not return link-local addresses here.
//
// TODO(e.burkov): Can't properly test the function since it's nontrivial to
// substitute net.Interface.Addrs and the net.InterfaceAddrs can't be used.
func GetValidNetInterfacesForWeb() (nifaces []*NetInterface, err error) {
ifaces, err := net.Interfaces()
if err != nil {
return nil, fmt.Errorf("getting interfaces: %w", err)
} else if len(ifaces) == 0 {
return nil, errors.Error("no legible interfaces")
}
for i := range ifaces {
var niface *NetInterface
niface, err = NetInterfaceFrom(&ifaces[i])
if err != nil {
return nil, err
} else if len(niface.Addresses) != 0 {
// Discard interfaces with no addresses.
nifaces = append(nifaces, niface) </s> remove addr := netutil.IPPort{IP: ip, Port: port}.String()
</s> add addr := ipp.String() </s> remove // GetValidNetInterfacesForWeb returns interfaces that are eligible for DNS and
// WEB only we do not return link-local addresses here.
//
// TODO(e.burkov): Can't properly test the function since it's nontrivial to
// substitute net.Interface.Addrs and the net.InterfaceAddrs can't be used.
func GetValidNetInterfacesForWeb() (netIfaces []*NetInterface, err error) {
ifaces, err := net.Interfaces()
</s> add func NetInterfaceFrom(iface *net.Interface) (niface *NetInterface, err error) {
niface = &NetInterface{
Name: iface.Name,
HardwareAddr: iface.HardwareAddr,
Flags: iface.Flags,
MTU: iface.MTU,
}
addrs, err := iface.Addrs() | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net.go |
keep keep keep replace replace replace keep keep keep replace keep | <mask> netIface.Subnets = append(netIface.Subnets, ipNet)
<mask> }
<mask>
<mask> // Discard interfaces with no addresses.
<mask> if len(netIface.Addresses) != 0 {
<mask> netIfaces = append(netIfaces, netIface)
<mask> }
<mask> }
<mask>
<mask> return netIfaces, nil
<mask> }
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove netIface.Addresses = append(netIface.Addresses, ipNet.IP)
netIface.Subnets = append(netIface.Subnets, ipNet)
</s> add ip = ip.WithZone(iface.Name) </s> remove return nil
</s> add return p </s> remove // Collect network interface addresses.
for _, addr := range addrs {
ipNet, ok := addr.(*net.IPNet)
if !ok {
// Should be net.IPNet, this is weird.
return nil, fmt.Errorf("got %s that is not net.IPNet, it is %T", addr, addr)
}
// Ignore link-local.
if ipNet.IP.IsLinkLocalUnicast() {
</s> add ip = ip.Unmap()
if ip.IsLinkLocalUnicast() {
// Ignore link-local IPv4.
if ip.Is4() { </s> remove if ip4 := subnet.IP.To4(); ip4 != nil {
subnet.IP = ip4
return subnet, nil
</s> add if ip = ip.To4(); ip != nil {
return netip.PrefixFrom(netip.AddrFrom4(*(*[4]byte)(ip)), maskLen), nil </s> remove func GetSubnet(ifaceName string) *net.IPNet {
</s> add func GetSubnet(ifaceName string) (p netip.Prefix) { | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net.go |
keep keep keep keep replace keep keep keep keep keep | <mask> // TODO(a.garipov, e.burkov): This function is technically incorrect, since one
<mask> // IP address can be shared by multiple interfaces in some configurations.
<mask> //
<mask> // TODO(e.burkov): See TODO on GetValidNetInterfacesForWeb.
<mask> func InterfaceByIP(ip net.IP) (ifaceName string) {
<mask> ifaces, err := GetValidNetInterfacesForWeb()
<mask> if err != nil {
<mask> return ""
<mask> }
<mask>
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove return netIfaces, nil
</s> add return nifaces, nil </s> remove func GetSubnet(ifaceName string) *net.IPNet {
</s> add func GetSubnet(ifaceName string) (p netip.Prefix) { </s> remove // GetSubnet returns pointer to net.IPNet for the specified interface or nil if
</s> add // GetSubnet returns the subnet corresponding to the interface of zero prefix if </s> remove func GatewayIP(ifaceName string) (ip net.IP) {
</s> add func GatewayIP(ifaceName string) (ip netip.Addr) { </s> remove // GetValidNetInterfacesForWeb returns interfaces that are eligible for DNS and
// WEB only we do not return link-local addresses here.
//
// TODO(e.burkov): Can't properly test the function since it's nontrivial to
// substitute net.Interface.Addrs and the net.InterfaceAddrs can't be used.
func GetValidNetInterfacesForWeb() (netIfaces []*NetInterface, err error) {
ifaces, err := net.Interfaces()
</s> add func NetInterfaceFrom(iface *net.Interface) (niface *NetInterface, err error) {
niface = &NetInterface{
Name: iface.Name,
HardwareAddr: iface.HardwareAddr,
Flags: iface.Flags,
MTU: iface.MTU,
}
addrs, err := iface.Addrs() </s> remove // Discard interfaces with no addresses.
if len(netIface.Addresses) != 0 {
netIfaces = append(netIfaces, netIface)
</s> add ones, _ := n.Mask.Size()
p := netip.PrefixFrom(ip, ones)
niface.Addresses = append(niface.Addresses, ip)
niface.Subnets = append(niface.Subnets, p)
}
return niface, nil
}
// GetValidNetInterfacesForWeb returns interfaces that are eligible for DNS and
// WEB only we do not return link-local addresses here.
//
// TODO(e.burkov): Can't properly test the function since it's nontrivial to
// substitute net.Interface.Addrs and the net.InterfaceAddrs can't be used.
func GetValidNetInterfacesForWeb() (nifaces []*NetInterface, err error) {
ifaces, err := net.Interfaces()
if err != nil {
return nil, fmt.Errorf("getting interfaces: %w", err)
} else if len(ifaces) == 0 {
return nil, errors.Error("no legible interfaces")
}
for i := range ifaces {
var niface *NetInterface
niface, err = NetInterfaceFrom(&ifaces[i])
if err != nil {
return nil, err
} else if len(niface.Addresses) != 0 {
// Discard interfaces with no addresses.
nifaces = append(nifaces, niface) | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net.go |
keep keep keep keep replace keep keep keep keep keep | <mask> }
<mask>
<mask> for _, iface := range ifaces {
<mask> for _, addr := range iface.Addresses {
<mask> if ip.Equal(addr) {
<mask> return iface.Name
<mask> }
<mask> }
<mask> }
<mask>
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove for _, iface := range ifaces {
var addrs []net.Addr
addrs, err = iface.Addrs()
if err != nil {
return nil, fmt.Errorf("failed to get addresses for interface %s: %w", iface.Name, err)
</s> add // Collect network interface addresses.
for _, addr := range addrs {
n, ok := addr.(*net.IPNet)
if !ok {
// Should be *net.IPNet, this is weird.
return nil, fmt.Errorf("expected %[2]s to be %[1]T, got %[2]T", n, addr)
} else if ip4 := n.IP.To4(); ip4 != nil {
n.IP = ip4 </s> remove return nil, fmt.Errorf("couldn't get interfaces: %w", err)
} else if len(ifaces) == 0 {
return nil, errors.Error("couldn't find any legible interface")
</s> add return nil, fmt.Errorf("failed to get addresses for interface %s: %w", iface.Name, err) </s> remove return nil, err
</s> add return netip.Prefix{}, err </s> remove hostport = netutil.JoinHostPort(addr.String(), config.DNS.Port)
</s> add hostport = netip.AddrPortFrom(addr, uint16(config.DNS.Port)).String() </s> remove tcpAddrs = make([]*net.TCPAddr, len(ips))
for i, ip := range ips {
tcpAddrs[i] = &net.TCPAddr{
IP: ip,
Port: port,
}
</s> add tcpAddrs = make([]*net.TCPAddr, 0, len(ips))
for _, ip := range ips {
tcpAddrs = append(tcpAddrs, net.TCPAddrFromAddrPort(netip.AddrPortFrom(ip, uint16(port)))) </s> remove udpAddrs = make([]*net.UDPAddr, len(ips))
for i, ip := range ips {
udpAddrs[i] = &net.UDPAddr{
IP: ip,
Port: port,
}
</s> add udpAddrs = make([]*net.UDPAddr, 0, len(ips))
for _, ip := range ips {
udpAddrs = append(udpAddrs, net.UDPAddrFromAddrPort(netip.AddrPortFrom(ip, uint16(port)))) | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net.go |
keep keep keep replace keep keep keep replace keep keep keep keep | <mask> return ""
<mask> }
<mask>
<mask> // GetSubnet returns pointer to net.IPNet for the specified interface or nil if
<mask> // the search fails.
<mask> //
<mask> // TODO(e.burkov): See TODO on GetValidNetInterfacesForWeb.
<mask> func GetSubnet(ifaceName string) *net.IPNet {
<mask> netIfaces, err := GetValidNetInterfacesForWeb()
<mask> if err != nil {
<mask> log.Error("Could not get network interfaces info: %v", err)
<mask> return nil
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove return nil
</s> add return p </s> remove func InterfaceByIP(ip net.IP) (ifaceName string) {
</s> add func InterfaceByIP(ip netip.Addr) (ifaceName string) { </s> remove if ipNet.IP == nil {
</s> add if !ipNet.Addr().IsValid() { </s> remove func GatewayIP(ifaceName string) (ip net.IP) {
</s> add func GatewayIP(ifaceName string) (ip netip.Addr) { </s> remove // Discard interfaces with no addresses.
if len(netIface.Addresses) != 0 {
netIfaces = append(netIfaces, netIface)
</s> add ones, _ := n.Mask.Size()
p := netip.PrefixFrom(ip, ones)
niface.Addresses = append(niface.Addresses, ip)
niface.Subnets = append(niface.Subnets, p)
}
return niface, nil
}
// GetValidNetInterfacesForWeb returns interfaces that are eligible for DNS and
// WEB only we do not return link-local addresses here.
//
// TODO(e.burkov): Can't properly test the function since it's nontrivial to
// substitute net.Interface.Addrs and the net.InterfaceAddrs can't be used.
func GetValidNetInterfacesForWeb() (nifaces []*NetInterface, err error) {
ifaces, err := net.Interfaces()
if err != nil {
return nil, fmt.Errorf("getting interfaces: %w", err)
} else if len(ifaces) == 0 {
return nil, errors.Error("no legible interfaces")
}
for i := range ifaces {
var niface *NetInterface
niface, err = NetInterfaceFrom(&ifaces[i])
if err != nil {
return nil, err
} else if len(niface.Addresses) != 0 {
// Discard interfaces with no addresses.
nifaces = append(nifaces, niface) | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net.go |
keep keep keep keep replace keep keep keep keep keep | <mask> func GetSubnet(ifaceName string) *net.IPNet {
<mask> netIfaces, err := GetValidNetInterfacesForWeb()
<mask> if err != nil {
<mask> log.Error("Could not get network interfaces info: %v", err)
<mask> return nil
<mask> }
<mask>
<mask> for _, netIface := range netIfaces {
<mask> if netIface.Name == ifaceName && len(netIface.Subnets) > 0 {
<mask> return netIface.Subnets[0]
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove func GetSubnet(ifaceName string) *net.IPNet {
</s> add func GetSubnet(ifaceName string) (p netip.Prefix) { </s> remove return nil, fmt.Errorf("couldn't get interfaces: %w", err)
} else if len(ifaces) == 0 {
return nil, errors.Error("couldn't find any legible interface")
</s> add return nil, fmt.Errorf("failed to get addresses for interface %s: %w", iface.Name, err) </s> remove // Discard interfaces with no addresses.
if len(netIface.Addresses) != 0 {
netIfaces = append(netIfaces, netIface)
</s> add ones, _ := n.Mask.Size()
p := netip.PrefixFrom(ip, ones)
niface.Addresses = append(niface.Addresses, ip)
niface.Subnets = append(niface.Subnets, p)
}
return niface, nil
}
// GetValidNetInterfacesForWeb returns interfaces that are eligible for DNS and
// WEB only we do not return link-local addresses here.
//
// TODO(e.burkov): Can't properly test the function since it's nontrivial to
// substitute net.Interface.Addrs and the net.InterfaceAddrs can't be used.
func GetValidNetInterfacesForWeb() (nifaces []*NetInterface, err error) {
ifaces, err := net.Interfaces()
if err != nil {
return nil, fmt.Errorf("getting interfaces: %w", err)
} else if len(ifaces) == 0 {
return nil, errors.Error("no legible interfaces")
}
for i := range ifaces {
var niface *NetInterface
niface, err = NetInterfaceFrom(&ifaces[i])
if err != nil {
return nil, err
} else if len(niface.Addresses) != 0 {
// Discard interfaces with no addresses.
nifaces = append(nifaces, niface) </s> remove for _, iface := range ifaces {
var addrs []net.Addr
addrs, err = iface.Addrs()
if err != nil {
return nil, fmt.Errorf("failed to get addresses for interface %s: %w", iface.Name, err)
</s> add // Collect network interface addresses.
for _, addr := range addrs {
n, ok := addr.(*net.IPNet)
if !ok {
// Should be *net.IPNet, this is weird.
return nil, fmt.Errorf("expected %[2]s to be %[1]T, got %[2]T", n, addr)
} else if ip4 := n.IP.To4(); ip4 != nil {
n.IP = ip4 </s> remove if ipNet.IP == nil {
</s> add if !ipNet.Addr().IsValid() { </s> remove netIface := &NetInterface{
MTU: iface.MTU,
Name: iface.Name,
HardwareAddr: iface.HardwareAddr,
Flags: iface.Flags,
</s> add ip, ok := netip.AddrFromSlice(n.IP)
if !ok {
return nil, fmt.Errorf("bad address %s", n.IP) | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net.go |
keep replace keep keep keep keep replace keep keep | <mask>
<mask> return nil
<mask> }
<mask>
<mask> // CheckPort checks if the port is available for binding. network is expected
<mask> // to be one of "udp" and "tcp".
<mask> func CheckPort(network string, ip net.IP, port int) (err error) {
<mask> var c io.Closer
<mask> addr := netutil.IPPort{IP: ip, Port: port}.String()
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove addr := netutil.IPPort{IP: ip, Port: port}.String()
</s> add addr := ipp.String() </s> remove func ipsToUDPAddrs(ips []net.IP, port int) (udpAddrs []*net.UDPAddr) {
</s> add func ipsToUDPAddrs(ips []netip.Addr, port int) (udpAddrs []*net.UDPAddr) { </s> remove func ipsToTCPAddrs(ips []net.IP, port int) (tcpAddrs []*net.TCPAddr) {
</s> add func ipsToTCPAddrs(ips []netip.Addr, port int) (tcpAddrs []*net.TCPAddr) { </s> remove // ensureV4 returns a 4-byte version of ip. An error is returned if the passed
// ip is not an IPv4.
func ensureV4(ip net.IP) (ip4 net.IP, err error) {
if ip == nil {
return nil, fmt.Errorf("%v is not an IP address", ip)
}
ip4 = ip.To4()
if ip4 == nil {
return nil, fmt.Errorf("%v is not an IPv4 address", ip)
</s> add // ensureV4 returns an unmapped version of ip. An error is returned if the
// passed ip is not an IPv4.
func ensureV4(ip netip.Addr, kind string) (ip4 netip.Addr, err error) {
ip4 = ip.Unmap()
if !ip4.IsValid() || !ip4.Is4() {
return netip.Addr{}, fmt.Errorf("%v is not an IPv4 %s", ip, kind) </s> remove return aghnet.CheckPort("tcp", req.Web.IP, portInt)
</s> add return aghnet.CheckPort("tcp", netip.AddrPortFrom(req.Web.IP, uint16(portInt))) | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net.go |
keep keep keep keep replace keep keep keep keep keep | <mask> // CheckPort checks if the port is available for binding. network is expected
<mask> // to be one of "udp" and "tcp".
<mask> func CheckPort(network string, ip net.IP, port int) (err error) {
<mask> var c io.Closer
<mask> addr := netutil.IPPort{IP: ip, Port: port}.String()
<mask> switch network {
<mask> case "tcp":
<mask> c, err = net.Listen(network, addr)
<mask> case "udp":
<mask> c, err = net.ListenPacket(network, addr)
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove func CheckPort(network string, ip net.IP, port int) (err error) {
</s> add func CheckPort(network string, ipp netip.AddrPort) (err error) { </s> remove return nil
</s> add return p </s> add var ip net.IP
var maskLen int </s> remove s.conf.dnsIPAddrs = dnsIPAddrs
</s> add for _, ip := range dnsIPAddrs {
ip = ip.To4()
if ip == nil {
continue
}
s.conf.dnsIPAddrs = append(s.conf.dnsIPAddrs, netip.AddrFrom4(*(*[4]byte)(ip)))
} </s> remove return nil, err
</s> add return netip.Prefix{}, err </s> remove // Collect network interface addresses.
for _, addr := range addrs {
ipNet, ok := addr.(*net.IPNet)
if !ok {
// Should be net.IPNet, this is weird.
return nil, fmt.Errorf("got %s that is not net.IPNet, it is %T", addr, addr)
}
// Ignore link-local.
if ipNet.IP.IsLinkLocalUnicast() {
</s> add ip = ip.Unmap()
if ip.IsLinkLocalUnicast() {
// Ignore link-local IPv4.
if ip.Is4() { | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net.go |
keep keep keep replace replace replace keep replace replace replace keep keep keep keep | <mask> return addrs, nil
<mask> }
<mask>
<mask> // BroadcastFromIPNet calculates the broadcast IP address for n.
<mask> func BroadcastFromIPNet(n *net.IPNet) (dc net.IP) {
<mask> dc = netutil.CloneIP(n.IP)
<mask>
<mask> mask := n.Mask
<mask> if mask == nil {
<mask> mask = dc.DefaultMask()
<mask> }
<mask>
<mask> for i, b := range mask {
<mask> dc[i] |= ^b
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove for i, b := range mask {
dc[i] |= ^b
</s> add ipBytes := bc.AsSlice()
for i := maskLen; i < addrLen; i++ {
ipBytes[i/8] |= 1 << (7 - (i % 8)) </s> remove return dc
</s> add return bc </s> remove udpAddrs = make([]*net.UDPAddr, len(ips))
for i, ip := range ips {
udpAddrs[i] = &net.UDPAddr{
IP: ip,
Port: port,
}
</s> add udpAddrs = make([]*net.UDPAddr, 0, len(ips))
for _, ip := range ips {
udpAddrs = append(udpAddrs, net.UDPAddrFromAddrPort(netip.AddrPortFrom(ip, uint16(port)))) </s> remove tcpAddrs = make([]*net.TCPAddr, len(ips))
for i, ip := range ips {
tcpAddrs[i] = &net.TCPAddr{
IP: ip,
Port: port,
}
</s> add tcpAddrs = make([]*net.TCPAddr, 0, len(ips))
for _, ip := range ips {
tcpAddrs = append(tcpAddrs, net.TCPAddrFromAddrPort(netip.AddrPortFrom(ip, uint16(port)))) </s> remove if ip4 := reqIP.To4(); ip4 == nil {
</s> add ip4 := reqIP.To4()
if ip4 == nil { | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net.go |
keep keep keep keep replace replace keep keep keep keep | <mask> if mask == nil {
<mask> mask = dc.DefaultMask()
<mask> }
<mask>
<mask> for i, b := range mask {
<mask> dc[i] |= ^b
<mask> }
<mask>
<mask> return dc
<mask> }
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove return dc
</s> add return bc </s> remove mask := n.Mask
if mask == nil {
mask = dc.DefaultMask()
</s> add maskLen, addrLen := p.Bits(), bc.BitLen()
if maskLen == addrLen {
return bc </s> remove // BroadcastFromIPNet calculates the broadcast IP address for n.
func BroadcastFromIPNet(n *net.IPNet) (dc net.IP) {
dc = netutil.CloneIP(n.IP)
</s> add // BroadcastFromPref calculates the broadcast IP address for p.
func BroadcastFromPref(p netip.Prefix) (bc netip.Addr) {
bc = p.Addr().Unmap()
if !bc.IsValid() {
return netip.Addr{}
} </s> remove tcpAddrs = make([]*net.TCPAddr, len(ips))
for i, ip := range ips {
tcpAddrs[i] = &net.TCPAddr{
IP: ip,
Port: port,
}
</s> add tcpAddrs = make([]*net.TCPAddr, 0, len(ips))
for _, ip := range ips {
tcpAddrs = append(tcpAddrs, net.TCPAddrFromAddrPort(netip.AddrPortFrom(ip, uint16(port)))) </s> remove udpAddrs = make([]*net.UDPAddr, len(ips))
for i, ip := range ips {
udpAddrs[i] = &net.UDPAddr{
IP: ip,
Port: port,
}
</s> add udpAddrs = make([]*net.UDPAddr, 0, len(ips))
for _, ip := range ips {
udpAddrs = append(udpAddrs, net.UDPAddrFromAddrPort(netip.AddrPortFrom(ip, uint16(port)))) </s> remove if ip.Equal(addr) {
</s> add if ip == addr { | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net.go |
keep keep keep add keep keep keep | <mask> ipBytes := bc.AsSlice()
<mask> for i := maskLen; i < addrLen; i++ {
<mask> ipBytes[i/8] |= 1 << (7 - (i % 8))
<mask> }
<mask>
<mask> return bc
<mask> }
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove for i, b := range mask {
dc[i] |= ^b
</s> add ipBytes := bc.AsSlice()
for i := maskLen; i < addrLen; i++ {
ipBytes[i/8] |= 1 << (7 - (i % 8)) </s> remove return dc
</s> add return bc </s> remove mask := n.Mask
if mask == nil {
mask = dc.DefaultMask()
</s> add maskLen, addrLen := p.Bits(), bc.BitLen()
if maskLen == addrLen {
return bc </s> remove bc := BroadcastFromIPNet(tc.subnet)
assert.True(t, bc.Equal(tc.want), bc)
</s> add assert.Equal(t, tc.want, BroadcastFromPref(tc.pref)) </s> remove // Discard interfaces with no addresses.
if len(netIface.Addresses) != 0 {
netIfaces = append(netIfaces, netIface)
</s> add ones, _ := n.Mask.Size()
p := netip.PrefixFrom(ip, ones)
niface.Addresses = append(niface.Addresses, ip)
niface.Subnets = append(niface.Subnets, p)
}
return niface, nil
}
// GetValidNetInterfacesForWeb returns interfaces that are eligible for DNS and
// WEB only we do not return link-local addresses here.
//
// TODO(e.burkov): Can't properly test the function since it's nontrivial to
// substitute net.Interface.Addrs and the net.InterfaceAddrs can't be used.
func GetValidNetInterfacesForWeb() (nifaces []*NetInterface, err error) {
ifaces, err := net.Interfaces()
if err != nil {
return nil, fmt.Errorf("getting interfaces: %w", err)
} else if len(ifaces) == 0 {
return nil, errors.Error("no legible interfaces")
}
for i := range ifaces {
var niface *NetInterface
niface, err = NetInterfaceFrom(&ifaces[i])
if err != nil {
return nil, err
} else if len(niface.Addresses) != 0 {
// Discard interfaces with no addresses.
nifaces = append(nifaces, niface) </s> remove // BroadcastFromIPNet calculates the broadcast IP address for n.
func BroadcastFromIPNet(n *net.IPNet) (dc net.IP) {
dc = netutil.CloneIP(n.IP)
</s> add // BroadcastFromPref calculates the broadcast IP address for p.
func BroadcastFromPref(p netip.Prefix) (bc netip.Addr) {
bc = p.Addr().Unmap()
if !bc.IsValid() {
return netip.Addr{}
} | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net.go |
keep keep keep keep replace keep | <mask> for i, b := range mask {
<mask> dc[i] |= ^b
<mask> }
<mask>
<mask> return dc
<mask> }
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove for i, b := range mask {
dc[i] |= ^b
</s> add ipBytes := bc.AsSlice()
for i := maskLen; i < addrLen; i++ {
ipBytes[i/8] |= 1 << (7 - (i % 8)) </s> remove mask := n.Mask
if mask == nil {
mask = dc.DefaultMask()
</s> add maskLen, addrLen := p.Bits(), bc.BitLen()
if maskLen == addrLen {
return bc </s> remove // BroadcastFromIPNet calculates the broadcast IP address for n.
func BroadcastFromIPNet(n *net.IPNet) (dc net.IP) {
dc = netutil.CloneIP(n.IP)
</s> add // BroadcastFromPref calculates the broadcast IP address for p.
func BroadcastFromPref(p netip.Prefix) (bc netip.Addr) {
bc = p.Addr().Unmap()
if !bc.IsValid() {
return netip.Addr{}
} </s> remove tcpAddrs = make([]*net.TCPAddr, len(ips))
for i, ip := range ips {
tcpAddrs[i] = &net.TCPAddr{
IP: ip,
Port: port,
}
</s> add tcpAddrs = make([]*net.TCPAddr, 0, len(ips))
for _, ip := range ips {
tcpAddrs = append(tcpAddrs, net.TCPAddrFromAddrPort(netip.AddrPortFrom(ip, uint16(port)))) </s> remove udpAddrs = make([]*net.UDPAddr, len(ips))
for i, ip := range ips {
udpAddrs[i] = &net.UDPAddr{
IP: ip,
Port: port,
}
</s> add udpAddrs = make([]*net.UDPAddr, 0, len(ips))
for _, ip := range ips {
udpAddrs = append(udpAddrs, net.UDPAddrFromAddrPort(netip.AddrPortFrom(ip, uint16(port)))) </s> add bc, _ = netip.AddrFromSlice(ipBytes) | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net.go |
keep keep keep keep replace keep keep keep keep keep | <mask> import (
<mask> "bufio"
<mask> "fmt"
<mask> "io"
<mask> "net"
<mask> "os"
<mask> "strings"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghos"
<mask> "github.com/AdguardTeam/golibs/errors"
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove "net"
</s> add "net/netip" </s> add "net/netip" </s> add "net/netip" </s> remove "net"
</s> add </s> add "net/netip" </s> add "net/netip" | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_linux.go |
keep keep keep keep replace keep keep keep keep keep | <mask> // ifaceSetStaticIP configures the system to retain its current IP on the
<mask> // interface through dhcpcd.conf.
<mask> func ifaceSetStaticIP(ifaceName string) (err error) {
<mask> ipNet := GetSubnet(ifaceName)
<mask> if ipNet.IP == nil {
<mask> return errors.Error("can't get IP address")
<mask> }
<mask>
<mask> body, err := os.ReadFile(dhcpcdConf)
<mask> if err != nil && !errors.Is(err, os.ErrNotExist) {
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove func GetSubnet(ifaceName string) *net.IPNet {
</s> add func GetSubnet(ifaceName string) (p netip.Prefix) { </s> remove return nil
</s> add return p </s> remove return nil, fmt.Errorf("couldn't get interfaces: %w", err)
} else if len(ifaces) == 0 {
return nil, errors.Error("couldn't find any legible interface")
</s> add return nil, fmt.Errorf("failed to get addresses for interface %s: %w", iface.Name, err) </s> remove // GetSubnet returns pointer to net.IPNet for the specified interface or nil if
</s> add // GetSubnet returns the subnet corresponding to the interface of zero prefix if </s> remove func InterfaceByIP(ip net.IP) (ifaceName string) {
</s> add func InterfaceByIP(ip netip.Addr) (ifaceName string) { </s> remove return net.ParseIP(string(fields[2]))
</s> add ip, err = netip.ParseAddr(string(fields[2]))
if err != nil {
return netip.Addr{}
}
return ip | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_linux.go |
keep keep keep keep replace keep keep keep keep keep | <mask> }
<mask>
<mask> // dhcpcdConfIface returns configuration lines for the dhcpdc.conf files that
<mask> // configure the interface to have a static IP.
<mask> func dhcpcdConfIface(ifaceName string, ipNet *net.IPNet, gwIP net.IP) (conf string) {
<mask> b := &strings.Builder{}
<mask> stringutil.WriteToBuilder(
<mask> b,
<mask> "\n# ",
<mask> ifaceName,
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> add // IPv4Localhost returns 127.0.0.1, which returns true for [netip.Addr.Is4].
func IPv4Localhost() (ip netip.Addr) { return netip.AddrFrom4([4]byte{127, 0, 0, 1}) }
// IPv6Localhost returns ::1, which returns true for [netip.Addr.Is6].
func IPv6Localhost() (ip netip.Addr) { return netip.AddrFrom16([16]byte{15: 1}) }
</s> remove // GetSubnet returns pointer to net.IPNet for the specified interface or nil if
</s> add // GetSubnet returns the subnet corresponding to the interface of zero prefix if </s> remove ipNet.String(),
</s> add subnet.String(), </s> remove func GetSubnet(ifaceName string) *net.IPNet {
</s> add func GetSubnet(ifaceName string) (p netip.Prefix) { </s> remove if ipNet.IP == nil {
</s> add if !ipNet.Addr().IsValid() { </s> remove func handleStaticIP(ip net.IP, set bool) staticIPJSON {
</s> add func handleStaticIP(ip netip.Addr, set bool) staticIPJSON { | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_linux.go |
keep replace keep keep keep replace replace keep keep keep | <mask> "\nstatic ip_address=",
<mask> ipNet.String(),
<mask> "\n",
<mask> )
<mask>
<mask> if gwIP != nil {
<mask> stringutil.WriteToBuilder(b, "static routers=", gwIP.String(), "\n")
<mask> }
<mask>
<mask> stringutil.WriteToBuilder(b, "static domain_name_servers=", ipNet.IP.String(), "\n\n")
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove stringutil.WriteToBuilder(b, "static domain_name_servers=", ipNet.IP.String(), "\n\n")
</s> add stringutil.WriteToBuilder(b, "static domain_name_servers=", subnet.Addr().String(), "\n\n") </s> remove defer func() { s.implicitOpts.Update(dhcpv4.OptDNS(defaultIP)) }()
</s> add defer func() { s.implicitOpts.Update(dhcpv4.OptDNS(defaultIP.AsSlice())) }() </s> remove } else if gwIP := s.conf.GatewayIP; gwIP.Equal(ip) {
</s> add } else if gwIP := s.conf.GatewayIP; gwIP == netip.AddrFrom4(*(*[4]byte)(ip)) { </s> remove if !c.subnet.Contains(c.RangeStart) {
</s> add if !c.subnet.Contains(rangeStart) { </s> remove if !c.subnet.Contains(c.RangeEnd) {
</s> add if !c.subnet.Contains(rangeEnd) { | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_linux.go |
keep keep keep keep replace keep keep keep | <mask> if gwIP != nil {
<mask> stringutil.WriteToBuilder(b, "static routers=", gwIP.String(), "\n")
<mask> }
<mask>
<mask> stringutil.WriteToBuilder(b, "static domain_name_servers=", ipNet.IP.String(), "\n\n")
<mask>
<mask> return b.String()
<mask> }
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove if gwIP != nil {
stringutil.WriteToBuilder(b, "static routers=", gwIP.String(), "\n")
</s> add if gateway != (netip.Addr{}) {
stringutil.WriteToBuilder(b, "static routers=", gateway.String(), "\n") </s> remove ipNet.String(),
</s> add subnet.String(), </s> remove defer func() { s.implicitOpts.Update(dhcpv4.OptDNS(defaultIP)) }()
</s> add defer func() { s.implicitOpts.Update(dhcpv4.OptDNS(defaultIP.AsSlice())) }() </s> remove } else if gwIP := s.conf.GatewayIP; gwIP.Equal(ip) {
</s> add } else if gwIP := s.conf.GatewayIP; gwIP == netip.AddrFrom4(*(*[4]byte)(ip)) { </s> remove return nil
</s> add return netip.Addr{} </s> remove if ip4 := subnet.IP.To4(); ip4 != nil {
subnet.IP = ip4
return subnet, nil
</s> add if ip = ip.To4(); ip != nil {
return netip.PrefixFrom(netip.AddrFrom4(*(*[4]byte)(ip)), maskLen), nil | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_linux.go |
keep keep keep add keep keep keep keep keep keep | <mask> "encoding/json"
<mask> "fmt"
<mask> "io/fs"
<mask> "net"
<mask> "os"
<mask> "strings"
<mask> "testing"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghtest"
<mask> "github.com/AdguardTeam/golibs/errors"
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove "net"
</s> add "net/netip" </s> add "net/netip" </s> add "net/netip" </s> add "net/netip" </s> add "net/netip" </s> remove "net"
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_test.go |
keep keep replace keep replace | <mask>
<mask> testCases := []struct {
<mask> name string
<mask> shell mapShell
<mask> want net.IP
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove name string
subnet *net.IPNet
want net.IP
</s> add pref netip.Prefix
want netip.Addr
name string </s> remove name: "success_v4",
</s> add </s> remove gatewayIP net.IP
subnetMask net.IP
</s> add </s> remove known6 := net.IP{
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16,
}
</s> add known4 := netip.MustParseAddr("192.168.0.1")
fullBroadcast4 := netip.MustParseAddr("255.255.255.255")
known6 := netip.MustParseAddr("102:304:506:708:90a:b0c:d0e:f10") </s> add gatewayIP netip.Addr
subnetMask netip.Addr | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_test.go |
keep replace keep replace keep keep keep | <mask> }{{
<mask> name: "success_v4",
<mask> shell: theOnlyCmd(cmd, 0, `default via 1.2.3.4 onlink`, nil),
<mask> want: net.IP{1, 2, 3, 4}.To16(),
<mask> }, {
<mask> name: "success_v6",
<mask> shell: theOnlyCmd(cmd, 0, `default via ::ffff onlink`, nil),
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove name: "success_v6",
</s> add </s> remove want: net.IP{
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0xFF, 0xFF,
},
</s> add want: netip.MustParseAddr("::ffff"),
name: "success_v6", </s> remove want net.IP
</s> add want netip.Addr
name string </s> remove name: "err_runcmd",
</s> add </s> remove want: nil,
</s> add want: netip.Addr{},
name: "bad_output", | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_test.go |
keep replace keep replace replace replace replace replace replace keep keep keep | <mask> }, {
<mask> name: "success_v6",
<mask> shell: theOnlyCmd(cmd, 0, `default via ::ffff onlink`, nil),
<mask> want: net.IP{
<mask> 0x0, 0x0, 0x0, 0x0,
<mask> 0x0, 0x0, 0x0, 0x0,
<mask> 0x0, 0x0, 0x0, 0x0,
<mask> 0x0, 0x0, 0xFF, 0xFF,
<mask> },
<mask> }, {
<mask> name: "bad_output",
<mask> shell: theOnlyCmd(cmd, 0, `non-default via 1.2.3.4 onlink`, nil),
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove name: "bad_output",
</s> add </s> remove want: net.IP{1, 2, 3, 4}.To16(),
</s> add want: netip.MustParseAddr("1.2.3.4"),
name: "success_v4", </s> remove name: "success_v4",
</s> add </s> remove name: "err_runcmd",
</s> add </s> remove want: nil,
</s> add want: netip.Addr{},
name: "bad_output", | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_test.go |
keep replace keep replace | <mask> }, {
<mask> name: "bad_output",
<mask> shell: theOnlyCmd(cmd, 0, `non-default via 1.2.3.4 onlink`, nil),
<mask> want: nil,
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove name: "err_runcmd",
</s> add </s> remove want: net.IP{
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0xFF, 0xFF,
},
</s> add want: netip.MustParseAddr("::ffff"),
name: "success_v6", </s> remove want: net.IP{1, 2, 3, 4}.To16(),
</s> add want: netip.MustParseAddr("1.2.3.4"),
name: "success_v4", </s> remove name: "success_v4",
</s> add </s> remove name: "success_v6",
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask> name: "bad_output",
<mask> shell: theOnlyCmd(cmd, 0, `non-default via 1.2.3.4 onlink`, nil),
<mask> want: nil,
<mask> }, {
<mask> name: "err_runcmd",
<mask> shell: theOnlyCmd(cmd, 0, "", errors.Error("can't run command")),
<mask> want: nil,
<mask> }, {
<mask> name: "bad_code",
<mask> shell: theOnlyCmd(cmd, 1, "", nil),
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove want: nil,
</s> add want: netip.Addr{},
name: "bad_output", </s> remove want: nil,
</s> add want: netip.Addr{},
name: "err_runcmd", </s> remove name: "bad_output",
</s> add </s> remove name: "bad_code",
</s> add </s> remove want: net.IP{
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0xFF, 0xFF,
},
</s> add want: netip.MustParseAddr("::ffff"),
name: "success_v6", </s> remove want: net.IP{1, 2, 3, 4}.To16(),
</s> add want: netip.MustParseAddr("1.2.3.4"),
name: "success_v4", | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_test.go |
keep keep keep replace keep replace keep keep keep | <mask> }, {
<mask> name: "err_runcmd",
<mask> shell: theOnlyCmd(cmd, 0, "", errors.Error("can't run command")),
<mask> want: nil,
<mask> }, {
<mask> name: "bad_code",
<mask> shell: theOnlyCmd(cmd, 1, "", nil),
<mask> want: nil,
<mask> }}
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove name: "err_runcmd",
</s> add </s> remove want: nil,
</s> add want: netip.Addr{},
name: "bad_output", </s> remove name: "bad_output",
</s> add </s> remove want: nil,
</s> add want: netip.Addr{},
name: "bad_code", </s> remove want: net.IP{
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0xFF, 0xFF,
},
</s> add want: netip.MustParseAddr("::ffff"),
name: "success_v6", | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask> want: nil,
<mask> }, {
<mask> name: "bad_code",
<mask> shell: theOnlyCmd(cmd, 1, "", nil),
<mask> want: nil,
<mask> }}
<mask>
<mask> for _, tc := range testCases {
<mask> t.Run(tc.name, func(t *testing.T) {
<mask> substShell(t, tc.shell.RunCmd)
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove name: "bad_code",
</s> add </s> remove want: nil,
</s> add want: netip.Addr{},
name: "err_runcmd", </s> remove name: "err_runcmd",
</s> add </s> remove subnet: &net.IPNet{
IP: net.IP{0, 0, 0, 0},
Mask: net.IPMask{0, 0, 0, 0},
},
want: net.IPv4bcast,
</s> add }, {
pref: netip.Prefix{},
want: netip.Addr{},
name: "invalid", </s> remove want: nil,
</s> add want: netip.Addr{},
name: "bad_output", </s> remove name: "bad_output",
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_test.go |
keep keep keep keep replace replace replace replace replace replace keep keep replace replace replace keep | <mask> }
<mask> }
<mask>
<mask> func TestBroadcastFromIPNet(t *testing.T) {
<mask> known6 := net.IP{
<mask> 1, 2, 3, 4,
<mask> 5, 6, 7, 8,
<mask> 9, 10, 11, 12,
<mask> 13, 14, 15, 16,
<mask> }
<mask>
<mask> testCases := []struct {
<mask> name string
<mask> subnet *net.IPNet
<mask> want net.IP
<mask> }{{
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove want net.IP
</s> add want netip.Addr
name string </s> remove gatewayIP net.IP
subnetMask net.IP
</s> add </s> remove name string
</s> add </s> remove dhcpv4.WithGatewayIP(DefaultGatewayIP),
</s> add dhcpv4.WithGatewayIP(DefaultGatewayIP.AsSlice()), </s> remove name: "success_v4",
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_test.go |
keep keep keep add keep keep keep keep keep keep | <mask> pref netip.Prefix
<mask> want netip.Addr
<mask> name string
<mask> }{{
<mask> name: "full",
<mask> }, {
<mask> pref: netip.PrefixFrom(known4, 20),
<mask> want: netip.MustParseAddr("192.168.15.255"),
<mask> name: "full",
<mask> }, {
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove name: "ipv6_no_mask",
subnet: &net.IPNet{
IP: known6,
},
</s> add pref: netip.PrefixFrom(known4, 20),
want: netip.MustParseAddr("192.168.15.255"),
name: "full",
}, {
pref: netip.PrefixFrom(known6, netutil.IPv6BitLen), </s> remove name string
subnet *net.IPNet
want net.IP
</s> add pref netip.Prefix
want netip.Addr
name string </s> remove want net.IP
</s> add want netip.Addr
name string </s> add name: "ipv6_no_mask", </s> add pref: netip.PrefixFrom(known4, netutil.IPv4BitLen),
want: known4, </s> remove subnet: &net.IPNet{
IP: net.IP{192, 168, 0, 1},
Mask: net.IPMask{255, 255, 15, 0},
},
want: net.IP{192, 168, 240, 255},
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_test.go |
keep keep keep replace replace replace replace replace keep replace replace replace replace keep keep keep keep | <mask> want net.IP
<mask> }{{
<mask> name: "full",
<mask> subnet: &net.IPNet{
<mask> IP: net.IP{192, 168, 0, 1},
<mask> Mask: net.IPMask{255, 255, 15, 0},
<mask> },
<mask> want: net.IP{192, 168, 240, 255},
<mask> }, {
<mask> name: "ipv6_no_mask",
<mask> subnet: &net.IPNet{
<mask> IP: known6,
<mask> },
<mask> want: known6,
<mask> }, {
<mask> name: "ipv4_no_mask",
<mask> subnet: &net.IPNet{
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove subnet: &net.IPNet{
IP: net.IP{192, 168, 1, 2},
},
want: net.IP{192, 168, 1, 255},
</s> add </s> remove name string
subnet *net.IPNet
want net.IP
</s> add pref netip.Prefix
want netip.Addr
name string </s> remove subnet: &net.IPNet{
IP: net.IP{0, 0, 0, 0},
Mask: net.IPMask{0, 0, 0, 0},
},
want: net.IPv4bcast,
</s> add }, {
pref: netip.Prefix{},
want: netip.Addr{},
name: "invalid", </s> add name: "ipv6_no_mask", </s> add pref: netip.PrefixFrom(known4, 0),
want: fullBroadcast4, | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_test.go |
keep keep add keep keep keep keep keep | <mask> }, {
<mask> pref: netip.PrefixFrom(known6, netutil.IPv6BitLen),
<mask> want: known6,
<mask> }, {
<mask> pref: netip.PrefixFrom(known4, netutil.IPv4BitLen),
<mask> want: known4,
<mask> name: "ipv4_no_mask",
<mask> }, {
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> add pref: netip.PrefixFrom(known4, netutil.IPv4BitLen),
want: known4, </s> remove name: "ipv6_no_mask",
subnet: &net.IPNet{
IP: known6,
},
</s> add pref: netip.PrefixFrom(known4, 20),
want: netip.MustParseAddr("192.168.15.255"),
name: "full",
}, {
pref: netip.PrefixFrom(known6, netutil.IPv6BitLen), </s> add pref: netip.PrefixFrom(netip.IPv4Unspecified(), 0),
want: fullBroadcast4, </s> add pref: netip.PrefixFrom(known4, 0),
want: fullBroadcast4, </s> remove subnet: &net.IPNet{
IP: net.IP{192, 168, 1, 2},
},
want: net.IP{192, 168, 1, 255},
</s> add </s> remove subnet: &net.IPNet{
IP: net.IP{0, 0, 0, 0},
Mask: net.IPMask{0, 0, 0, 0},
},
want: net.IPv4bcast,
</s> add }, {
pref: netip.Prefix{},
want: netip.Addr{},
name: "invalid", | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_test.go |
keep add keep keep keep keep keep | <mask> name: "ipv6_no_mask",
<mask> }, {
<mask> name: "ipv4_no_mask",
<mask> }, {
<mask> pref: netip.PrefixFrom(netip.IPv4Unspecified(), 0),
<mask> want: fullBroadcast4,
<mask> name: "unspecified",
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> add pref: netip.PrefixFrom(netip.IPv4Unspecified(), 0),
want: fullBroadcast4, </s> add name: "ipv6_no_mask", </s> add pref: netip.PrefixFrom(known4, 0),
want: fullBroadcast4, </s> remove name: "ipv6_no_mask",
subnet: &net.IPNet{
IP: known6,
},
</s> add pref: netip.PrefixFrom(known4, 20),
want: netip.MustParseAddr("192.168.15.255"),
name: "full",
}, {
pref: netip.PrefixFrom(known6, netutil.IPv6BitLen), </s> remove subnet: &net.IPNet{
IP: net.IP{192, 168, 1, 2},
},
want: net.IP{192, 168, 1, 255},
</s> add </s> remove subnet: &net.IPNet{
IP: net.IP{0, 0, 0, 0},
Mask: net.IPMask{0, 0, 0, 0},
},
want: net.IPv4bcast,
</s> add }, {
pref: netip.Prefix{},
want: netip.Addr{},
name: "invalid", | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_test.go |
keep keep keep keep replace replace replace replace keep keep keep keep keep | <mask> },
<mask> want: known6,
<mask> }, {
<mask> name: "ipv4_no_mask",
<mask> subnet: &net.IPNet{
<mask> IP: net.IP{192, 168, 1, 2},
<mask> },
<mask> want: net.IP{192, 168, 1, 255},
<mask> }, {
<mask> name: "unspecified",
<mask> subnet: &net.IPNet{
<mask> IP: net.IP{0, 0, 0, 0},
<mask> Mask: net.IPMask{0, 0, 0, 0},
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove name: "ipv6_no_mask",
subnet: &net.IPNet{
IP: known6,
},
</s> add pref: netip.PrefixFrom(known4, 20),
want: netip.MustParseAddr("192.168.15.255"),
name: "full",
}, {
pref: netip.PrefixFrom(known6, netutil.IPv6BitLen), </s> remove subnet: &net.IPNet{
IP: net.IP{0, 0, 0, 0},
Mask: net.IPMask{0, 0, 0, 0},
},
want: net.IPv4bcast,
</s> add }, {
pref: netip.Prefix{},
want: netip.Addr{},
name: "invalid", </s> remove subnet: &net.IPNet{
IP: net.IP{192, 168, 0, 1},
Mask: net.IPMask{255, 255, 15, 0},
},
want: net.IP{192, 168, 240, 255},
</s> add </s> remove name string
subnet *net.IPNet
want net.IP
</s> add pref netip.Prefix
want netip.Addr
name string </s> remove name: "err_runcmd",
</s> add </s> remove want: nil,
</s> add want: netip.Addr{},
name: "err_runcmd", | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_test.go |
keep keep add keep keep keep keep keep | <mask> want: known4,
<mask> name: "ipv4_no_mask",
<mask> }, {
<mask> name: "unspecified",
<mask> }, {
<mask> pref: netip.Prefix{},
<mask> want: netip.Addr{},
<mask> name: "invalid",
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> add pref: netip.PrefixFrom(known4, netutil.IPv4BitLen),
want: known4, </s> add name: "ipv6_no_mask", </s> remove subnet: &net.IPNet{
IP: net.IP{0, 0, 0, 0},
Mask: net.IPMask{0, 0, 0, 0},
},
want: net.IPv4bcast,
</s> add }, {
pref: netip.Prefix{},
want: netip.Addr{},
name: "invalid", </s> remove name: "ipv6_no_mask",
subnet: &net.IPNet{
IP: known6,
},
</s> add pref: netip.PrefixFrom(known4, 20),
want: netip.MustParseAddr("192.168.15.255"),
name: "full",
}, {
pref: netip.PrefixFrom(known6, netutil.IPv6BitLen), </s> remove subnet: &net.IPNet{
IP: net.IP{192, 168, 1, 2},
},
want: net.IP{192, 168, 1, 255},
</s> add </s> remove want: nil,
</s> add want: netip.Addr{},
name: "bad_output", | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_test.go |
keep keep keep keep replace replace replace replace replace keep keep keep keep replace replace keep | <mask> },
<mask> want: net.IP{192, 168, 1, 255},
<mask> }, {
<mask> name: "unspecified",
<mask> subnet: &net.IPNet{
<mask> IP: net.IP{0, 0, 0, 0},
<mask> Mask: net.IPMask{0, 0, 0, 0},
<mask> },
<mask> want: net.IPv4bcast,
<mask> }}
<mask>
<mask> for _, tc := range testCases {
<mask> t.Run(tc.name, func(t *testing.T) {
<mask> bc := BroadcastFromIPNet(tc.subnet)
<mask> assert.True(t, bc.Equal(tc.want), bc)
<mask> })
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove subnet: &net.IPNet{
IP: net.IP{192, 168, 1, 2},
},
want: net.IP{192, 168, 1, 255},
</s> add </s> remove subnet: &net.IPNet{
IP: net.IP{192, 168, 0, 1},
Mask: net.IPMask{255, 255, 15, 0},
},
want: net.IP{192, 168, 240, 255},
</s> add </s> remove name: "ipv6_no_mask",
subnet: &net.IPNet{
IP: known6,
},
</s> add pref: netip.PrefixFrom(known4, 20),
want: netip.MustParseAddr("192.168.15.255"),
name: "full",
}, {
pref: netip.PrefixFrom(known6, netutil.IPv6BitLen), </s> remove want: nil,
</s> add want: netip.Addr{},
name: "bad_code", </s> remove name: "bad_code",
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_test.go |
keep keep keep add keep keep keep keep | <mask> }
<mask> }
<mask>
<mask> func TestCheckPort(t *testing.T) {
<mask> t.Run("tcp_bound", func(t *testing.T) {
<mask> l, err := net.Listen("tcp", laddr.String())
<mask> require.NoError(t, err)
<mask> testutil.CleanupAndRequireSuccess(t, l.Close)
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove l, err := net.Listen("tcp", "127.0.0.1:")
</s> add l, err := net.Listen("tcp", laddr.String()) </s> remove conn, err := net.ListenPacket("udp", "127.0.0.1:")
</s> add conn, err := net.ListenPacket("udp", laddr.String()) </s> remove ipp := netutil.IPPortFromAddr(l.Addr())
require.NotNil(t, ipp)
require.NotNil(t, ipp.IP)
require.NotZero(t, ipp.Port)
</s> add addr := l.Addr()
require.IsType(t, new(net.TCPAddr), addr)
ipp := addr.(*net.TCPAddr).AddrPort()
require.Equal(t, laddr.Addr(), ipp.Addr())
require.NotZero(t, ipp.Port()) </s> remove bc := BroadcastFromIPNet(tc.subnet)
assert.True(t, bc.Equal(tc.want), bc)
</s> add assert.Equal(t, tc.want, BroadcastFromPref(tc.pref)) </s> remove err := CheckPort("udp", net.IP{0, 0, 0, 0}, 0)
</s> add err := CheckPort("udp", netip.AddrPortFrom(netip.IPv4Unspecified(), 0)) </s> remove err := CheckPort("bad_network", nil, 0)
</s> add err := CheckPort("bad_network", netip.AddrPortFrom(netip.Addr{}, 0)) | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_test.go |
keep keep keep keep replace keep keep keep replace replace replace replace keep | <mask> }
<mask>
<mask> func TestCheckPort(t *testing.T) {
<mask> t.Run("tcp_bound", func(t *testing.T) {
<mask> l, err := net.Listen("tcp", "127.0.0.1:")
<mask> require.NoError(t, err)
<mask> testutil.CleanupAndRequireSuccess(t, l.Close)
<mask>
<mask> ipp := netutil.IPPortFromAddr(l.Addr())
<mask> require.NotNil(t, ipp)
<mask> require.NotNil(t, ipp.IP)
<mask> require.NotZero(t, ipp.Port)
<mask>
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> add laddr := netip.AddrPortFrom(IPv4Localhost(), 0)
</s> remove ipp := netutil.IPPortFromAddr(conn.LocalAddr())
require.NotNil(t, ipp)
require.NotNil(t, ipp.IP)
require.NotZero(t, ipp.Port)
</s> add addr := conn.LocalAddr()
require.IsType(t, new(net.UDPAddr), addr)
ipp := addr.(*net.UDPAddr).AddrPort()
require.Equal(t, laddr.Addr(), ipp.Addr())
require.NotZero(t, ipp.Port()) </s> remove conn, err := net.ListenPacket("udp", "127.0.0.1:")
</s> add conn, err := net.ListenPacket("udp", laddr.String()) </s> remove err = CheckPort("udp", ipp.IP, ipp.Port)
</s> add err = CheckPort("udp", ipp) </s> remove err = CheckPort("tcp", ipp.IP, ipp.Port)
</s> add err = CheckPort("tcp", ipp) | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask> require.NotNil(t, ipp)
<mask> require.NotNil(t, ipp.IP)
<mask> require.NotZero(t, ipp.Port)
<mask>
<mask> err = CheckPort("tcp", ipp.IP, ipp.Port)
<mask> target := &net.OpError{}
<mask> require.ErrorAs(t, err, &target)
<mask>
<mask> assert.Equal(t, "listen", target.Op)
<mask> })
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove err = CheckPort("udp", ipp.IP, ipp.Port)
</s> add err = CheckPort("udp", ipp) </s> remove ipp := netutil.IPPortFromAddr(l.Addr())
require.NotNil(t, ipp)
require.NotNil(t, ipp.IP)
require.NotZero(t, ipp.Port)
</s> add addr := l.Addr()
require.IsType(t, new(net.TCPAddr), addr)
ipp := addr.(*net.TCPAddr).AddrPort()
require.Equal(t, laddr.Addr(), ipp.Addr())
require.NotZero(t, ipp.Port()) </s> remove ipp := netutil.IPPortFromAddr(conn.LocalAddr())
require.NotNil(t, ipp)
require.NotNil(t, ipp.IP)
require.NotZero(t, ipp.Port)
</s> add addr := conn.LocalAddr()
require.IsType(t, new(net.UDPAddr), addr)
ipp := addr.(*net.UDPAddr).AddrPort()
require.Equal(t, laddr.Addr(), ipp.Addr())
require.NotZero(t, ipp.Port()) </s> remove conn, err := net.ListenPacket("udp", "127.0.0.1:")
</s> add conn, err := net.ListenPacket("udp", laddr.String()) </s> remove err := CheckPort("bad_network", nil, 0)
</s> add err := CheckPort("bad_network", netip.AddrPortFrom(netip.Addr{}, 0)) </s> remove l, err := net.Listen("tcp", "127.0.0.1:")
</s> add l, err := net.Listen("tcp", laddr.String()) | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_test.go |
keep keep replace keep keep keep replace replace replace replace keep | <mask>
<mask> t.Run("udp_bound", func(t *testing.T) {
<mask> conn, err := net.ListenPacket("udp", "127.0.0.1:")
<mask> require.NoError(t, err)
<mask> testutil.CleanupAndRequireSuccess(t, conn.Close)
<mask>
<mask> ipp := netutil.IPPortFromAddr(conn.LocalAddr())
<mask> require.NotNil(t, ipp)
<mask> require.NotNil(t, ipp.IP)
<mask> require.NotZero(t, ipp.Port)
<mask>
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove ipp := netutil.IPPortFromAddr(l.Addr())
require.NotNil(t, ipp)
require.NotNil(t, ipp.IP)
require.NotZero(t, ipp.Port)
</s> add addr := l.Addr()
require.IsType(t, new(net.TCPAddr), addr)
ipp := addr.(*net.TCPAddr).AddrPort()
require.Equal(t, laddr.Addr(), ipp.Addr())
require.NotZero(t, ipp.Port()) </s> remove l, err := net.Listen("tcp", "127.0.0.1:")
</s> add l, err := net.Listen("tcp", laddr.String()) </s> remove err = CheckPort("udp", ipp.IP, ipp.Port)
</s> add err = CheckPort("udp", ipp) </s> remove err = CheckPort("tcp", ipp.IP, ipp.Port)
</s> add err = CheckPort("tcp", ipp) </s> add laddr := netip.AddrPortFrom(IPv4Localhost(), 0)
| https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask> require.NotNil(t, ipp)
<mask> require.NotNil(t, ipp.IP)
<mask> require.NotZero(t, ipp.Port)
<mask>
<mask> err = CheckPort("udp", ipp.IP, ipp.Port)
<mask> target := &net.OpError{}
<mask> require.ErrorAs(t, err, &target)
<mask>
<mask> assert.Equal(t, "listen", target.Op)
<mask> })
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove err = CheckPort("tcp", ipp.IP, ipp.Port)
</s> add err = CheckPort("tcp", ipp) </s> remove ipp := netutil.IPPortFromAddr(conn.LocalAddr())
require.NotNil(t, ipp)
require.NotNil(t, ipp.IP)
require.NotZero(t, ipp.Port)
</s> add addr := conn.LocalAddr()
require.IsType(t, new(net.UDPAddr), addr)
ipp := addr.(*net.UDPAddr).AddrPort()
require.Equal(t, laddr.Addr(), ipp.Addr())
require.NotZero(t, ipp.Port()) </s> remove ipp := netutil.IPPortFromAddr(l.Addr())
require.NotNil(t, ipp)
require.NotNil(t, ipp.IP)
require.NotZero(t, ipp.Port)
</s> add addr := l.Addr()
require.IsType(t, new(net.TCPAddr), addr)
ipp := addr.(*net.TCPAddr).AddrPort()
require.Equal(t, laddr.Addr(), ipp.Addr())
require.NotZero(t, ipp.Port()) </s> remove conn, err := net.ListenPacket("udp", "127.0.0.1:")
</s> add conn, err := net.ListenPacket("udp", laddr.String()) </s> remove err := CheckPort("bad_network", nil, 0)
</s> add err := CheckPort("bad_network", netip.AddrPortFrom(netip.Addr{}, 0)) </s> remove l, err := net.Listen("tcp", "127.0.0.1:")
</s> add l, err := net.Listen("tcp", laddr.String()) | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_test.go |
keep keep keep replace keep keep keep keep replace keep keep keep keep | <mask> })
<mask>
<mask> t.Run("bad_network", func(t *testing.T) {
<mask> err := CheckPort("bad_network", nil, 0)
<mask> assert.NoError(t, err)
<mask> })
<mask>
<mask> t.Run("can_bind", func(t *testing.T) {
<mask> err := CheckPort("udp", net.IP{0, 0, 0, 0}, 0)
<mask> assert.NoError(t, err)
<mask> })
<mask> }
<mask>
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> add laddr := netip.AddrPortFrom(IPv4Localhost(), 0)
</s> remove IP: anotherIP,
</s> add IP: anotherIP.AsSlice(), </s> remove conn, err := net.ListenPacket("udp", "127.0.0.1:")
</s> add conn, err := net.ListenPacket("udp", laddr.String()) </s> remove resp := discoverAnOffer(t, anotherName, anotherIP, staticMAC)
</s> add resp := discoverAnOffer(t, anotherName, anotherIP.AsSlice(), staticMAC) </s> remove IP: anotherIP,
</s> add IP: anotherIP.AsSlice(), | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_test.go |
keep keep keep replace replace keep keep replace replace replace replace replace replace replace replace keep keep | <mask> `"mtu":1500` +
<mask> `}` + "\n"
<mask>
<mask> ip4, ip6 := net.IP{1, 2, 3, 4}, net.IP{0xAA, 0xAA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}
<mask> mask4, mask6 := net.CIDRMask(24, netutil.IPv4BitLen), net.CIDRMask(8, netutil.IPv6BitLen)
<mask>
<mask> iface := &NetInterface{
<mask> Addresses: []net.IP{ip4, ip6},
<mask> Subnets: []*net.IPNet{{
<mask> IP: ip4.Mask(mask4),
<mask> Mask: mask4,
<mask> }, {
<mask> IP: ip6.Mask(mask6),
<mask> Mask: mask6,
<mask> }},
<mask> Name: "iface0",
<mask> HardwareAddr: net.HardwareAddr{0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF},
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove subnet: &net.IPNet{
IP: net.IP{192, 168, 1, 2},
},
want: net.IP{192, 168, 1, 255},
</s> add </s> remove subnet: &net.IPNet{
IP: net.IP{0, 0, 0, 0},
Mask: net.IPMask{0, 0, 0, 0},
},
want: net.IPv4bcast,
</s> add }, {
pref: netip.Prefix{},
want: netip.Addr{},
name: "invalid", </s> remove name: "success_v4",
</s> add </s> remove BindHost: net.IP{0, 0, 0, 0},
</s> add BindHost: netip.IPv4Unspecified(), </s> remove want: net.IP{1, 2, 3, 4}.To16(),
</s> add want: netip.MustParseAddr("1.2.3.4"),
name: "success_v4", | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/aghnet/net_test.go |
keep keep add keep keep keep keep keep keep | <mask> import (
<mask> "fmt"
<mask> "net"
<mask> "time"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghnet"
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> )
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> add "net/netip" </s> remove "net"
</s> add </s> add "net/netip" </s> remove "net"
</s> add "net/netip" </s> remove "net"
</s> add </s> add "net/netip" | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/config.go |
keep keep keep keep replace keep keep keep keep keep | <mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghnet"
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/golibs/netutil"
<mask> )
<mask>
<mask> // ServerConfig is the configuration for the DHCP server. The order of YAML
<mask> // fields is important, since the YAML configuration file follows it.
<mask> type ServerConfig struct {
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove // migration.
</s> add // migration. Also keep the blocked services in mind. </s> add "net/netip" </s> remove "github.com/AdguardTeam/golibs/netutil"
</s> add </s> remove subnet *net.IPNet
</s> add subnet netip.Prefix </s> remove BindHost net.IP `yaml:"bind_host"` // BindHost is the IP address of the HTTP server to bind to
BindPort int `yaml:"bind_port"` // BindPort is the port the HTTP server
BetaBindPort int `yaml:"beta_bind_port"` // BetaBindPort is the port for new client
Users []webUser `yaml:"users"` // Users that can access HTTP server
</s> add // BindHost is the address for the web interface server to listen on.
BindHost netip.Addr `yaml:"bind_host"`
// BindPort is the port for the web interface server to listen on.
BindPort int `yaml:"bind_port"`
// BetaBindPort is the port for the new client's web interface server to
// listen on.
BetaBindPort int `yaml:"beta_bind_port"`
// Users are the clients capable for accessing the web interface.
Users []webUser `yaml:"users"` </s> remove defaultIP := net.IP{192, 168, 1, 1}
</s> add defaultIP := netip.MustParseAddr("192.168.1.1") | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/config.go |
keep replace replace keep keep replace keep keep keep | <mask>
<mask> GatewayIP net.IP `yaml:"gateway_ip" json:"gateway_ip"`
<mask> SubnetMask net.IP `yaml:"subnet_mask" json:"subnet_mask"`
<mask> // broadcastIP is the broadcasting address pre-calculated from the
<mask> // configured gateway IP and subnet mask.
<mask> broadcastIP net.IP
<mask>
<mask> // The first & the last IP address for dynamic leases
<mask> // Bytes [0..2] of the last allowed IP address must match the first IP
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove RangeStart net.IP `yaml:"range_start" json:"range_start"`
RangeEnd net.IP `yaml:"range_end" json:"range_end"`
</s> add RangeStart netip.Addr `yaml:"range_start" json:"range_start"`
RangeEnd netip.Addr `yaml:"range_end" json:"range_end"` </s> remove subnet *net.IPNet
</s> add subnet netip.Prefix </s> remove return nil
</s> add return netip.Addr{} </s> remove return nil
</s> add return netip.Addr{} </s> remove dnsIPAddrs []net.IP // IPv4 addresses to return to DHCP clients as DNS server addresses
</s> add dnsIPAddrs []netip.Addr // IPv4 addresses to return to DHCP clients as DNS server addresses | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/config.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask> broadcastIP net.IP
<mask>
<mask> // The first & the last IP address for dynamic leases
<mask> // Bytes [0..2] of the last allowed IP address must match the first IP
<mask> RangeStart net.IP `yaml:"range_start" json:"range_start"`
<mask> RangeEnd net.IP `yaml:"range_end" json:"range_end"`
<mask>
<mask> LeaseDuration uint32 `yaml:"lease_duration" json:"lease_duration"` // in seconds
<mask>
<mask> // IP conflict detector: time (ms) to wait for ICMP reply
<mask> // 0: disable
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove broadcastIP net.IP
</s> add broadcastIP netip.Addr </s> remove GatewayIP net.IP `yaml:"gateway_ip" json:"gateway_ip"`
SubnetMask net.IP `yaml:"subnet_mask" json:"subnet_mask"`
</s> add GatewayIP netip.Addr `yaml:"gateway_ip" json:"gateway_ip"`
SubnetMask netip.Addr `yaml:"subnet_mask" json:"subnet_mask"` </s> remove GatewayIP net.IP `json:"gateway_ip"`
SubnetMask net.IP `json:"subnet_mask"`
RangeStart net.IP `json:"range_start"`
RangeEnd net.IP `json:"range_end"`
LeaseDuration uint32 `json:"lease_duration"`
</s> add GatewayIP netip.Addr `json:"gateway_ip"`
SubnetMask netip.Addr `json:"subnet_mask"`
RangeStart netip.Addr `json:"range_start"`
RangeEnd netip.Addr `json:"range_end"`
LeaseDuration uint32 `json:"lease_duration"` </s> remove dnsIPAddrs []net.IP // IPv4 addresses to return to DHCP clients as DNS server addresses
</s> add dnsIPAddrs []netip.Addr // IPv4 addresses to return to DHCP clients as DNS server addresses </s> remove subnet *net.IPNet
</s> add subnet netip.Prefix </s> remove return nil
</s> add return netip.Addr{} | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/config.go |
keep keep keep keep replace keep keep keep replace keep keep keep keep | <mask>
<mask> ipRange *ipRange
<mask>
<mask> leaseTime time.Duration // the time during which a dynamic lease is considered valid
<mask> dnsIPAddrs []net.IP // IPv4 addresses to return to DHCP clients as DNS server addresses
<mask>
<mask> // subnet contains the DHCP server's subnet. The IP is the IP of the
<mask> // gateway.
<mask> subnet *net.IPNet
<mask>
<mask> // notify is a way to signal to other components that leases have been
<mask> // changed. notify must be called outside of locked sections, since the
<mask> // clients might want to get the new data.
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove BindHost net.IP `yaml:"bind_host"` // BindHost is the IP address of the HTTP server to bind to
BindPort int `yaml:"bind_port"` // BindPort is the port the HTTP server
BetaBindPort int `yaml:"beta_bind_port"` // BetaBindPort is the port for new client
Users []webUser `yaml:"users"` // Users that can access HTTP server
</s> add // BindHost is the address for the web interface server to listen on.
BindHost netip.Addr `yaml:"bind_host"`
// BindPort is the port for the web interface server to listen on.
BindPort int `yaml:"bind_port"`
// BetaBindPort is the port for the new client's web interface server to
// listen on.
BetaBindPort int `yaml:"beta_bind_port"`
// Users are the clients capable for accessing the web interface.
Users []webUser `yaml:"users"` </s> remove if !s.conf.subnet.Contains(reqIP) {
</s> add if !s.conf.subnet.Contains(netip.AddrFrom4(*(*[4]byte)(ip4))) { </s> remove broadcastIP net.IP
</s> add broadcastIP netip.Addr </s> remove RangeStart net.IP `yaml:"range_start" json:"range_start"`
RangeEnd net.IP `yaml:"range_end" json:"range_end"`
</s> add RangeStart netip.Addr `yaml:"range_start" json:"range_start"`
RangeEnd netip.Addr `yaml:"range_end" json:"range_end"` </s> remove QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled
QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` // if true, query log will be written to a file
</s> add // QueryLogEnabled defines if the query log is enabled.
QueryLogEnabled bool `yaml:"querylog_enabled"`
// QueryLogFileEnabled defines, if the query log is written to the file.
QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/config.go |
keep keep keep keep replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep | <mask>
<mask> // errNilConfig is an error returned by validation method if the config is nil.
<mask> const errNilConfig errors.Error = "nil config"
<mask>
<mask> // ensureV4 returns a 4-byte version of ip. An error is returned if the passed
<mask> // ip is not an IPv4.
<mask> func ensureV4(ip net.IP) (ip4 net.IP, err error) {
<mask> if ip == nil {
<mask> return nil, fmt.Errorf("%v is not an IP address", ip)
<mask> }
<mask>
<mask> ip4 = ip.To4()
<mask> if ip4 == nil {
<mask> return nil, fmt.Errorf("%v is not an IPv4 address", ip)
<mask> }
<mask>
<mask> return ip4, nil
<mask> }
<mask>
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> add // IPv4Localhost returns 127.0.0.1, which returns true for [netip.Addr.Is4].
func IPv4Localhost() (ip netip.Addr) { return netip.AddrFrom4([4]byte{127, 0, 0, 1}) }
// IPv6Localhost returns ::1, which returns true for [netip.Addr.Is6].
func IPv6Localhost() (ip netip.Addr) { return netip.AddrFrom16([16]byte{15: 1}) }
</s> remove var gatewayIP net.IP
gatewayIP, err = ensureV4(c.GatewayIP)
</s> add gatewayIP, err := ensureV4(c.GatewayIP, "address") </s> remove // Don't wrap an errors since it's inforative enough as is and there is
</s> add // Don't wrap an errors since it's informative enough as is and there is </s> remove subnetMask := net.IPMask(netutil.CloneIP(c.SubnetMask.To4()))
c.subnet = &net.IPNet{
IP: gatewayIP,
Mask: subnetMask,
</s> add rangeStart, err := ensureV4(c.RangeStart, "address")
if err != nil {
// Don't wrap an errors since it's informative enough as is and there is
// an annotation deferred already.
return err
}
rangeEnd, err := ensureV4(c.RangeEnd, "address")
if err != nil {
// Don't wrap an errors since it's informative enough as is and there is
// an annotation deferred already.
return err </s> remove if c.SubnetMask == nil {
return fmt.Errorf("invalid subnet mask: %v", c.SubnetMask)
</s> add subnetMask, err := ensureV4(c.SubnetMask, "subnet mask")
if err != nil {
// Don't wrap an errors since it's informative enough as is and there is
// an annotation deferred already.
return err </s> remove // Don't wrap an errors since it's inforative enough as is and there is
</s> add // Don't wrap an errors since it's informative enough as is and there is | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/config.go |
keep replace replace keep replace keep keep | <mask>
<mask> var gatewayIP net.IP
<mask> gatewayIP, err = ensureV4(c.GatewayIP)
<mask> if err != nil {
<mask> // Don't wrap an errors since it's inforative enough as is and there is
<mask> // an annotation deferred already.
<mask> return err
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove // Don't wrap an errors since it's inforative enough as is and there is
</s> add // Don't wrap an errors since it's informative enough as is and there is </s> remove c.broadcastIP = aghnet.BroadcastFromIPNet(c.subnet)
</s> add </s> remove c.ipRange, err = newIPRange(c.RangeStart, c.RangeEnd)
</s> add c.ipRange, err = newIPRange(rangeStart.AsSlice(), rangeEnd.AsSlice()) </s> remove subnetMask := net.IPMask(netutil.CloneIP(c.SubnetMask.To4()))
c.subnet = &net.IPNet{
IP: gatewayIP,
Mask: subnetMask,
</s> add rangeStart, err := ensureV4(c.RangeStart, "address")
if err != nil {
// Don't wrap an errors since it's informative enough as is and there is
// an annotation deferred already.
return err
}
rangeEnd, err := ensureV4(c.RangeEnd, "address")
if err != nil {
// Don't wrap an errors since it's informative enough as is and there is
// an annotation deferred already.
return err </s> remove if c.SubnetMask == nil {
return fmt.Errorf("invalid subnet mask: %v", c.SubnetMask)
</s> add subnetMask, err := ensureV4(c.SubnetMask, "subnet mask")
if err != nil {
// Don't wrap an errors since it's informative enough as is and there is
// an annotation deferred already.
return err | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/config.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask> // an annotation deferred already.
<mask> return err
<mask> }
<mask>
<mask> if c.SubnetMask == nil {
<mask> return fmt.Errorf("invalid subnet mask: %v", c.SubnetMask)
<mask> }
<mask>
<mask> subnetMask := net.IPMask(netutil.CloneIP(c.SubnetMask.To4()))
<mask> c.subnet = &net.IPNet{
<mask> IP: gatewayIP,
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove subnetMask := net.IPMask(netutil.CloneIP(c.SubnetMask.To4()))
c.subnet = &net.IPNet{
IP: gatewayIP,
Mask: subnetMask,
</s> add rangeStart, err := ensureV4(c.RangeStart, "address")
if err != nil {
// Don't wrap an errors since it's informative enough as is and there is
// an annotation deferred already.
return err
}
rangeEnd, err := ensureV4(c.RangeEnd, "address")
if err != nil {
// Don't wrap an errors since it's informative enough as is and there is
// an annotation deferred already.
return err </s> remove c.broadcastIP = aghnet.BroadcastFromIPNet(c.subnet)
</s> add </s> remove // Don't wrap an errors since it's inforative enough as is and there is
</s> add // Don't wrap an errors since it's informative enough as is and there is </s> remove var gatewayIP net.IP
gatewayIP, err = ensureV4(c.GatewayIP)
</s> add gatewayIP, err := ensureV4(c.GatewayIP, "address") </s> remove if c.ipRange.contains(gatewayIP) {
</s> add if c.ipRange.contains(gatewayIP.AsSlice()) { </s> remove c.ipRange, err = newIPRange(c.RangeStart, c.RangeEnd)
</s> add c.ipRange, err = newIPRange(rangeStart.AsSlice(), rangeEnd.AsSlice()) | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/config.go |
keep add keep keep keep keep | <mask> return err
<mask> }
<mask>
<mask> rangeStart, err := ensureV4(c.RangeStart, "address")
<mask> if err != nil {
<mask> // Don't wrap an errors since it's informative enough as is and there is
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove subnetMask := net.IPMask(netutil.CloneIP(c.SubnetMask.To4()))
c.subnet = &net.IPNet{
IP: gatewayIP,
Mask: subnetMask,
</s> add rangeStart, err := ensureV4(c.RangeStart, "address")
if err != nil {
// Don't wrap an errors since it's informative enough as is and there is
// an annotation deferred already.
return err
}
rangeEnd, err := ensureV4(c.RangeEnd, "address")
if err != nil {
// Don't wrap an errors since it's informative enough as is and there is
// an annotation deferred already.
return err </s> remove // Don't wrap an errors since it's inforative enough as is and there is
</s> add // Don't wrap an errors since it's informative enough as is and there is </s> remove // Don't wrap an errors since it's inforative enough as is and there is
</s> add // Don't wrap an errors since it's informative enough as is and there is </s> remove var gatewayIP net.IP
gatewayIP, err = ensureV4(c.GatewayIP)
</s> add gatewayIP, err := ensureV4(c.GatewayIP, "address") </s> remove c.ipRange, err = newIPRange(c.RangeStart, c.RangeEnd)
</s> add c.ipRange, err = newIPRange(rangeStart.AsSlice(), rangeEnd.AsSlice()) </s> remove if c.SubnetMask == nil {
return fmt.Errorf("invalid subnet mask: %v", c.SubnetMask)
</s> add subnetMask, err := ensureV4(c.SubnetMask, "subnet mask")
if err != nil {
// Don't wrap an errors since it's informative enough as is and there is
// an annotation deferred already.
return err | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/config.go |
keep keep replace replace replace replace keep replace keep keep | <mask> }
<mask>
<mask> subnetMask := net.IPMask(netutil.CloneIP(c.SubnetMask.To4()))
<mask> c.subnet = &net.IPNet{
<mask> IP: gatewayIP,
<mask> Mask: subnetMask,
<mask> }
<mask> c.broadcastIP = aghnet.BroadcastFromIPNet(c.subnet)
<mask>
<mask> c.ipRange, err = newIPRange(c.RangeStart, c.RangeEnd)
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove c.ipRange, err = newIPRange(c.RangeStart, c.RangeEnd)
</s> add c.ipRange, err = newIPRange(rangeStart.AsSlice(), rangeEnd.AsSlice()) </s> remove if c.SubnetMask == nil {
return fmt.Errorf("invalid subnet mask: %v", c.SubnetMask)
</s> add subnetMask, err := ensureV4(c.SubnetMask, "subnet mask")
if err != nil {
// Don't wrap an errors since it's informative enough as is and there is
// an annotation deferred already.
return err </s> remove // Don't wrap an errors since it's inforative enough as is and there is
</s> add // Don't wrap an errors since it's informative enough as is and there is </s> remove subnet = &net.IPNet{
IP: a.IP,
Mask: a.IP.DefaultMask(),
}
</s> add ip = a.IP
maskLen, _ = ip.DefaultMask().Size() </s> add maskLen, _ := net.IPMask(subnetMask.AsSlice()).Size()
c.subnet = netip.PrefixFrom(gatewayIP, maskLen)
c.broadcastIP = aghnet.BroadcastFromPref(c.subnet) | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/config.go |
keep keep keep keep replace keep replace keep keep keep keep | <mask> Mask: subnetMask,
<mask> }
<mask> c.broadcastIP = aghnet.BroadcastFromIPNet(c.subnet)
<mask>
<mask> c.ipRange, err = newIPRange(c.RangeStart, c.RangeEnd)
<mask> if err != nil {
<mask> // Don't wrap an errors since it's inforative enough as is and there is
<mask> // an annotation deferred already.
<mask> return err
<mask> }
<mask>
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove c.broadcastIP = aghnet.BroadcastFromIPNet(c.subnet)
</s> add </s> remove subnetMask := net.IPMask(netutil.CloneIP(c.SubnetMask.To4()))
c.subnet = &net.IPNet{
IP: gatewayIP,
Mask: subnetMask,
</s> add rangeStart, err := ensureV4(c.RangeStart, "address")
if err != nil {
// Don't wrap an errors since it's informative enough as is and there is
// an annotation deferred already.
return err
}
rangeEnd, err := ensureV4(c.RangeEnd, "address")
if err != nil {
// Don't wrap an errors since it's informative enough as is and there is
// an annotation deferred already.
return err </s> remove // Don't wrap an errors since it's inforative enough as is and there is
</s> add // Don't wrap an errors since it's informative enough as is and there is </s> remove var gatewayIP net.IP
gatewayIP, err = ensureV4(c.GatewayIP)
</s> add gatewayIP, err := ensureV4(c.GatewayIP, "address") </s> remove if c.SubnetMask == nil {
return fmt.Errorf("invalid subnet mask: %v", c.SubnetMask)
</s> add subnetMask, err := ensureV4(c.SubnetMask, "subnet mask")
if err != nil {
// Don't wrap an errors since it's informative enough as is and there is
// an annotation deferred already.
return err | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/config.go |
keep keep keep keep replace keep keep keep keep keep | <mask> // an annotation deferred already.
<mask> return err
<mask> }
<mask>
<mask> if c.ipRange.contains(gatewayIP) {
<mask> return fmt.Errorf("gateway ip %v in the ip range: %v-%v",
<mask> gatewayIP,
<mask> c.RangeStart,
<mask> c.RangeEnd,
<mask> )
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove if c.SubnetMask == nil {
return fmt.Errorf("invalid subnet mask: %v", c.SubnetMask)
</s> add subnetMask, err := ensureV4(c.SubnetMask, "subnet mask")
if err != nil {
// Don't wrap an errors since it's informative enough as is and there is
// an annotation deferred already.
return err </s> remove if !c.subnet.Contains(c.RangeStart) {
</s> add if !c.subnet.Contains(rangeStart) { </s> remove var gatewayIP net.IP
gatewayIP, err = ensureV4(c.GatewayIP)
</s> add gatewayIP, err := ensureV4(c.GatewayIP, "address") </s> remove // Don't wrap an errors since it's inforative enough as is and there is
</s> add // Don't wrap an errors since it's informative enough as is and there is </s> remove subnetMask := net.IPMask(netutil.CloneIP(c.SubnetMask.To4()))
c.subnet = &net.IPNet{
IP: gatewayIP,
Mask: subnetMask,
</s> add rangeStart, err := ensureV4(c.RangeStart, "address")
if err != nil {
// Don't wrap an errors since it's informative enough as is and there is
// an annotation deferred already.
return err
}
rangeEnd, err := ensureV4(c.RangeEnd, "address")
if err != nil {
// Don't wrap an errors since it's informative enough as is and there is
// an annotation deferred already.
return err </s> remove // Don't wrap an errors since it's inforative enough as is and there is
</s> add // Don't wrap an errors since it's informative enough as is and there is | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/config.go |
keep keep keep keep replace keep keep keep keep keep | <mask> c.RangeEnd,
<mask> )
<mask> }
<mask>
<mask> if !c.subnet.Contains(c.RangeStart) {
<mask> return fmt.Errorf("range start %v is outside network %v",
<mask> c.RangeStart,
<mask> c.subnet,
<mask> )
<mask> }
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove if !c.subnet.Contains(c.RangeEnd) {
</s> add if !c.subnet.Contains(rangeEnd) { </s> remove if c.ipRange.contains(gatewayIP) {
</s> add if c.ipRange.contains(gatewayIP.AsSlice()) { </s> remove gatewayIP: net.IP{192, 168, 10, 1},
subnetMask: net.IP{255, 255, 255, 240},
</s> add </s> remove name: "outside_range_start",
</s> add name: "outside_range_start",
gatewayIP: netip.MustParseAddr("192.168.10.1"),
subnetMask: netip.MustParseAddr("255.255.255.240"), </s> remove gatewayIP: net.IP{192, 168, 10, 120},
subnetMask: net.IP{255, 255, 255, 0},
</s> add </s> remove return nil
</s> add return p | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/config.go |
keep keep keep keep replace keep keep keep keep keep | <mask> c.subnet,
<mask> )
<mask> }
<mask>
<mask> if !c.subnet.Contains(c.RangeEnd) {
<mask> return fmt.Errorf("range end %v is outside network %v",
<mask> c.RangeEnd,
<mask> c.subnet,
<mask> )
<mask> }
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove if !c.subnet.Contains(c.RangeStart) {
</s> add if !c.subnet.Contains(rangeStart) { </s> remove if c.ipRange.contains(gatewayIP) {
</s> add if c.ipRange.contains(gatewayIP.AsSlice()) { </s> remove gatewayIP: net.IP{192, 168, 10, 1},
subnetMask: net.IP{255, 255, 255, 240},
</s> add </s> remove gatewayIP: net.IP{192, 168, 10, 1},
subnetMask: net.IP{255, 255, 255, 224},
</s> add </s> remove name: "outside_range_end",
</s> add name: "outside_range_end",
gatewayIP: netip.MustParseAddr("192.168.10.1"),
subnetMask: netip.MustParseAddr("255.255.255.224"), </s> remove return nil
</s> add return p | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/config.go |
keep keep replace keep keep replace keep keep keep | <mask> return &dhcpConn{
<mask> udpConn: bcast,
<mask> bcastIP: s.conf.broadcastIP,
<mask> rawConn: ucast,
<mask> srcMAC: iface.HardwareAddr,
<mask> srcIP: s.conf.dnsIPAddrs[0],
<mask> }, nil
<mask> }
<mask>
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove netIface := &NetInterface{
MTU: iface.MTU,
Name: iface.Name,
HardwareAddr: iface.HardwareAddr,
Flags: iface.Flags,
</s> add ip, ok := netip.AddrFromSlice(n.IP)
if !ok {
return nil, fmt.Errorf("bad address %s", n.IP) </s> remove if o.bindHost == nil {
</s> add if !o.bindHost.IsValid() { </s> remove updateWithValue: func(o options, v string) (options, error) {
o.bindHost = net.ParseIP(v)
return o, nil
</s> add updateWithValue: func(o options, v string) (oo options, err error) {
o.bindHost, err = netip.ParseAddr(v)
return o, err </s> remove // GetValidNetInterfacesForWeb returns interfaces that are eligible for DNS and
// WEB only we do not return link-local addresses here.
//
// TODO(e.burkov): Can't properly test the function since it's nontrivial to
// substitute net.Interface.Addrs and the net.InterfaceAddrs can't be used.
func GetValidNetInterfacesForWeb() (netIfaces []*NetInterface, err error) {
ifaces, err := net.Interfaces()
</s> add func NetInterfaceFrom(iface *net.Interface) (niface *NetInterface, err error) {
niface = &NetInterface{
Name: iface.Name,
HardwareAddr: iface.HardwareAddr,
Flags: iface.Flags,
MTU: iface.MTU,
}
addrs, err := iface.Addrs() </s> remove // Collect network interface addresses.
for _, addr := range addrs {
ipNet, ok := addr.(*net.IPNet)
if !ok {
// Should be net.IPNet, this is weird.
return nil, fmt.Errorf("got %s that is not net.IPNet, it is %T", addr, addr)
}
// Ignore link-local.
if ipNet.IP.IsLinkLocalUnicast() {
</s> add ip = ip.Unmap()
if ip.IsLinkLocalUnicast() {
// Ignore link-local IPv4.
if ip.Is4() { | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/conn_unix.go |
keep keep keep keep replace keep keep keep keep keep | <mask>
<mask> v4conf := conf.Conf4
<mask> v4conf.InterfaceName = s.conf.InterfaceName
<mask> v4conf.notify = s.onNotify
<mask> v4conf.Enabled = s.conf.Enabled && len(v4conf.RangeStart) != 0
<mask>
<mask> s.srv4, err = v4Create(&v4conf)
<mask> if err != nil {
<mask> if v4conf.Enabled {
<mask> return nil, fmt.Errorf("creating dhcpv4 srv: %w", err)
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove restartHTTP = !config.BindHost.Equal(req.Web.IP) || config.BindPort != req.Web.Port
</s> add restartHTTP = config.BindHost != req.Web.IP || config.BindPort != req.Web.Port </s> remove return nil, fmt.Errorf("couldn't get interfaces: %w", err)
} else if len(ifaces) == 0 {
return nil, errors.Error("couldn't find any legible interface")
</s> add return nil, fmt.Errorf("failed to get addresses for interface %s: %w", iface.Name, err) </s> remove err = aghnet.CheckPort("tcp", req.Web.IP, req.Web.Port)
</s> add err = aghnet.CheckPort("tcp", netip.AddrPortFrom(req.Web.IP, uint16(req.Web.Port))) </s> remove // Discard interfaces with no addresses.
if len(netIface.Addresses) != 0 {
netIfaces = append(netIfaces, netIface)
</s> add ones, _ := n.Mask.Size()
p := netip.PrefixFrom(ip, ones)
niface.Addresses = append(niface.Addresses, ip)
niface.Subnets = append(niface.Subnets, p)
}
return niface, nil
}
// GetValidNetInterfacesForWeb returns interfaces that are eligible for DNS and
// WEB only we do not return link-local addresses here.
//
// TODO(e.burkov): Can't properly test the function since it's nontrivial to
// substitute net.Interface.Addrs and the net.InterfaceAddrs can't be used.
func GetValidNetInterfacesForWeb() (nifaces []*NetInterface, err error) {
ifaces, err := net.Interfaces()
if err != nil {
return nil, fmt.Errorf("getting interfaces: %w", err)
} else if len(ifaces) == 0 {
return nil, errors.Error("no legible interfaces")
}
for i := range ifaces {
var niface *NetInterface
niface, err = NetInterfaceFrom(&ifaces[i])
if err != nil {
return nil, err
} else if len(niface.Addresses) != 0 {
// Discard interfaces with no addresses.
nifaces = append(nifaces, niface) </s> remove if opts.bindHost != nil {
</s> add if opts.bindHost.IsValid() { </s> remove addrs = appendDNSAddrs(addrs, net.IP{127, 0, 0, 1})
</s> add addr := aghnet.IPv4Localhost()
addrs = appendDNSAddrs(addrs, addr) | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/dhcpd.go |
keep keep keep add keep keep keep keep | <mask> package dhcpd
<mask>
<mask> import (
<mask> "net"
<mask> "os"
<mask> "testing"
<mask> "time"
<mask>
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> add "net/netip" </s> remove "net"
</s> add "net/netip" </s> remove "net"
</s> add </s> remove "net"
</s> add "net/netip" </s> remove "net"
</s> add </s> add "net/netip" | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/dhcpd_unix_test.go |
keep keep keep keep replace replace replace replace keep keep keep keep keep | <mask> }
<mask>
<mask> s.srv4, err = v4Create(&V4ServerConf{
<mask> Enabled: true,
<mask> RangeStart: net.IP{192, 168, 10, 100},
<mask> RangeEnd: net.IP{192, 168, 10, 200},
<mask> GatewayIP: net.IP{192, 168, 10, 1},
<mask> SubnetMask: net.IP{255, 255, 255, 0},
<mask> notify: testNotify,
<mask> })
<mask> require.NoError(t, err)
<mask>
<mask> s.srv6, err = v6Create(V6ServerConf{})
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove RangeStart: net.IP{192, 168, 10, 20},
RangeEnd: net.IP{192, 168, 10, 200},
</s> add RangeStart: netip.MustParseAddr("192.168.10.20"),
RangeEnd: netip.MustParseAddr("192.168.10.200"), </s> remove GatewayIP: net.IP{1, 2, 3, 1},
SubnetMask: net.IP{255, 255, 255, 0},
RangeStart: net.IP{1, 2, 3, 2},
RangeEnd: net.IP{1, 2, 3, 10},
</s> add GatewayIP: netip.MustParseAddr("1.2.3.1"),
SubnetMask: netip.MustParseAddr("255.255.255.0"),
RangeStart: netip.MustParseAddr("1.2.3.2"),
RangeEnd: netip.MustParseAddr("1.2.3.10"), </s> remove name: "outside_range_start",
</s> add name: "outside_range_start",
gatewayIP: netip.MustParseAddr("192.168.10.1"),
subnetMask: netip.MustParseAddr("255.255.255.240"), </s> remove name: "outside_range_end",
</s> add name: "outside_range_end",
gatewayIP: netip.MustParseAddr("192.168.10.1"),
subnetMask: netip.MustParseAddr("255.255.255.224"), </s> remove DefaultRangeStart = net.IP{192, 168, 10, 100}
DefaultRangeEnd = net.IP{192, 168, 10, 200}
DefaultGatewayIP = net.IP{192, 168, 10, 1}
DefaultSelfIP = net.IP{192, 168, 10, 2}
DefaultSubnetMask = net.IP{255, 255, 255, 0}
</s> add DefaultRangeStart = netip.MustParseAddr("192.168.10.100")
DefaultRangeEnd = netip.MustParseAddr("192.168.10.200")
DefaultGatewayIP = netip.MustParseAddr("192.168.10.1")
DefaultSelfIP = netip.MustParseAddr("192.168.10.2")
DefaultSubnetMask = netip.MustParseAddr("255.255.255.0") </s> remove gatewayIP: net.IP{192, 168, 10, 120},
subnetMask: net.IP{255, 255, 255, 0},
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/dhcpd_unix_test.go |
keep add keep keep keep keep keep keep | <mask> testCases := []struct {
<mask> name string
<mask> wantErrMsg string
<mask> }{{
<mask> name: "gateway_in_range",
<mask> gatewayIP: netip.MustParseAddr("192.168.10.120"),
<mask> subnetMask: netip.MustParseAddr("255.255.255.0"),
<mask> wantErrMsg: "dhcpv4: gateway ip 192.168.10.120 in the ip range: " +
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove name: "gateway_in_range",
</s> add name: "gateway_in_range",
gatewayIP: netip.MustParseAddr("192.168.10.120"),
subnetMask: netip.MustParseAddr("255.255.255.0"), </s> remove gatewayIP net.IP
subnetMask net.IP
</s> add </s> remove gatewayIP: net.IP{192, 168, 10, 120},
subnetMask: net.IP{255, 255, 255, 0},
</s> add </s> remove gatewayIP: net.IP{192, 168, 10, 1},
subnetMask: net.IP{255, 255, 255, 240},
</s> add </s> remove name string
</s> add </s> remove name: "outside_range_start",
</s> add name: "outside_range_start",
gatewayIP: netip.MustParseAddr("192.168.10.1"),
subnetMask: netip.MustParseAddr("255.255.255.240"), | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/dhcpd_unix_test.go |
keep keep keep keep replace replace keep replace keep keep keep | <mask> func TestV4Server_badRange(t *testing.T) {
<mask> testCases := []struct {
<mask> name string
<mask> wantErrMsg string
<mask> gatewayIP net.IP
<mask> subnetMask net.IP
<mask> }{{
<mask> name: "gateway_in_range",
<mask> wantErrMsg: "dhcpv4: gateway ip 192.168.10.120 in the ip range: " +
<mask> "192.168.10.20-192.168.10.200",
<mask> gatewayIP: net.IP{192, 168, 10, 120},
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> add gatewayIP netip.Addr
subnetMask netip.Addr </s> remove gatewayIP: net.IP{192, 168, 10, 120},
subnetMask: net.IP{255, 255, 255, 0},
</s> add </s> remove name: "outside_range_start",
</s> add name: "outside_range_start",
gatewayIP: netip.MustParseAddr("192.168.10.1"),
subnetMask: netip.MustParseAddr("255.255.255.240"), </s> remove gatewayIP: net.IP{192, 168, 10, 1},
subnetMask: net.IP{255, 255, 255, 240},
</s> add </s> remove name string
subnet *net.IPNet
want net.IP
</s> add pref netip.Prefix
want netip.Addr
name string | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/dhcpd_unix_test.go |
keep replace replace keep replace keep | <mask> "192.168.10.20-192.168.10.200",
<mask> gatewayIP: net.IP{192, 168, 10, 120},
<mask> subnetMask: net.IP{255, 255, 255, 0},
<mask> }, {
<mask> name: "outside_range_start",
<mask> wantErrMsg: "dhcpv4: range start 192.168.10.20 is outside network " +
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove gatewayIP: net.IP{192, 168, 10, 1},
subnetMask: net.IP{255, 255, 255, 240},
</s> add </s> remove name: "outside_range_end",
</s> add name: "outside_range_end",
gatewayIP: netip.MustParseAddr("192.168.10.1"),
subnetMask: netip.MustParseAddr("255.255.255.224"), </s> remove name: "gateway_in_range",
</s> add name: "gateway_in_range",
gatewayIP: netip.MustParseAddr("192.168.10.120"),
subnetMask: netip.MustParseAddr("255.255.255.0"), </s> remove gatewayIP: net.IP{192, 168, 10, 1},
subnetMask: net.IP{255, 255, 255, 224},
</s> add </s> remove gatewayIP net.IP
subnetMask net.IP
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/dhcpd_unix_test.go |
keep replace replace keep replace keep keep | <mask> "192.168.10.1/28",
<mask> gatewayIP: net.IP{192, 168, 10, 1},
<mask> subnetMask: net.IP{255, 255, 255, 240},
<mask> }, {
<mask> name: "outside_range_end",
<mask> wantErrMsg: "dhcpv4: range end 192.168.10.200 is outside network " +
<mask> "192.168.10.1/27",
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove name: "outside_range_start",
</s> add name: "outside_range_start",
gatewayIP: netip.MustParseAddr("192.168.10.1"),
subnetMask: netip.MustParseAddr("255.255.255.240"), </s> remove gatewayIP: net.IP{192, 168, 10, 1},
subnetMask: net.IP{255, 255, 255, 224},
</s> add </s> remove gatewayIP: net.IP{192, 168, 10, 120},
subnetMask: net.IP{255, 255, 255, 0},
</s> add </s> remove name: "gateway_in_range",
</s> add name: "gateway_in_range",
gatewayIP: netip.MustParseAddr("192.168.10.120"),
subnetMask: netip.MustParseAddr("255.255.255.0"), </s> remove gatewayIP net.IP
subnetMask net.IP
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/dhcpd_unix_test.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask> }, {
<mask> name: "outside_range_end",
<mask> wantErrMsg: "dhcpv4: range end 192.168.10.200 is outside network " +
<mask> "192.168.10.1/27",
<mask> gatewayIP: net.IP{192, 168, 10, 1},
<mask> subnetMask: net.IP{255, 255, 255, 224},
<mask> }}
<mask>
<mask> for _, tc := range testCases {
<mask> t.Run(tc.name, func(t *testing.T) {
<mask> conf := V4ServerConf{
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove name: "outside_range_end",
</s> add name: "outside_range_end",
gatewayIP: netip.MustParseAddr("192.168.10.1"),
subnetMask: netip.MustParseAddr("255.255.255.224"), </s> remove gatewayIP: net.IP{192, 168, 10, 1},
subnetMask: net.IP{255, 255, 255, 240},
</s> add </s> remove name: "outside_range_start",
</s> add name: "outside_range_start",
gatewayIP: netip.MustParseAddr("192.168.10.1"),
subnetMask: netip.MustParseAddr("255.255.255.240"), </s> remove gatewayIP: net.IP{192, 168, 10, 120},
subnetMask: net.IP{255, 255, 255, 0},
</s> add </s> remove name: "gateway_in_range",
</s> add name: "gateway_in_range",
gatewayIP: netip.MustParseAddr("192.168.10.120"),
subnetMask: netip.MustParseAddr("255.255.255.0"), </s> remove RangeStart: net.IP{192, 168, 10, 20},
RangeEnd: net.IP{192, 168, 10, 200},
</s> add RangeStart: netip.MustParseAddr("192.168.10.20"),
RangeEnd: netip.MustParseAddr("192.168.10.200"), | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/dhcpd_unix_test.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask> for _, tc := range testCases {
<mask> t.Run(tc.name, func(t *testing.T) {
<mask> conf := V4ServerConf{
<mask> Enabled: true,
<mask> RangeStart: net.IP{192, 168, 10, 20},
<mask> RangeEnd: net.IP{192, 168, 10, 200},
<mask> GatewayIP: tc.gatewayIP,
<mask> SubnetMask: tc.subnetMask,
<mask> notify: testNotify,
<mask> }
<mask>
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove RangeStart: net.IP{192, 168, 10, 100},
RangeEnd: net.IP{192, 168, 10, 200},
GatewayIP: net.IP{192, 168, 10, 1},
SubnetMask: net.IP{255, 255, 255, 0},
</s> add RangeStart: netip.MustParseAddr("192.168.10.100"),
RangeEnd: netip.MustParseAddr("192.168.10.200"),
GatewayIP: netip.MustParseAddr("192.168.10.1"),
SubnetMask: netip.MustParseAddr("255.255.255.0"), </s> remove gatewayIP: net.IP{192, 168, 10, 1},
subnetMask: net.IP{255, 255, 255, 224},
</s> add </s> remove GatewayIP: net.IP{1, 2, 3, 1},
SubnetMask: net.IP{255, 255, 255, 0},
RangeStart: net.IP{1, 2, 3, 2},
RangeEnd: net.IP{1, 2, 3, 10},
</s> add GatewayIP: netip.MustParseAddr("1.2.3.1"),
SubnetMask: netip.MustParseAddr("255.255.255.0"),
RangeStart: netip.MustParseAddr("1.2.3.2"),
RangeEnd: netip.MustParseAddr("1.2.3.10"), </s> remove subnet: &net.IPNet{
IP: net.IP{0, 0, 0, 0},
Mask: net.IPMask{0, 0, 0, 0},
},
want: net.IPv4bcast,
</s> add }, {
pref: netip.Prefix{},
want: netip.Addr{},
name: "invalid", </s> remove bc := BroadcastFromIPNet(tc.subnet)
assert.True(t, bc.Equal(tc.want), bc)
</s> add assert.Equal(t, tc.want, BroadcastFromPref(tc.pref)) </s> remove DefaultRangeStart = net.IP{192, 168, 10, 100}
DefaultRangeEnd = net.IP{192, 168, 10, 200}
DefaultGatewayIP = net.IP{192, 168, 10, 1}
DefaultSelfIP = net.IP{192, 168, 10, 2}
DefaultSubnetMask = net.IP{255, 255, 255, 0}
</s> add DefaultRangeStart = netip.MustParseAddr("192.168.10.100")
DefaultRangeEnd = netip.MustParseAddr("192.168.10.200")
DefaultGatewayIP = netip.MustParseAddr("192.168.10.1")
DefaultSelfIP = netip.MustParseAddr("192.168.10.2")
DefaultSubnetMask = netip.MustParseAddr("255.255.255.0") | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/dhcpd_unix_test.go |
keep add keep keep keep keep keep keep | <mask> "net"
<mask> "net/http"
<mask> "os"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghalg"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghnet"
<mask> "github.com/AdguardTeam/golibs/errors"
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> add "net/netip" </s> add "net/netip" </s> remove "net"
</s> add "net/netip" </s> add "net/netip" </s> remove "net"
</s> add </s> add "net/netip" | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/http_unix.go |
keep keep keep keep replace replace replace replace replace keep keep keep keep keep | <mask> "github.com/AdguardTeam/golibs/log"
<mask> )
<mask>
<mask> type v4ServerConfJSON struct {
<mask> GatewayIP net.IP `json:"gateway_ip"`
<mask> SubnetMask net.IP `json:"subnet_mask"`
<mask> RangeStart net.IP `json:"range_start"`
<mask> RangeEnd net.IP `json:"range_end"`
<mask> LeaseDuration uint32 `json:"lease_duration"`
<mask> }
<mask>
<mask> func (j *v4ServerConfJSON) toServerConf() *V4ServerConf {
<mask> if j == nil {
<mask> return &V4ServerConf{}
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove RangeStart net.IP `json:"range_start"`
LeaseDuration uint32 `json:"lease_duration"`
</s> add RangeStart netip.Addr `json:"range_start"`
LeaseDuration uint32 `json:"lease_duration"` </s> remove GatewayIP net.IP `yaml:"gateway_ip" json:"gateway_ip"`
SubnetMask net.IP `yaml:"subnet_mask" json:"subnet_mask"`
</s> add GatewayIP netip.Addr `yaml:"gateway_ip" json:"gateway_ip"`
SubnetMask netip.Addr `yaml:"subnet_mask" json:"subnet_mask"` </s> remove broadcastIP net.IP
</s> add broadcastIP netip.Addr </s> remove RangeStart net.IP `yaml:"range_start" json:"range_start"`
RangeEnd net.IP `yaml:"range_end" json:"range_end"`
</s> add RangeStart netip.Addr `yaml:"range_start" json:"range_start"`
RangeEnd netip.Addr `yaml:"range_end" json:"range_end"` </s> remove Name string `json:"name"`
HardwareAddr string `json:"hardware_address"`
Flags string `json:"flags"`
GatewayIP net.IP `json:"gateway_ip"`
Addrs4 []net.IP `json:"ipv4_addresses"`
Addrs6 []net.IP `json:"ipv6_addresses"`
</s> add Name string `json:"name"`
HardwareAddr string `json:"hardware_address"`
Flags string `json:"flags"`
GatewayIP netip.Addr `json:"gateway_ip"`
Addrs4 []netip.Addr `json:"ipv4_addresses"`
Addrs6 []netip.Addr `json:"ipv6_addresses"` </s> remove IP net.IP `json:"ip"`
Port int `json:"port"`
</s> add IP netip.Addr `json:"ip"`
Port int `json:"port"` | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/http_unix.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask> }
<mask> }
<mask>
<mask> type v6ServerConfJSON struct {
<mask> RangeStart net.IP `json:"range_start"`
<mask> LeaseDuration uint32 `json:"lease_duration"`
<mask> }
<mask>
<mask> func v6JSONToServerConf(j *v6ServerConfJSON) V6ServerConf {
<mask> if j == nil {
<mask> return V6ServerConf{}
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove GatewayIP net.IP `json:"gateway_ip"`
SubnetMask net.IP `json:"subnet_mask"`
RangeStart net.IP `json:"range_start"`
RangeEnd net.IP `json:"range_end"`
LeaseDuration uint32 `json:"lease_duration"`
</s> add GatewayIP netip.Addr `json:"gateway_ip"`
SubnetMask netip.Addr `json:"subnet_mask"`
RangeStart netip.Addr `json:"range_start"`
RangeEnd netip.Addr `json:"range_end"`
LeaseDuration uint32 `json:"lease_duration"` </s> remove IP net.IP `json:"ip"`
Port int `json:"port"`
</s> add IP netip.Addr `json:"ip"`
Port int `json:"port"` </s> remove IP net.IP `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"`
</s> add IP netip.Addr `json:"ip"`
Port int `json:"port"`
Autofix bool `json:"autofix"` </s> remove RangeStart net.IP `yaml:"range_start" json:"range_start"`
RangeEnd net.IP `yaml:"range_end" json:"range_end"`
</s> add RangeStart netip.Addr `yaml:"range_start" json:"range_start"`
RangeEnd netip.Addr `yaml:"range_end" json:"range_end"` </s> remove func ipsToUDPAddrs(ips []net.IP, port int) (udpAddrs []*net.UDPAddr) {
</s> add func ipsToUDPAddrs(ips []netip.Addr, port int) (udpAddrs []*net.UDPAddr) { </s> remove func ipsToTCPAddrs(ips []net.IP, port int) (tcpAddrs []*net.TCPAddr) {
</s> add func ipsToTCPAddrs(ips []netip.Addr, port int) (tcpAddrs []*net.TCPAddr) { | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/http_unix.go |
keep keep keep keep replace keep keep keep keep keep | <mask> return V6ServerConf{}
<mask> }
<mask>
<mask> return V6ServerConf{
<mask> RangeStart: j.RangeStart,
<mask> LeaseDuration: j.LeaseDuration,
<mask> }
<mask> }
<mask>
<mask> // dhcpStatusResponse is the response for /control/dhcp/status endpoint.
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove return nil, fmt.Errorf("interface %s has no ipv4 addresses", iface.Name)
</s> add return netip.Prefix{}, fmt.Errorf("interface %s has no ipv4 addresses", iface.Name) </s> remove var subnet *net.IPNet
</s> add var subnet netip.Prefix </s> remove RangeStart: net.IP{192, 168, 10, 20},
RangeEnd: net.IP{192, 168, 10, 200},
</s> add RangeStart: netip.MustParseAddr("192.168.10.20"),
RangeEnd: netip.MustParseAddr("192.168.10.200"), </s> remove RangeStart net.IP `json:"range_start"`
LeaseDuration uint32 `json:"lease_duration"`
</s> add RangeStart netip.Addr `json:"range_start"`
LeaseDuration uint32 `json:"lease_duration"` </s> remove return nil
</s> add return p </s> remove if !s.conf.subnet.Contains(reqIP) {
</s> add if !s.conf.subnet.Contains(netip.AddrFrom4(*(*[4]byte)(ip4))) { | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/http_unix.go |
keep keep keep keep replace keep keep keep keep keep | <mask> }
<mask>
<mask> v4Conf := conf.V4.toServerConf()
<mask> v4Conf.Enabled = conf.Enabled == aghalg.NBTrue
<mask> if len(v4Conf.RangeStart) == 0 {
<mask> v4Conf.Enabled = false
<mask> }
<mask>
<mask> v4Conf.InterfaceName = conf.InterfaceName
<mask>
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove restartHTTP = !config.BindHost.Equal(req.Web.IP) || config.BindPort != req.Web.Port
</s> add restartHTTP = config.BindHost != req.Web.IP || config.BindPort != req.Web.Port </s> remove hosts = []net.IP{{127, 0, 0, 1}}
</s> add hosts = []netip.Addr{aghnet.IPv4Localhost()} </s> remove if o.bindHost == nil {
</s> add if !o.bindHost.IsValid() { </s> remove mask := n.Mask
if mask == nil {
mask = dc.DefaultMask()
</s> add maskLen, addrLen := p.Bits(), bc.BitLen()
if maskLen == addrLen {
return bc </s> remove if ip4 := reqIP.To4(); ip4 == nil {
</s> add ip4 := reqIP.To4()
if ip4 == nil { </s> remove s.conf.dnsIPAddrs = dnsIPAddrs
</s> add for _, ip := range dnsIPAddrs {
ip = ip.To4()
if ip == nil {
continue
}
s.conf.dnsIPAddrs = append(s.conf.dnsIPAddrs, netip.AddrFrom4(*(*[4]byte)(ip)))
} | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/http_unix.go |
keep keep keep keep replace replace replace replace replace replace keep keep keep keep keep | <mask> }
<mask> }
<mask>
<mask> type netInterfaceJSON struct {
<mask> Name string `json:"name"`
<mask> HardwareAddr string `json:"hardware_address"`
<mask> Flags string `json:"flags"`
<mask> GatewayIP net.IP `json:"gateway_ip"`
<mask> Addrs4 []net.IP `json:"ipv4_addresses"`
<mask> Addrs6 []net.IP `json:"ipv6_addresses"`
<mask> }
<mask>
<mask> func (s *server) handleDHCPInterfaces(w http.ResponseWriter, r *http.Request) {
<mask> response := map[string]netInterfaceJSON{}
<mask>
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove Subnets []*net.IPNet `json:"-"`
</s> add Subnets []netip.Prefix `json:"-"` </s> remove Addresses []net.IP `json:"ip_addresses,omitempty"`
</s> add Addresses []netip.Addr `json:"ip_addresses,omitempty"` </s> remove IP net.IP `json:"ip"`
Port int `json:"port"`
</s> add IP netip.Addr `json:"ip"`
Port int `json:"port"` </s> remove GatewayIP net.IP `json:"gateway_ip"`
SubnetMask net.IP `json:"subnet_mask"`
RangeStart net.IP `json:"range_start"`
RangeEnd net.IP `json:"range_end"`
LeaseDuration uint32 `json:"lease_duration"`
</s> add GatewayIP netip.Addr `json:"gateway_ip"`
SubnetMask netip.Addr `json:"subnet_mask"`
RangeStart netip.Addr `json:"range_start"`
RangeEnd netip.Addr `json:"range_end"`
LeaseDuration uint32 `json:"lease_duration"` </s> remove GatewayIP net.IP `yaml:"gateway_ip" json:"gateway_ip"`
SubnetMask net.IP `yaml:"subnet_mask" json:"subnet_mask"`
</s> add GatewayIP netip.Addr `yaml:"gateway_ip" json:"gateway_ip"`
SubnetMask netip.Addr `yaml:"subnet_mask" json:"subnet_mask"` </s> remove gatewayIP net.IP
subnetMask net.IP
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/http_unix.go |
keep keep keep add keep keep keep keep | <mask>
<mask> return
<mask> }
<mask> // ignore link-local
<mask> if ipnet.IP.IsLinkLocalUnicast() {
<mask> continue
<mask> }
<mask>
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove if ipnet.IP.To4() != nil {
jsonIface.Addrs4 = append(jsonIface.Addrs4, ipnet.IP)
</s> add if ip4 := ipnet.IP.To4(); ip4 != nil {
addr := netip.AddrFrom4(*(*[4]byte)(ip4))
jsonIface.Addrs4 = append(jsonIface.Addrs4, addr) </s> remove // Collect network interface addresses.
for _, addr := range addrs {
ipNet, ok := addr.(*net.IPNet)
if !ok {
// Should be net.IPNet, this is weird.
return nil, fmt.Errorf("got %s that is not net.IPNet, it is %T", addr, addr)
}
// Ignore link-local.
if ipNet.IP.IsLinkLocalUnicast() {
</s> add ip = ip.Unmap()
if ip.IsLinkLocalUnicast() {
// Ignore link-local IPv4.
if ip.Is4() { </s> remove if ip4 := subnet.IP.To4(); ip4 != nil {
subnet.IP = ip4
return subnet, nil
</s> add if ip = ip.To4(); ip != nil {
return netip.PrefixFrom(netip.AddrFrom4(*(*[4]byte)(ip)), maskLen), nil </s> remove s.conf.dnsIPAddrs = dnsIPAddrs
</s> add for _, ip := range dnsIPAddrs {
ip = ip.To4()
if ip == nil {
continue
}
s.conf.dnsIPAddrs = append(s.conf.dnsIPAddrs, netip.AddrFrom4(*(*[4]byte)(ip)))
} </s> remove netIface.Addresses = append(netIface.Addresses, ipNet.IP)
netIface.Subnets = append(netIface.Subnets, ipNet)
</s> add ip = ip.WithZone(iface.Name) </s> remove subnet = a
</s> add ip = a.IP
maskLen, _ = a.Mask.Size() | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/http_unix.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask> // ignore link-local
<mask> if ipnet.IP.IsLinkLocalUnicast() {
<mask> continue
<mask> }
<mask> if ipnet.IP.To4() != nil {
<mask> jsonIface.Addrs4 = append(jsonIface.Addrs4, ipnet.IP)
<mask> } else {
<mask> jsonIface.Addrs6 = append(jsonIface.Addrs6, ipnet.IP)
<mask> }
<mask> }
<mask> if len(jsonIface.Addrs4)+len(jsonIface.Addrs6) != 0 {
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove jsonIface.Addrs6 = append(jsonIface.Addrs6, ipnet.IP)
</s> add addr := netip.AddrFrom16(*(*[16]byte)(ipnet.IP))
jsonIface.Addrs6 = append(jsonIface.Addrs6, addr) </s> add //
// TODO(e.burkov): Try to listen DHCP on LLA as well. </s> remove netIface.Addresses = append(netIface.Addresses, ipNet.IP)
netIface.Subnets = append(netIface.Subnets, ipNet)
</s> add ip = ip.WithZone(iface.Name) </s> remove // Discard interfaces with no addresses.
if len(netIface.Addresses) != 0 {
netIfaces = append(netIfaces, netIface)
</s> add ones, _ := n.Mask.Size()
p := netip.PrefixFrom(ip, ones)
niface.Addresses = append(niface.Addresses, ip)
niface.Subnets = append(niface.Subnets, p)
}
return niface, nil
}
// GetValidNetInterfacesForWeb returns interfaces that are eligible for DNS and
// WEB only we do not return link-local addresses here.
//
// TODO(e.burkov): Can't properly test the function since it's nontrivial to
// substitute net.Interface.Addrs and the net.InterfaceAddrs can't be used.
func GetValidNetInterfacesForWeb() (nifaces []*NetInterface, err error) {
ifaces, err := net.Interfaces()
if err != nil {
return nil, fmt.Errorf("getting interfaces: %w", err)
} else if len(ifaces) == 0 {
return nil, errors.Error("no legible interfaces")
}
for i := range ifaces {
var niface *NetInterface
niface, err = NetInterfaceFrom(&ifaces[i])
if err != nil {
return nil, err
} else if len(niface.Addresses) != 0 {
// Discard interfaces with no addresses.
nifaces = append(nifaces, niface) </s> remove if opts.bindHost != nil {
</s> add if opts.bindHost.IsValid() { </s> remove restartHTTP = !config.BindHost.Equal(req.Web.IP) || config.BindPort != req.Web.Port
</s> add restartHTTP = config.BindHost != req.Web.IP || config.BindPort != req.Web.Port | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/http_unix.go |
keep keep keep keep replace keep keep keep keep keep | <mask> }
<mask> if ipnet.IP.To4() != nil {
<mask> jsonIface.Addrs4 = append(jsonIface.Addrs4, ipnet.IP)
<mask> } else {
<mask> jsonIface.Addrs6 = append(jsonIface.Addrs6, ipnet.IP)
<mask> }
<mask> }
<mask> if len(jsonIface.Addrs4)+len(jsonIface.Addrs6) != 0 {
<mask> jsonIface.GatewayIP = aghnet.GatewayIP(iface.Name)
<mask> response[iface.Name] = jsonIface
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove if ipnet.IP.To4() != nil {
jsonIface.Addrs4 = append(jsonIface.Addrs4, ipnet.IP)
</s> add if ip4 := ipnet.IP.To4(); ip4 != nil {
addr := netip.AddrFrom4(*(*[4]byte)(ip4))
jsonIface.Addrs4 = append(jsonIface.Addrs4, addr) </s> remove if opts.bindHost != nil {
</s> add if opts.bindHost.IsValid() { </s> remove restartHTTP = !config.BindHost.Equal(req.Web.IP) || config.BindPort != req.Web.Port
</s> add restartHTTP = config.BindHost != req.Web.IP || config.BindPort != req.Web.Port </s> remove v4conf.Enabled = s.conf.Enabled && len(v4conf.RangeStart) != 0
</s> add v4conf.Enabled = s.conf.Enabled && v4conf.RangeStart.IsValid() </s> remove // Discard interfaces with no addresses.
if len(netIface.Addresses) != 0 {
netIfaces = append(netIfaces, netIface)
</s> add ones, _ := n.Mask.Size()
p := netip.PrefixFrom(ip, ones)
niface.Addresses = append(niface.Addresses, ip)
niface.Subnets = append(niface.Subnets, p)
}
return niface, nil
}
// GetValidNetInterfacesForWeb returns interfaces that are eligible for DNS and
// WEB only we do not return link-local addresses here.
//
// TODO(e.burkov): Can't properly test the function since it's nontrivial to
// substitute net.Interface.Addrs and the net.InterfaceAddrs can't be used.
func GetValidNetInterfacesForWeb() (nifaces []*NetInterface, err error) {
ifaces, err := net.Interfaces()
if err != nil {
return nil, fmt.Errorf("getting interfaces: %w", err)
} else if len(ifaces) == 0 {
return nil, errors.Error("no legible interfaces")
}
for i := range ifaces {
var niface *NetInterface
niface, err = NetInterfaceFrom(&ifaces[i])
if err != nil {
return nil, err
} else if len(niface.Addresses) != 0 {
// Discard interfaces with no addresses.
nifaces = append(nifaces, niface) </s> remove netIface.Addresses = append(netIface.Addresses, ipNet.IP)
netIface.Subnets = append(netIface.Subnets, ipNet)
</s> add ip = ip.WithZone(iface.Name) | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/http_unix.go |
keep keep add keep keep keep keep | <mask>
<mask> // newIPRange creates a new IP address range. start must be less than end. The
<mask> // resulting range must not be greater than maxRangeLen.
<mask> func newIPRange(start, end net.IP) (r *ipRange, err error) {
<mask> defer func() { err = errors.Annotate(err, "invalid ip range: %w") }()
<mask>
<mask> // Make sure that both are 16 bytes long to simplify handling in
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove defer func() { s.implicitOpts.Update(dhcpv4.OptDNS(defaultIP)) }()
</s> add defer func() { s.implicitOpts.Update(dhcpv4.OptDNS(defaultIP.AsSlice())) }() </s> remove subnet *net.IPNet
</s> add subnet netip.Prefix </s> remove func GatewayIP(ifaceName string) (ip net.IP) {
</s> add func GatewayIP(ifaceName string) (ip netip.Addr) { </s> remove func InterfaceByIP(ip net.IP) (ifaceName string) {
</s> add func InterfaceByIP(ip netip.Addr) (ifaceName string) { </s> remove // GetValidNetInterfacesForWeb returns interfaces that are eligible for DNS and
// WEB only we do not return link-local addresses here.
//
// TODO(e.burkov): Can't properly test the function since it's nontrivial to
// substitute net.Interface.Addrs and the net.InterfaceAddrs can't be used.
func GetValidNetInterfacesForWeb() (netIfaces []*NetInterface, err error) {
ifaces, err := net.Interfaces()
</s> add func NetInterfaceFrom(iface *net.Interface) (niface *NetInterface, err error) {
niface = &NetInterface{
Name: iface.Name,
HardwareAddr: iface.HardwareAddr,
Flags: iface.Flags,
MTU: iface.MTU,
}
addrs, err := iface.Addrs() </s> remove // ensureV4 returns a 4-byte version of ip. An error is returned if the passed
// ip is not an IPv4.
func ensureV4(ip net.IP) (ip4 net.IP, err error) {
if ip == nil {
return nil, fmt.Errorf("%v is not an IP address", ip)
}
ip4 = ip.To4()
if ip4 == nil {
return nil, fmt.Errorf("%v is not an IPv4 address", ip)
</s> add // ensureV4 returns an unmapped version of ip. An error is returned if the
// passed ip is not an IPv4.
func ensureV4(ip netip.Addr, kind string) (ip4 netip.Addr, err error) {
ip4 = ip.Unmap()
if !ip4.IsValid() || !ip4.Is4() {
return netip.Addr{}, fmt.Errorf("%v is not an IPv4 %s", ip, kind) | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/iprange.go |
keep keep keep add keep keep keep keep keep | <mask> // See https://datatracker.ietf.org/doc/html/rfc1122#section-4.2.3.6.
<mask> dhcpv4.OptGeneric(dhcpv4.OptionTCPKeepaliveGarbage, []byte{0x01}),
<mask>
<mask> // Values From Configuration
<mask>
<mask> dhcpv4.OptSubnetMask(s.conf.SubnetMask.AsSlice()),
<mask> )
<mask>
<mask> // Set values for explicitly configured options.
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove // Set the Router Option to working subnet's IP since it's initialized
// with the address of the gateway.
dhcpv4.OptRouter(s.conf.subnet.IP),
dhcpv4.OptSubnetMask(s.conf.subnet.Mask),
</s> add dhcpv4.OptSubnetMask(s.conf.SubnetMask.AsSlice()), </s> remove // GetSubnet returns pointer to net.IPNet for the specified interface or nil if
</s> add // GetSubnet returns the subnet corresponding to the interface of zero prefix if </s> remove resp.UpdateOption(dhcpv4.OptServerIdentifier(s.conf.dnsIPAddrs[0]))
</s> add resp.UpdateOption(dhcpv4.OptServerIdentifier(s.conf.dnsIPAddrs[0].AsSlice())) </s> remove func GetSubnet(ifaceName string) *net.IPNet {
</s> add func GetSubnet(ifaceName string) (p netip.Prefix) { </s> remove broadcastIP net.IP
</s> add broadcastIP netip.Addr </s> remove GatewayIP net.IP `yaml:"gateway_ip" json:"gateway_ip"`
SubnetMask net.IP `yaml:"subnet_mask" json:"subnet_mask"`
</s> add GatewayIP netip.Addr `yaml:"gateway_ip" json:"gateway_ip"`
SubnetMask netip.Addr `yaml:"subnet_mask" json:"subnet_mask"` | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/options_unix.go |
keep keep keep keep replace replace replace replace replace keep keep keep keep keep | <mask> dhcpv4.OptGeneric(dhcpv4.OptionTCPKeepaliveGarbage, []byte{0x01}),
<mask>
<mask> // Values From Configuration
<mask>
<mask> // Set the Router Option to working subnet's IP since it's initialized
<mask> // with the address of the gateway.
<mask> dhcpv4.OptRouter(s.conf.subnet.IP),
<mask>
<mask> dhcpv4.OptSubnetMask(s.conf.subnet.Mask),
<mask> )
<mask>
<mask> // Set values for explicitly configured options.
<mask> s.explicitOpts = dhcpv4.Options{}
<mask> for i, o := range s.conf.Options {
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> add dhcpv4.OptRouter(s.conf.GatewayIP.AsSlice()), </s> remove broadcastIP net.IP
</s> add broadcastIP netip.Addr </s> remove subnet *net.IPNet
</s> add subnet netip.Prefix </s> remove func GatewayIP(ifaceName string) (ip net.IP) {
</s> add func GatewayIP(ifaceName string) (ip netip.Addr) { </s> remove "github.com/AdguardTeam/golibs/netutil"
</s> add </s> remove mask := n.Mask
if mask == nil {
mask = dc.DefaultMask()
</s> add maskLen, addrLen := p.Bits(), bc.BitLen()
if maskLen == addrLen {
return bc | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/options_unix.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask>
<mask> for _, tc := range testCases {
<mask> s := &v4Server{
<mask> conf: &V4ServerConf{
<mask> // Just to avoid nil pointer dereference.
<mask> subnet: &net.IPNet{},
<mask> Options: tc.opts,
<mask> },
<mask> }
<mask>
<mask> t.Run(tc.name, func(t *testing.T) {
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove subnet: &net.IPNet{
IP: net.IP{0, 0, 0, 0},
Mask: net.IPMask{0, 0, 0, 0},
},
want: net.IPv4bcast,
</s> add }, {
pref: netip.Prefix{},
want: netip.Addr{},
name: "invalid", </s> remove bc := BroadcastFromIPNet(tc.subnet)
assert.True(t, bc.Equal(tc.want), bc)
</s> add assert.Equal(t, tc.want, BroadcastFromPref(tc.pref)) </s> remove want: nil,
</s> add want: netip.Addr{},
name: "bad_code", </s> remove gatewayIP: net.IP{192, 168, 10, 1},
subnetMask: net.IP{255, 255, 255, 224},
</s> add </s> remove RangeStart: net.IP{192, 168, 10, 20},
RangeEnd: net.IP{192, 168, 10, 200},
</s> add RangeStart: netip.MustParseAddr("192.168.10.20"),
RangeEnd: netip.MustParseAddr("192.168.10.200"), </s> remove name: "bad_code",
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/options_unix_test.go |
keep add keep keep keep keep keep keep | <mask> "fmt"
<mask> "net"
<mask> "strings"
<mask> "sync"
<mask> "time"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghnet"
<mask> "github.com/AdguardTeam/golibs/errors"
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> add "net/netip" </s> add "net/netip" </s> add "net/netip" </s> add "net/netip" </s> remove "net"
</s> add "net/netip" </s> remove "net"
</s> add | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/v4_unix.go |
keep keep keep keep replace keep keep keep keep keep | <mask>
<mask> if l.IsStatic() {
<mask> // TODO(a.garipov, d.seregin): Subnet can be nil when dhcp server is
<mask> // disabled.
<mask> if sn := s.conf.subnet; !sn.Contains(l.IP) {
<mask> return fmt.Errorf("subnet %s does not contain the ip %q", sn, l.IP)
<mask> }
<mask> } else if !inOffset {
<mask> return fmt.Errorf("lease %s (%s) out of range, not adding", l.IP, l.HWAddr)
<mask> }
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove } else if gwIP := s.conf.GatewayIP; gwIP.Equal(ip) {
</s> add } else if gwIP := s.conf.GatewayIP; gwIP == netip.AddrFrom4(*(*[4]byte)(ip)) { </s> remove // Collect network interface addresses.
for _, addr := range addrs {
ipNet, ok := addr.(*net.IPNet)
if !ok {
// Should be net.IPNet, this is weird.
return nil, fmt.Errorf("got %s that is not net.IPNet, it is %T", addr, addr)
}
// Ignore link-local.
if ipNet.IP.IsLinkLocalUnicast() {
</s> add ip = ip.Unmap()
if ip.IsLinkLocalUnicast() {
// Ignore link-local IPv4.
if ip.Is4() { </s> remove // ensureV4 returns a 4-byte version of ip. An error is returned if the passed
// ip is not an IPv4.
func ensureV4(ip net.IP) (ip4 net.IP, err error) {
if ip == nil {
return nil, fmt.Errorf("%v is not an IP address", ip)
}
ip4 = ip.To4()
if ip4 == nil {
return nil, fmt.Errorf("%v is not an IPv4 address", ip)
</s> add // ensureV4 returns an unmapped version of ip. An error is returned if the
// passed ip is not an IPv4.
func ensureV4(ip netip.Addr, kind string) (ip4 netip.Addr, err error) {
ip4 = ip.Unmap()
if !ip4.IsValid() || !ip4.Is4() {
return netip.Addr{}, fmt.Errorf("%v is not an IPv4 %s", ip, kind) </s> remove if ip4 := subnet.IP.To4(); ip4 != nil {
subnet.IP = ip4
return subnet, nil
</s> add if ip = ip.To4(); ip != nil {
return netip.PrefixFrom(netip.AddrFrom4(*(*[4]byte)(ip)), maskLen), nil </s> remove if !sid.Equal(s.conf.dnsIPAddrs[0]) {
</s> add if !sid.Equal(s.conf.dnsIPAddrs[0].AsSlice()) { </s> remove return aghnet.CheckPort("tcp", req.Web.IP, portInt)
</s> add return aghnet.CheckPort("tcp", netip.AddrPortFrom(req.Web.IP, uint16(portInt))) | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/v4_unix.go |
keep keep keep keep replace keep keep keep keep keep | <mask>
<mask> ip := l.IP.To4()
<mask> if ip == nil {
<mask> return fmt.Errorf("invalid ip %q, only ipv4 is supported", l.IP)
<mask> } else if gwIP := s.conf.GatewayIP; gwIP.Equal(ip) {
<mask> return fmt.Errorf("can't assign the gateway IP %s to the lease", gwIP)
<mask> }
<mask>
<mask> l.Expiry = time.Unix(leaseExpireStatic, 0)
<mask>
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove if ip4 := subnet.IP.To4(); ip4 != nil {
subnet.IP = ip4
return subnet, nil
</s> add if ip = ip.To4(); ip != nil {
return netip.PrefixFrom(netip.AddrFrom4(*(*[4]byte)(ip)), maskLen), nil </s> remove if sn := s.conf.subnet; !sn.Contains(l.IP) {
</s> add addr := netip.AddrFrom4(*(*[4]byte)(l.IP.To4()))
if sn := s.conf.subnet; !sn.Contains(addr) { </s> remove s.conf.dnsIPAddrs = dnsIPAddrs
</s> add for _, ip := range dnsIPAddrs {
ip = ip.To4()
if ip == nil {
continue
}
s.conf.dnsIPAddrs = append(s.conf.dnsIPAddrs, netip.AddrFrom4(*(*[4]byte)(ip)))
} </s> remove IP: DefaultGatewayIP,
</s> add IP: DefaultGatewayIP.AsSlice(), </s> remove // ensureV4 returns a 4-byte version of ip. An error is returned if the passed
// ip is not an IPv4.
func ensureV4(ip net.IP) (ip4 net.IP, err error) {
if ip == nil {
return nil, fmt.Errorf("%v is not an IP address", ip)
}
ip4 = ip.To4()
if ip4 == nil {
return nil, fmt.Errorf("%v is not an IPv4 address", ip)
</s> add // ensureV4 returns an unmapped version of ip. An error is returned if the
// passed ip is not an IPv4.
func ensureV4(ip netip.Addr, kind string) (ip4 netip.Addr, err error) {
ip4 = ip.Unmap()
if !ip4.IsValid() || !ip4.Is4() {
return netip.Addr{}, fmt.Errorf("%v is not an IPv4 %s", ip, kind) </s> remove tcpAddrs = make([]*net.TCPAddr, len(ips))
for i, ip := range ips {
tcpAddrs[i] = &net.TCPAddr{
IP: ip,
Port: port,
}
</s> add tcpAddrs = make([]*net.TCPAddr, 0, len(ips))
for _, ip := range ips {
tcpAddrs = append(tcpAddrs, net.TCPAddrFromAddrPort(netip.AddrPortFrom(ip, uint16(port)))) | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/v4_unix.go |
keep keep keep keep replace keep keep keep keep keep | <mask> ) (l *Lease, needsReply bool) {
<mask> // Client inserts the address of the selected server in server identifier,
<mask> // ciaddr MUST be zero.
<mask> mac := req.ClientHWAddr
<mask> if !sid.Equal(s.conf.dnsIPAddrs[0]) {
<mask> log.Debug("dhcpv4: bad server identifier in req msg for %s: %s", mac, sid)
<mask>
<mask> return nil, false
<mask> } else if ciaddr := req.ClientIPAddr; ciaddr != nil && !ciaddr.IsUnspecified() {
<mask> log.Debug("dhcpv4: non-zero ciaddr in selecting req msg for %s", mac)
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove if ip4 := reqIP.To4(); ip4 == nil {
</s> add ip4 := reqIP.To4()
if ip4 == nil { </s> remove if !s.conf.subnet.Contains(reqIP) {
</s> add if !s.conf.subnet.Contains(netip.AddrFrom4(*(*[4]byte)(ip4))) { </s> remove addrs = appendDNSAddrs(addrs, net.IP{127, 0, 0, 1})
</s> add addr := aghnet.IPv4Localhost()
addrs = appendDNSAddrs(addrs, addr) </s> remove return Context.web.httpsServer.server != nil ||
aghnet.CheckPort("tcp", config.BindHost, port) == nil
</s> add if Context.web.httpsServer.server != nil {
return true
}
return aghnet.CheckPort("tcp", netip.AddrPortFrom(config.BindHost, uint16(port))) == nil </s> remove defaultIP := net.IP{192, 168, 1, 1}
</s> add defaultIP := netip.MustParseAddr("192.168.1.1") </s> remove netIface := &NetInterface{
MTU: iface.MTU,
Name: iface.Name,
HardwareAddr: iface.HardwareAddr,
Flags: iface.Flags,
</s> add ip, ok := netip.AddrFromSlice(n.IP)
if !ok {
return nil, fmt.Errorf("bad address %s", n.IP) | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/v4_unix.go |
keep keep keep keep replace keep keep keep keep keep | <mask> // handleInitReboot handles the DHCPREQUEST generated during INIT-REBOOT state.
<mask> func (s *v4Server) handleInitReboot(req *dhcpv4.DHCPv4, reqIP net.IP) (l *Lease, needsReply bool) {
<mask> mac := req.ClientHWAddr
<mask>
<mask> if ip4 := reqIP.To4(); ip4 == nil {
<mask> log.Debug("dhcpv4: bad requested address in req msg for %s: %s", mac, reqIP)
<mask>
<mask> return nil, false
<mask> }
<mask>
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove if !sid.Equal(s.conf.dnsIPAddrs[0]) {
</s> add if !sid.Equal(s.conf.dnsIPAddrs[0].AsSlice()) { </s> remove if !s.conf.subnet.Contains(reqIP) {
</s> add if !s.conf.subnet.Contains(netip.AddrFrom4(*(*[4]byte)(ip4))) { </s> remove for _, iface := range ifaces {
var addrs []net.Addr
addrs, err = iface.Addrs()
if err != nil {
return nil, fmt.Errorf("failed to get addresses for interface %s: %w", iface.Name, err)
</s> add // Collect network interface addresses.
for _, addr := range addrs {
n, ok := addr.(*net.IPNet)
if !ok {
// Should be *net.IPNet, this is weird.
return nil, fmt.Errorf("expected %[2]s to be %[1]T, got %[2]T", n, addr)
} else if ip4 := n.IP.To4(); ip4 != nil {
n.IP = ip4 </s> remove // ensureV4 returns a 4-byte version of ip. An error is returned if the passed
// ip is not an IPv4.
func ensureV4(ip net.IP) (ip4 net.IP, err error) {
if ip == nil {
return nil, fmt.Errorf("%v is not an IP address", ip)
}
ip4 = ip.To4()
if ip4 == nil {
return nil, fmt.Errorf("%v is not an IPv4 address", ip)
</s> add // ensureV4 returns an unmapped version of ip. An error is returned if the
// passed ip is not an IPv4.
func ensureV4(ip netip.Addr, kind string) (ip4 netip.Addr, err error) {
ip4 = ip.Unmap()
if !ip4.IsValid() || !ip4.Is4() {
return netip.Addr{}, fmt.Errorf("%v is not an IPv4 %s", ip, kind) </s> remove if ip4 := subnet.IP.To4(); ip4 != nil {
subnet.IP = ip4
return subnet, nil
</s> add if ip = ip.To4(); ip != nil {
return netip.PrefixFrom(netip.AddrFrom4(*(*[4]byte)(ip)), maskLen), nil </s> remove if o.bindHost == nil {
</s> add if !o.bindHost.IsValid() { | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/v4_unix.go |
keep keep keep keep replace keep keep keep keep keep | <mask>
<mask> return nil, false
<mask> }
<mask>
<mask> if !s.conf.subnet.Contains(reqIP) {
<mask> // If the DHCP server detects that the client is on the wrong net then
<mask> // the server SHOULD send a DHCPNAK message to the client.
<mask> log.Debug("dhcpv4: wrong subnet in init-reboot req msg for %s: %s", mac, reqIP)
<mask>
<mask> return nil, true
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove if !sid.Equal(s.conf.dnsIPAddrs[0]) {
</s> add if !sid.Equal(s.conf.dnsIPAddrs[0].AsSlice()) { </s> remove if ip4 := reqIP.To4(); ip4 == nil {
</s> add ip4 := reqIP.To4()
if ip4 == nil { </s> remove dnsIPAddrs []net.IP // IPv4 addresses to return to DHCP clients as DNS server addresses
</s> add dnsIPAddrs []netip.Addr // IPv4 addresses to return to DHCP clients as DNS server addresses </s> remove subnet *net.IPNet
</s> add subnet netip.Prefix </s> remove BindHost net.IP `yaml:"bind_host"` // BindHost is the IP address of the HTTP server to bind to
BindPort int `yaml:"bind_port"` // BindPort is the port the HTTP server
BetaBindPort int `yaml:"beta_bind_port"` // BetaBindPort is the port for new client
Users []webUser `yaml:"users"` // Users that can access HTTP server
</s> add // BindHost is the address for the web interface server to listen on.
BindHost netip.Addr `yaml:"bind_host"`
// BindPort is the port for the web interface server to listen on.
BindPort int `yaml:"bind_port"`
// BetaBindPort is the port for the new client's web interface server to
// listen on.
BetaBindPort int `yaml:"beta_bind_port"`
// Users are the clients capable for accessing the web interface.
Users []webUser `yaml:"users"` </s> remove AuthBlockMin uint `yaml:"block_auth_min"`
ProxyURL string `yaml:"http_proxy"` // Proxy address for our HTTP client
Language string `yaml:"language"` // two-letter ISO 639-1 language code
DebugPProf bool `yaml:"debug_pprof"` // Enable pprof HTTP server on port 6060
</s> add AuthBlockMin uint `yaml:"block_auth_min"`
// ProxyURL is the address of proxy server for the internal HTTP client.
ProxyURL string `yaml:"http_proxy"`
// Language is a two-letter ISO 639-1 language code.
Language string `yaml:"language"`
// DebugPProf defines if the profiling HTTP handler will listen on :6060.
DebugPProf bool `yaml:"debug_pprof"` | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/v4_unix.go |
keep keep keep keep replace keep keep keep keep keep | <mask>
<mask> // Include server's identifier option since any reply should contain it.
<mask> //
<mask> // See https://datatracker.ietf.org/doc/html/rfc2131#page-29.
<mask> resp.UpdateOption(dhcpv4.OptServerIdentifier(s.conf.dnsIPAddrs[0]))
<mask>
<mask> // TODO(a.garipov): Refactor this into handlers.
<mask> var l *Lease
<mask> switch mt := req.MessageType(); mt {
<mask> case dhcpv4.MessageTypeDiscover:
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> add var ip net.IP
var maskLen int </s> remove addr := netutil.IPPort{IP: ip, Port: port}.String()
</s> add addr := ipp.String() </s> remove return nil, err
</s> add return netip.Prefix{}, err </s> remove func CheckPort(network string, ip net.IP, port int) (err error) {
</s> add func CheckPort(network string, ipp netip.AddrPort) (err error) { </s> remove "github.com/AdguardTeam/golibs/netutil"
</s> add </s> remove subnet = &net.IPNet{
IP: a.IP,
Mask: a.IP.DefaultMask(),
}
</s> add ip = a.IP
maskLen, _ = ip.DefaultMask().Size() | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/v4_unix.go |
keep keep keep keep replace keep keep keep keep keep | <mask> if !s.explicitOpts.Has(dhcpv4.OptionDomainNameServer) {
<mask> s.implicitOpts.Update(dhcpv4.OptDNS(dnsIPAddrs...))
<mask> }
<mask>
<mask> s.conf.dnsIPAddrs = dnsIPAddrs
<mask>
<mask> var c net.PacketConn
<mask> if c, err = s.newDHCPConn(iface); err != nil {
<mask> return err
<mask> }
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove var gatewayIP net.IP
gatewayIP, err = ensureV4(c.GatewayIP)
</s> add gatewayIP, err := ensureV4(c.GatewayIP, "address") </s> remove addr := netutil.IPPort{IP: ip, Port: port}.String()
</s> add addr := ipp.String() </s> remove err = aghnet.CheckPort("tcp", req.DNS.IP, port)
</s> add err = aghnet.CheckPort("tcp", netip.AddrPortFrom(req.DNS.IP, uint16(port))) </s> remove func CheckPort(network string, ip net.IP, port int) (err error) {
</s> add func CheckPort(network string, ipp netip.AddrPort) (err error) { </s> remove s.conf.dnsIPAddrs = []net.IP{defaultIP}
</s> add s.conf.dnsIPAddrs = []netip.Addr{defaultIP} </s> remove s.conf.dnsIPAddrs = []net.IP{{192, 168, 10, 1}}
s.implicitOpts.Update(dhcpv4.OptDNS(s.conf.dnsIPAddrs...))
</s> add s.conf.dnsIPAddrs = []netip.Addr{netip.MustParseAddr("192.168.10.1")}
s.implicitOpts.Update(dhcpv4.OptDNS(s.conf.dnsIPAddrs[0].AsSlice())) | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/v4_unix.go |
keep add keep keep keep keep keep | <mask> "fmt"
<mask> "net"
<mask> "strings"
<mask> "testing"
<mask> "time"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghnet"
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> add "net/netip" </s> add "net/netip" </s> add "net/netip" </s> remove "net"
</s> add </s> add "net/netip" </s> add "net/netip" | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/v4_unix_test.go |
keep keep keep keep replace replace replace replace replace keep keep keep keep keep | <mask> "github.com/mdlayher/raw"
<mask> )
<mask>
<mask> var (
<mask> DefaultRangeStart = net.IP{192, 168, 10, 100}
<mask> DefaultRangeEnd = net.IP{192, 168, 10, 200}
<mask> DefaultGatewayIP = net.IP{192, 168, 10, 1}
<mask> DefaultSelfIP = net.IP{192, 168, 10, 2}
<mask> DefaultSubnetMask = net.IP{255, 255, 255, 0}
<mask> )
<mask>
<mask> // defaultV4ServerConf returns the default configuration for *v4Server to use in
<mask> // tests.
<mask> func defaultV4ServerConf() (conf *V4ServerConf) {
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove RangeStart: net.IP{192, 168, 10, 100},
RangeEnd: net.IP{192, 168, 10, 200},
GatewayIP: net.IP{192, 168, 10, 1},
SubnetMask: net.IP{255, 255, 255, 0},
</s> add RangeStart: netip.MustParseAddr("192.168.10.100"),
RangeEnd: netip.MustParseAddr("192.168.10.200"),
GatewayIP: netip.MustParseAddr("192.168.10.1"),
SubnetMask: netip.MustParseAddr("255.255.255.0"), </s> remove name: "outside_range_start",
</s> add name: "outside_range_start",
gatewayIP: netip.MustParseAddr("192.168.10.1"),
subnetMask: netip.MustParseAddr("255.255.255.240"), </s> remove name: "outside_range_end",
</s> add name: "outside_range_end",
gatewayIP: netip.MustParseAddr("192.168.10.1"),
subnetMask: netip.MustParseAddr("255.255.255.224"), </s> remove gatewayIP: net.IP{192, 168, 10, 120},
subnetMask: net.IP{255, 255, 255, 0},
</s> add </s> remove gatewayIP: net.IP{192, 168, 10, 1},
subnetMask: net.IP{255, 255, 255, 240},
</s> add </s> remove RangeStart: net.IP{192, 168, 10, 20},
RangeEnd: net.IP{192, 168, 10, 200},
</s> add RangeStart: netip.MustParseAddr("192.168.10.20"),
RangeEnd: netip.MustParseAddr("192.168.10.200"), | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/v4_unix_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask> RangeEnd: DefaultRangeEnd,
<mask> GatewayIP: DefaultGatewayIP,
<mask> SubnetMask: DefaultSubnetMask,
<mask> notify: testNotify,
<mask> dnsIPAddrs: []net.IP{DefaultSelfIP},
<mask> }
<mask> }
<mask>
<mask> // defaultSrv prepares the default DHCPServer to use in tests. The underlying
<mask> // type of s is *v4Server.
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove RangeStart: net.IP{192, 168, 10, 100},
RangeEnd: net.IP{192, 168, 10, 200},
GatewayIP: net.IP{192, 168, 10, 1},
SubnetMask: net.IP{255, 255, 255, 0},
</s> add RangeStart: netip.MustParseAddr("192.168.10.100"),
RangeEnd: netip.MustParseAddr("192.168.10.200"),
GatewayIP: netip.MustParseAddr("192.168.10.1"),
SubnetMask: netip.MustParseAddr("255.255.255.0"), </s> remove RangeStart: net.IP{192, 168, 10, 20},
RangeEnd: net.IP{192, 168, 10, 200},
</s> add RangeStart: netip.MustParseAddr("192.168.10.20"),
RangeEnd: netip.MustParseAddr("192.168.10.200"), </s> remove GatewayIP: net.IP{1, 2, 3, 1},
SubnetMask: net.IP{255, 255, 255, 0},
RangeStart: net.IP{1, 2, 3, 2},
RangeEnd: net.IP{1, 2, 3, 10},
</s> add GatewayIP: netip.MustParseAddr("1.2.3.1"),
SubnetMask: netip.MustParseAddr("255.255.255.0"),
RangeStart: netip.MustParseAddr("1.2.3.2"),
RangeEnd: netip.MustParseAddr("1.2.3.10"), </s> remove "github.com/AdguardTeam/golibs/netutil"
</s> add </s> remove DefaultRangeStart = net.IP{192, 168, 10, 100}
DefaultRangeEnd = net.IP{192, 168, 10, 200}
DefaultGatewayIP = net.IP{192, 168, 10, 1}
DefaultSelfIP = net.IP{192, 168, 10, 2}
DefaultSubnetMask = net.IP{255, 255, 255, 0}
</s> add DefaultRangeStart = netip.MustParseAddr("192.168.10.100")
DefaultRangeEnd = netip.MustParseAddr("192.168.10.200")
DefaultGatewayIP = netip.MustParseAddr("192.168.10.1")
DefaultSelfIP = netip.MustParseAddr("192.168.10.2")
DefaultSubnetMask = netip.MustParseAddr("255.255.255.0") </s> remove config.DNS.BindHosts = []net.IP{req.DNS.IP}
</s> add config.DNS.BindHosts = []netip.Addr{req.DNS.IP} | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/v4_unix_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask> err = s.AddStaticLease(&Lease{
<mask> Expiry: time.Unix(leaseExpireStatic, 0),
<mask> Hostname: staticName,
<mask> HWAddr: anotherMAC,
<mask> IP: anotherIP,
<mask> })
<mask> assert.ErrorIs(t, err, ErrDupHostname)
<mask> })
<mask>
<mask> t.Run("same_mac", func(t *testing.T) {
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove IP: anotherIP,
</s> add IP: anotherIP.AsSlice(), </s> remove resp := discoverAnOffer(t, anotherName, anotherIP, staticMAC)
</s> add resp := discoverAnOffer(t, anotherName, anotherIP.AsSlice(), staticMAC) </s> remove resp := discoverAnOffer(t, staticName, anotherIP, anotherMAC)
</s> add resp := discoverAnOffer(t, staticName, anotherIP.AsSlice(), anotherMAC) </s> remove err := CheckPort("bad_network", nil, 0)
</s> add err := CheckPort("bad_network", netip.AddrPortFrom(netip.Addr{}, 0)) </s> remove err := CheckPort("udp", net.IP{0, 0, 0, 0}, 0)
</s> add err := CheckPort("udp", netip.AddrPortFrom(netip.IPv4Unspecified(), 0)) </s> remove checkResp(t, s, []net.IP{defaultIP})
</s> add checkResp(t, s, []net.IP{defaultIP.AsSlice()}) | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/v4_unix_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask> err = s.AddStaticLease(&Lease{
<mask> Expiry: time.Unix(leaseExpireStatic, 0),
<mask> Hostname: anotherName,
<mask> HWAddr: staticMAC,
<mask> IP: anotherIP,
<mask> })
<mask> testutil.AssertErrorMsg(t, wantErrMsg, err)
<mask> })
<mask>
<mask> t.Run("same_ip", func(t *testing.T) {
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove IP: anotherIP,
</s> add IP: anotherIP.AsSlice(), </s> remove resp := discoverAnOffer(t, anotherName, anotherIP, staticMAC)
</s> add resp := discoverAnOffer(t, anotherName, anotherIP.AsSlice(), staticMAC) </s> remove err := CheckPort("udp", net.IP{0, 0, 0, 0}, 0)
</s> add err := CheckPort("udp", netip.AddrPortFrom(netip.IPv4Unspecified(), 0)) </s> remove err := CheckPort("bad_network", nil, 0)
</s> add err := CheckPort("bad_network", netip.AddrPortFrom(netip.Addr{}, 0)) </s> remove conn, err := net.ListenPacket("udp", "127.0.0.1:")
</s> add conn, err := net.ListenPacket("udp", laddr.String()) </s> remove checkResp(t, s, []net.IP{defaultIP})
</s> add checkResp(t, s, []net.IP{defaultIP.AsSlice()}) | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/v4_unix_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask> mac,
<mask> dhcpv4.WithOption(dhcpv4.OptHostName(name)),
<mask> dhcpv4.WithOption(dhcpv4.OptRequestedIPAddress(ip)),
<mask> dhcpv4.WithOption(dhcpv4.OptClientIdentifier([]byte{1, 2, 3, 4, 5, 6, 8})),
<mask> dhcpv4.WithGatewayIP(DefaultGatewayIP),
<mask> )
<mask> require.NoError(t, err)
<mask>
<mask> resp = &dhcpv4.DHCPv4{}
<mask> res := s4.handle(req, resp)
</s> Pull request: Migrate to netip.Addr vol.1
Merge in DNS/adguard-home from 2926-lla-v6 to master
Updates #2926.
Updates #5035.
Squashed commit of the following:
commit 2e770d4b6d4e1ec3f7762f2f2466662983bf146c
Merge: 25c1afc5 893358ea
Author: Eugene Burkov <[email protected]>
Date: Fri Oct 14 15:14:56 2022 +0300
Merge branch 'master' into 2926-lla-v6
commit 25c1afc5f0a5027fafac9dee77618886aefee29c
Author: Eugene Burkov <[email protected]>
Date: Thu Oct 13 18:24:20 2022 +0300
all: imp code, docs
commit 59549c4f74ee17b10eae542d1f1828d4e59894c9
Author: Eugene Burkov <[email protected]>
Date: Tue Oct 11 18:49:09 2022 +0300
dhcpd: use netip initially
commit 1af623096b0517d07752385540f2f750f7f5b3bb
Author: Eugene Burkov <[email protected]>
Date: Fri Sep 30 18:03:52 2022 +0300
all: imp docs, code
commit e9faeb71dbc0e887b25a7f3d5b33a401805f2ae7
Author: Eugene Burkov <[email protected]>
Date: Thu Sep 29 14:56:37 2022 +0300
all: use netip for web
commit 38305e555a6884c3bd1b0839330b942ce0e59093
Author: Eugene Burkov <[email protected]>
Date: Wed Sep 28 19:13:58 2022 +0300
add basic lla </s> remove known6 := net.IP{
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16,
}
</s> add known4 := netip.MustParseAddr("192.168.0.1")
fullBroadcast4 := netip.MustParseAddr("255.255.255.255")
known6 := netip.MustParseAddr("102:304:506:708:90a:b0c:d0e:f10") </s> remove GatewayIP: net.IP{1, 2, 3, 1},
SubnetMask: net.IP{255, 255, 255, 0},
RangeStart: net.IP{1, 2, 3, 2},
RangeEnd: net.IP{1, 2, 3, 10},
</s> add GatewayIP: netip.MustParseAddr("1.2.3.1"),
SubnetMask: netip.MustParseAddr("255.255.255.0"),
RangeStart: netip.MustParseAddr("1.2.3.2"),
RangeEnd: netip.MustParseAddr("1.2.3.10"), </s> remove resp := discoverAnOffer(t, staticName, anotherIP, anotherMAC)
</s> add resp := discoverAnOffer(t, staticName, anotherIP.AsSlice(), anotherMAC) </s> remove resp := discoverAnOffer(t, anotherName, anotherIP, staticMAC)
</s> add resp := discoverAnOffer(t, anotherName, anotherIP.AsSlice(), staticMAC) </s> remove s.conf.dnsIPAddrs = []net.IP{{192, 168, 10, 1}}
s.implicitOpts.Update(dhcpv4.OptDNS(s.conf.dnsIPAddrs...))
</s> add s.conf.dnsIPAddrs = []netip.Addr{netip.MustParseAddr("192.168.10.1")}
s.implicitOpts.Update(dhcpv4.OptDNS(s.conf.dnsIPAddrs[0].AsSlice())) </s> remove assert.Equal(t, net.IPv4(1, 2, 3, 4), testParseOK(t, "--host", "1.2.3.4").bindHost, "--host is host")
</s> add assert.Equal(t, wantAddr, testParseOK(t, "--host", "1.2.3.4").bindHost, "--host is host") | https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a | internal/dhcpd/v4_unix_test.go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.