code_before
stringlengths
16
1.81M
edits
stringlengths
4
328k
next_edit
stringlengths
0
76.5k
code_after
stringlengths
3
49.9M
label_window
sequencelengths
4
1.81k
instruction
stringlengths
20
51.9k
html_url
stringlengths
74
116
file_name
stringlengths
3
311
for _, a := range addrs { switch a := a.(type) { case *net.IPAddr: subnet = &net.IPNet{ IP: a.IP, Mask: a.IP.DefaultMask(), } case *net.IPNet: subnet = a default: continue }
</s> remove subnet = a </s> add ip = a.IP maskLen, _ = a.Mask.Size() </s> remove return nil, err </s> add return netip.Prefix{}, err </s> remove func appendDNSAddrs(dst []string, addrs ...net.IP) (res []string) { </s> add func appendDNSAddrs(dst []string, addrs ...netip.Addr) (res []string) { </s> remove var subnet *net.IPNet </s> add var subnet netip.Prefix
ip = a.IP maskLen, _ = ip.DefaultMask().Size()
for _, a := range addrs { switch a := a.(type) { case *net.IPAddr: ip = a.IP maskLen, _ = ip.DefaultMask().Size() ip = a.IP maskLen, _ = ip.DefaultMask().Size() ip = a.IP maskLen, _ = ip.DefaultMask().Size() ip = a.IP maskLen, _ = ip.DefaultMask().Size() case *net.IPNet: subnet = a default: continue }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/dhcp_unix.go
IP: a.IP, Mask: a.IP.DefaultMask(), } case *net.IPNet: subnet = a default: continue } if ip4 := subnet.IP.To4(); ip4 != nil {
</s> remove subnet = &net.IPNet{ IP: a.IP, Mask: a.IP.DefaultMask(), } </s> add ip = a.IP maskLen, _ = ip.DefaultMask().Size() </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 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 ip4 := reqIP.To4(); ip4 == nil { </s> add ip4 := reqIP.To4() if ip4 == nil {
ip = a.IP maskLen, _ = a.Mask.Size()
IP: a.IP, Mask: a.IP.DefaultMask(), } case *net.IPNet: ip = a.IP maskLen, _ = a.Mask.Size() default: continue } if ip4 := subnet.IP.To4(); ip4 != nil {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/dhcp_unix.go
default: continue } if ip4 := subnet.IP.To4(); ip4 != nil { subnet.IP = ip4 return subnet, nil } } return nil, fmt.Errorf("interface %s has no ipv4 addresses", iface.Name) }
</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 subnet = a </s> add ip = a.IP maskLen, _ = a.Mask.Size() </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 ip4 := reqIP.To4(); ip4 == nil { </s> add ip4 := reqIP.To4() if ip4 == nil { </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
if ip = ip.To4(); ip != nil { return netip.PrefixFrom(netip.AddrFrom4(*(*[4]byte)(ip)), maskLen), nil
default: continue } if ip = ip.To4(); ip != nil { return netip.PrefixFrom(netip.AddrFrom4(*(*[4]byte)(ip)), maskLen), nil if ip = ip.To4(); ip != nil { return netip.PrefixFrom(netip.AddrFrom4(*(*[4]byte)(ip)), maskLen), nil if ip = ip.To4(); ip != nil { return netip.PrefixFrom(netip.AddrFrom4(*(*[4]byte)(ip)), maskLen), nil if ip = ip.To4(); ip != nil { return netip.PrefixFrom(netip.AddrFrom4(*(*[4]byte)(ip)), maskLen), nil } } return nil, fmt.Errorf("interface %s has no ipv4 addresses", iface.Name) }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/dhcp_unix.go
return subnet, nil } } return nil, fmt.Errorf("interface %s has no ipv4 addresses", iface.Name) } // checkOtherDHCPv4 sends a DHCP request to the specified network interface, and // waits for a response for a period defined by defaultDiscoverTime. func checkOtherDHCPv4(iface *net.Interface) (ok bool, err error) {
</s> remove var subnet *net.IPNet </s> add var subnet netip.Prefix </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 return nil, err </s> add return netip.Prefix{}, err </s> remove if !s.conf.subnet.Contains(reqIP) { </s> add if !s.conf.subnet.Contains(netip.AddrFrom4(*(*[4]byte)(ip4))) {
return netip.Prefix{}, fmt.Errorf("interface %s has no ipv4 addresses", iface.Name)
return subnet, nil } } return netip.Prefix{}, fmt.Errorf("interface %s has no ipv4 addresses", iface.Name) } // checkOtherDHCPv4 sends a DHCP request to the specified network interface, and // waits for a response for a period defined by defaultDiscoverTime. func checkOtherDHCPv4(iface *net.Interface) (ok bool, err error) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/dhcp_unix.go
// checkOtherDHCPv4 sends a DHCP request to the specified network interface, and // waits for a response for a period defined by defaultDiscoverTime. func checkOtherDHCPv4(iface *net.Interface) (ok bool, err error) { var subnet *net.IPNet if subnet, err = ifaceIPv4Subnet(iface); err != nil { return false, err } // Resolve broadcast addr.
</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 return nil, err </s> add return netip.Prefix{}, err </s> remove dst := netutil.IPPort{ IP: BroadcastFromIPNet(subnet), Port: 67, }.String() </s> add dst := netip.AddrPortFrom(BroadcastFromPref(subnet), 67).String() </s> remove func ifaceIPv4Subnet(iface *net.Interface) (subnet *net.IPNet, err error) { </s> add func ifaceIPv4Subnet(iface *net.Interface) (subnet netip.Prefix, err error) { </s> remove func GetSubnet(ifaceName string) *net.IPNet { </s> add func GetSubnet(ifaceName string) (p netip.Prefix) {
var subnet netip.Prefix
// checkOtherDHCPv4 sends a DHCP request to the specified network interface, and // waits for a response for a period defined by defaultDiscoverTime. func checkOtherDHCPv4(iface *net.Interface) (ok bool, err error) { var subnet netip.Prefix if subnet, err = ifaceIPv4Subnet(iface); err != nil { return false, err } // Resolve broadcast addr.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/dhcp_unix.go
return false, err } // Resolve broadcast addr. dst := netutil.IPPort{ IP: BroadcastFromIPNet(subnet), Port: 67, }.String() var dstAddr *net.UDPAddr if dstAddr, err = net.ResolveUDPAddr("udp4", dst); err != nil { return false, fmt.Errorf("couldn't resolve UDP address %s: %w", dst, err) }
</s> remove var subnet *net.IPNet </s> add var subnet netip.Prefix </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 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 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 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)
dst := netip.AddrPortFrom(BroadcastFromPref(subnet), 67).String()
return false, err } // Resolve broadcast addr. dst := netip.AddrPortFrom(BroadcastFromPref(subnet), 67).String() dst := netip.AddrPortFrom(BroadcastFromPref(subnet), 67).String() dst := netip.AddrPortFrom(BroadcastFromPref(subnet), 67).String() dst := netip.AddrPortFrom(BroadcastFromPref(subnet), 67).String() var dstAddr *net.UDPAddr if dstAddr, err = net.ResolveUDPAddr("udp4", dst); err != nil { return false, fmt.Errorf("couldn't resolve UDP address %s: %w", dst, err) }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/dhcp_unix.go
// done is the channel to sign closing the container. done chan struct{} // updates is the channel for receiving updated hosts. updates chan *netutil.IPMap // last is the set of hosts that was cached within last detected change. //
</s> remove broadcastIP net.IP </s> add broadcastIP netip.Addr </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 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
// // TODO(e.burkov): Use map[netip.Addr]struct{} instead.
// done is the channel to sign closing the container. done chan struct{} // updates is the channel for receiving updated hosts. // // TODO(e.burkov): Use map[netip.Addr]struct{} instead. updates chan *netutil.IPMap // last is the set of hosts that was cached within last detected change. //
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/hostscontainer.go
// TODO(e.burkov): Use map[netip.Addr]struct{} instead. updates chan *netutil.IPMap // last is the set of hosts that was cached within last detected change. last *netutil.IPMap // fsys is the working file system to read hosts files from. fsys fs.FS
</s> remove broadcastIP net.IP </s> add broadcastIP netip.Addr
// // TODO(e.burkov): Use map[netip.Addr]struct{} instead.
// TODO(e.burkov): Use map[netip.Addr]struct{} instead. updates chan *netutil.IPMap // last is the set of hosts that was cached within last detected change. // // TODO(e.burkov): Use map[netip.Addr]struct{} instead. last *netutil.IPMap // fsys is the working file system to read hosts files from. fsys fs.FS
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/hostscontainer.go
"encoding/json" "fmt" "io" "net" "syscall" "github.com/AdguardTeam/AdGuardHome/internal/aghos" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log"
</s> remove "net" </s> add "net/netip" </s> remove "net" </s> add </s> remove "github.com/AdguardTeam/golibs/netutil" </s> add
"net/netip"
"encoding/json" "fmt" "io" "net" "net/netip" "syscall" "github.com/AdguardTeam/AdGuardHome/internal/aghos" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log"
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
"github.com/AdguardTeam/AdGuardHome/internal/aghos" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/netutil" ) // Variables and functions to substitute in tests. var ( // aghosRunCommand is the function to run shell commands.
</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},
"github.com/AdguardTeam/AdGuardHome/internal/aghos" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" ) // Variables and functions to substitute in tests. var ( // aghosRunCommand is the function to run shell commands.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
// ErrNoStaticIPInfo is returned by IfaceHasStaticIP when no information about // the IP being static is available. const ErrNoStaticIPInfo errors.Error = "no information about static ip" // IfaceHasStaticIP checks if interface is configured to have static IP address. // If it can't give a definitive answer, it returns false and an error for which // errors.Is(err, ErrNoStaticIPInfo) is true. func IfaceHasStaticIP(ifaceName string) (has bool, err error) { return ifaceHasStaticIP(ifaceName)
</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) {
// 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}) }
// ErrNoStaticIPInfo is returned by IfaceHasStaticIP when no information about // the IP being static is available. const ErrNoStaticIPInfo errors.Error = "no information about static ip" // 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}) } // IfaceHasStaticIP checks if interface is configured to have static IP address. // If it can't give a definitive answer, it returns false and an error for which // errors.Is(err, ErrNoStaticIPInfo) is true. func IfaceHasStaticIP(ifaceName string) (has bool, err error) { return ifaceHasStaticIP(ifaceName)
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
// GatewayIP returns IP address of interface's gateway. // // TODO(e.burkov): Investigate if the gateway address may be fetched in another // way since not every machine has the software installed. func GatewayIP(ifaceName string) (ip net.IP) { code, out, err := aghosRunCommand("ip", "route", "show", "dev", ifaceName) if err != nil { log.Debug("%s", err) return nil
</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 // 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)
func GatewayIP(ifaceName string) (ip netip.Addr) {
// GatewayIP returns IP address of interface's gateway. // // TODO(e.burkov): Investigate if the gateway address may be fetched in another // way since not every machine has the software installed. func GatewayIP(ifaceName string) (ip netip.Addr) { code, out, err := aghosRunCommand("ip", "route", "show", "dev", ifaceName) if err != nil { log.Debug("%s", err) return nil
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
code, out, err := aghosRunCommand("ip", "route", "show", "dev", ifaceName) if err != nil { log.Debug("%s", err) return nil } else if code != 0 { log.Debug("fetching gateway ip: unexpected exit code: %d", code) return nil }
</s> remove return nil </s> add return netip.Addr{} </s> remove func GatewayIP(ifaceName string) (ip net.IP) { </s> add func GatewayIP(ifaceName string) (ip netip.Addr) { </s> remove return nil </s> add return p </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 v4conf.Enabled = s.conf.Enabled && len(v4conf.RangeStart) != 0 </s> add v4conf.Enabled = s.conf.Enabled && v4conf.RangeStart.IsValid()
return netip.Addr{}
code, out, err := aghosRunCommand("ip", "route", "show", "dev", ifaceName) if err != nil { log.Debug("%s", err) return netip.Addr{} } else if code != 0 { log.Debug("fetching gateway ip: unexpected exit code: %d", code) return nil }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
return nil } else if code != 0 { log.Debug("fetching gateway ip: unexpected exit code: %d", code) return nil } fields := bytes.Fields(out) // The meaningful "ip route" command output should contain the word // "default" at first field and default gateway IP address at third field.
</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) {
return netip.Addr{}
return nil } else if code != 0 { log.Debug("fetching gateway ip: unexpected exit code: %d", code) return netip.Addr{} } fields := bytes.Fields(out) // The meaningful "ip route" command output should contain the word // "default" at first field and default gateway IP address at third field.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
fields := bytes.Fields(out) // The meaningful "ip route" command output should contain the word // "default" at first field and default gateway IP address at third field. if len(fields) < 3 || string(fields[0]) != "default" { return nil } return net.ParseIP(string(fields[2])) }
</s> remove return nil </s> add return netip.Addr{} </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 </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 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"`
return netip.Addr{}
fields := bytes.Fields(out) // The meaningful "ip route" command output should contain the word // "default" at first field and default gateway IP address at third field. if len(fields) < 3 || string(fields[0]) != "default" { return netip.Addr{} } return net.ParseIP(string(fields[2])) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
if len(fields) < 3 || string(fields[0]) != "default" { return nil } return net.ParseIP(string(fields[2])) } // CanBindPrivilegedPorts checks if current process can bind to privileged // ports. func CanBindPrivilegedPorts() (can bool, err error) {
</s> remove return nil </s> add return netip.Addr{} </s> remove if ipNet.IP == nil { </s> add if !ipNet.Addr().IsValid() { </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 var subnet *net.IPNet </s> add var subnet netip.Prefix </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
ip, err = netip.ParseAddr(string(fields[2])) if err != nil { return netip.Addr{} } return ip
if len(fields) < 3 || string(fields[0]) != "default" { return nil } ip, err = netip.ParseAddr(string(fields[2])) if err != nil { return netip.Addr{} } return ip } // CanBindPrivilegedPorts checks if current process can bind to privileged // ports. func CanBindPrivilegedPorts() (can bool, err error) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
// NetInterface represents an entry of network interfaces map. type NetInterface struct { // Addresses are the network interface addresses. Addresses []net.IP `json:"ip_addresses,omitempty"` // Subnets are the IP networks for this network interface. Subnets []*net.IPNet `json:"-"` Name string `json:"name"` HardwareAddr net.HardwareAddr `json:"hardware_address"` Flags net.Flags `json:"flags"`
</s> remove Subnets []*net.IPNet `json:"-"` </s> add Subnets []netip.Prefix `json:"-"` </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"`
Addresses []netip.Addr `json:"ip_addresses,omitempty"`
// NetInterface represents an entry of network interfaces map. type NetInterface struct { // Addresses are the network interface addresses. Addresses []netip.Addr `json:"ip_addresses,omitempty"` // Subnets are the IP networks for this network interface. Subnets []*net.IPNet `json:"-"` Name string `json:"name"` HardwareAddr net.HardwareAddr `json:"hardware_address"` Flags net.Flags `json:"flags"`
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
type NetInterface struct { // Addresses are the network interface addresses. Addresses []net.IP `json:"ip_addresses,omitempty"` // Subnets are the IP networks for this network interface. Subnets []*net.IPNet `json:"-"` Name string `json:"name"` HardwareAddr net.HardwareAddr `json:"hardware_address"` Flags net.Flags `json:"flags"` MTU int `json:"mtu"` }
</s> remove Addresses []net.IP `json:"ip_addresses,omitempty"` </s> add Addresses []netip.Addr `json:"ip_addresses,omitempty"` </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"` </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"`
Subnets []netip.Prefix `json:"-"`
type NetInterface struct { // Addresses are the network interface addresses. Addresses []net.IP `json:"ip_addresses,omitempty"` // Subnets are the IP networks for this network interface. Subnets []netip.Prefix `json:"-"` Name string `json:"name"` HardwareAddr net.HardwareAddr `json:"hardware_address"` Flags net.Flags `json:"flags"` MTU int `json:"mtu"` }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
netInterface: netInterface(iface), }) } // 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() if err != nil { 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> 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 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) {
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()
netInterface: netInterface(iface), }) } 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() 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() 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() 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() 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() 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() 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() if err != nil { 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") }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
// substitute net.Interface.Addrs and the net.InterfaceAddrs can't be used. func GetValidNetInterfacesForWeb() (netIfaces []*NetInterface, err error) { ifaces, err := net.Interfaces() if err != nil { 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") } for _, iface := range ifaces { var addrs []net.Addr addrs, err = iface.Addrs()
</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 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 return nil, err </s> add return netip.Prefix{}, err </s> remove func ifaceIPv4Subnet(iface *net.Interface) (subnet *net.IPNet, err error) { </s> add func ifaceIPv4Subnet(iface *net.Interface) (subnet netip.Prefix, err error) {
return nil, fmt.Errorf("failed to get addresses for interface %s: %w", iface.Name, err)
// substitute net.Interface.Addrs and the net.InterfaceAddrs can't be used. func GetValidNetInterfacesForWeb() (netIfaces []*NetInterface, err error) { ifaces, err := net.Interfaces() if err != nil { return nil, fmt.Errorf("failed to get addresses for interface %s: %w", iface.Name, err) return nil, fmt.Errorf("failed to get addresses for interface %s: %w", iface.Name, err) return nil, fmt.Errorf("failed to get addresses for interface %s: %w", iface.Name, err) } for _, iface := range ifaces { var addrs []net.Addr addrs, err = iface.Addrs()
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
} else if len(ifaces) == 0 { return nil, errors.Error("couldn't find any legible interface") } 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) } netIface := &NetInterface{ MTU: iface.MTU, Name: iface.Name,
</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 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 // 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 // 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)
// 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
} else if len(ifaces) == 0 { return nil, errors.Error("couldn't find any legible interface") } // 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 // 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 // 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 // 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 // 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 } netIface := &NetInterface{ MTU: iface.MTU, Name: iface.Name,
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
if err != nil { return nil, fmt.Errorf("failed to get addresses for interface %s: %w", iface.Name, err) } netIface := &NetInterface{ MTU: iface.MTU, Name: iface.Name, HardwareAddr: iface.HardwareAddr, Flags: iface.Flags, } // Collect network interface addresses. for _, addr := range addrs { ipNet, ok := addr.(*net.IPNet)
</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 // 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 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 </s> add return p
ip, ok := netip.AddrFromSlice(n.IP) if !ok { return nil, fmt.Errorf("bad address %s", n.IP)
if err != nil { return nil, fmt.Errorf("failed to get addresses for interface %s: %w", iface.Name, err) } ip, ok := netip.AddrFromSlice(n.IP) if !ok { return nil, fmt.Errorf("bad address %s", n.IP) ip, ok := netip.AddrFromSlice(n.IP) if !ok { return nil, fmt.Errorf("bad address %s", n.IP) ip, ok := netip.AddrFromSlice(n.IP) if !ok { return nil, fmt.Errorf("bad address %s", n.IP) ip, ok := netip.AddrFromSlice(n.IP) if !ok { return nil, fmt.Errorf("bad address %s", n.IP) ip, ok := netip.AddrFromSlice(n.IP) if !ok { return nil, fmt.Errorf("bad address %s", n.IP) } // Collect network interface addresses. for _, addr := range addrs { ipNet, ok := addr.(*net.IPNet)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
HardwareAddr: iface.HardwareAddr, Flags: iface.Flags, } // 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() { continue } netIface.Addresses = append(netIface.Addresses, ipNet.IP) netIface.Subnets = append(netIface.Subnets, ipNet)
</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 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 addr := netutil.IPPort{IP: ip, Port: port}.String() </s> add addr := ipp.String()
ip = ip.Unmap() if ip.IsLinkLocalUnicast() { // Ignore link-local IPv4. if ip.Is4() {
HardwareAddr: iface.HardwareAddr, Flags: iface.Flags, } ip = ip.Unmap() if ip.IsLinkLocalUnicast() { // Ignore link-local IPv4. if ip.Is4() { ip = ip.Unmap() if ip.IsLinkLocalUnicast() { // Ignore link-local IPv4. if ip.Is4() { ip = ip.Unmap() if ip.IsLinkLocalUnicast() { // Ignore link-local IPv4. if ip.Is4() { ip = ip.Unmap() if ip.IsLinkLocalUnicast() { // Ignore link-local IPv4. if ip.Is4() { ip = ip.Unmap() if ip.IsLinkLocalUnicast() { // Ignore link-local IPv4. if ip.Is4() { ip = ip.Unmap() if ip.IsLinkLocalUnicast() { // Ignore link-local IPv4. if ip.Is4() { ip = ip.Unmap() if ip.IsLinkLocalUnicast() { // Ignore link-local IPv4. if ip.Is4() { ip = ip.Unmap() if ip.IsLinkLocalUnicast() { // Ignore link-local IPv4. if ip.Is4() { ip = ip.Unmap() if ip.IsLinkLocalUnicast() { // Ignore link-local IPv4. if ip.Is4() { ip = ip.Unmap() if ip.IsLinkLocalUnicast() { // Ignore link-local IPv4. if ip.Is4() { continue } netIface.Addresses = append(netIface.Addresses, ipNet.IP) netIface.Subnets = append(netIface.Subnets, ipNet)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
if ipNet.IP.IsLinkLocalUnicast() { continue } netIface.Addresses = append(netIface.Addresses, ipNet.IP) netIface.Subnets = append(netIface.Subnets, ipNet) } // Discard interfaces with no addresses. if len(netIface.Addresses) != 0 { netIfaces = append(netIfaces, netIface)
</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 // 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 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 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 return netIfaces, nil </s> add return nifaces, nil
ip = ip.WithZone(iface.Name)
if ipNet.IP.IsLinkLocalUnicast() { continue } ip = ip.WithZone(iface.Name) ip = ip.WithZone(iface.Name) } // Discard interfaces with no addresses. if len(netIface.Addresses) != 0 { netIfaces = append(netIfaces, netIface)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
netIface.Addresses = append(netIface.Addresses, ipNet.IP) netIface.Subnets = append(netIface.Subnets, ipNet) } // Discard interfaces with no addresses. if len(netIface.Addresses) != 0 { netIfaces = append(netIfaces, netIface) } } return netIfaces, nil }
</s> remove netIface.Addresses = append(netIface.Addresses, ipNet.IP) netIface.Subnets = append(netIface.Subnets, ipNet) </s> add ip = ip.WithZone(iface.Name) </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 return netIfaces, nil </s> add return nifaces, nil </s> remove return nil </s> add return p </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
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)
netIface.Addresses = append(netIface.Addresses, ipNet.IP) netIface.Subnets = append(netIface.Subnets, ipNet) } 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) 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) 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) } } return netIfaces, nil }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
netIfaces = append(netIfaces, netIface) } } return netIfaces, nil } // InterfaceByIP returns the name of the interface bound to ip. // // TODO(a.garipov, e.burkov): This function is technically incorrect, since one
</s> remove func InterfaceByIP(ip net.IP) (ifaceName string) { </s> add func InterfaceByIP(ip netip.Addr) (ifaceName string) { </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 // 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) </s> remove func GetSubnet(ifaceName string) *net.IPNet { </s> add func GetSubnet(ifaceName string) (p netip.Prefix) {
return nifaces, nil
netIfaces = append(netIfaces, netIface) } } return nifaces, nil } // InterfaceByIP returns the name of the interface bound to ip. // // TODO(a.garipov, e.burkov): This function is technically incorrect, since one
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
// TODO(a.garipov, e.burkov): This function is technically incorrect, since one // IP address can be shared by multiple interfaces in some configurations. // // TODO(e.burkov): See TODO on GetValidNetInterfacesForWeb. func InterfaceByIP(ip net.IP) (ifaceName string) { ifaces, err := GetValidNetInterfacesForWeb() if err != nil { return "" }
</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()
func InterfaceByIP(ip netip.Addr) (ifaceName string) {
// TODO(a.garipov, e.burkov): This function is technically incorrect, since one // IP address can be shared by multiple interfaces in some configurations. // // TODO(e.burkov): See TODO on GetValidNetInterfacesForWeb. func InterfaceByIP(ip netip.Addr) (ifaceName string) { ifaces, err := GetValidNetInterfacesForWeb() if err != nil { return "" }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
} for _, iface := range ifaces { for _, addr := range iface.Addresses { if ip.Equal(addr) { return iface.Name } } }
</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))))
if ip == addr {
} for _, iface := range ifaces { for _, addr := range iface.Addresses { if ip == addr { return iface.Name } } }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
return "" } // GetSubnet returns pointer to net.IPNet for the specified interface or nil if // the search fails. // // TODO(e.burkov): See TODO on GetValidNetInterfacesForWeb. func GetSubnet(ifaceName string) *net.IPNet { netIfaces, err := GetValidNetInterfacesForWeb()
</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) { </s> remove return nil </s> add return p </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) {
// GetSubnet returns the subnet corresponding to the interface of zero prefix if
return "" } // GetSubnet returns the subnet corresponding to the interface of zero prefix if // the search fails. // // TODO(e.burkov): See TODO on GetValidNetInterfacesForWeb. func GetSubnet(ifaceName string) *net.IPNet { netIfaces, err := GetValidNetInterfacesForWeb()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
// GetSubnet returns pointer to net.IPNet for the specified interface or nil if // the search fails. // // TODO(e.burkov): See TODO on GetValidNetInterfacesForWeb. func GetSubnet(ifaceName string) *net.IPNet { netIfaces, err := GetValidNetInterfacesForWeb() if err != nil { log.Error("Could not get network interfaces info: %v", err) return nil }
</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 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) {
func GetSubnet(ifaceName string) (p netip.Prefix) {
// GetSubnet returns pointer to net.IPNet for the specified interface or nil if // the search fails. // // TODO(e.burkov): See TODO on GetValidNetInterfacesForWeb. func GetSubnet(ifaceName string) (p netip.Prefix) { netIfaces, err := GetValidNetInterfacesForWeb() if err != nil { log.Error("Could not get network interfaces info: %v", err) return nil }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
func GetSubnet(ifaceName string) *net.IPNet { netIfaces, err := GetValidNetInterfacesForWeb() if err != nil { log.Error("Could not get network interfaces info: %v", err) return nil } for _, netIface := range netIfaces { if netIface.Name == ifaceName && len(netIface.Subnets) > 0 { return netIface.Subnets[0]
</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() {
return p
func GetSubnet(ifaceName string) *net.IPNet { netIfaces, err := GetValidNetInterfacesForWeb() if err != nil { log.Error("Could not get network interfaces info: %v", err) return p } for _, netIface := range netIfaces { if netIface.Name == ifaceName && len(netIface.Subnets) > 0 { return netIface.Subnets[0]
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
return netIface.Subnets[0] } } return nil } // CheckPort checks if the port is available for binding. network is expected // to be one of "udp" and "tcp". func CheckPort(network string, ip net.IP, port int) (err error) {
</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 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 return aghnet.CheckPort("tcp", req.Web.IP, portInt) </s> add return aghnet.CheckPort("tcp", netip.AddrPortFrom(req.Web.IP, uint16(portInt)))
return p
return netIface.Subnets[0] } } return p } // CheckPort checks if the port is available for binding. network is expected // to be one of "udp" and "tcp". func CheckPort(network string, ip net.IP, port int) (err error) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
} // CheckPort checks if the port is available for binding. network is expected // to be one of "udp" and "tcp". func CheckPort(network string, ip net.IP, port int) (err error) { var c io.Closer addr := netutil.IPPort{IP: ip, Port: port}.String() switch network { case "tcp": c, err = net.Listen(network, addr)
</s> remove addr := netutil.IPPort{IP: ip, Port: port}.String() </s> add addr := ipp.String() </s> remove return nil </s> add return p </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 func ipsToUDPAddrs(ips []net.IP, port int) (udpAddrs []*net.UDPAddr) { </s> add func ipsToUDPAddrs(ips []netip.Addr, port int) (udpAddrs []*net.UDPAddr) {
func CheckPort(network string, ipp netip.AddrPort) (err error) {
} // CheckPort checks if the port is available for binding. network is expected // to be one of "udp" and "tcp". func CheckPort(network string, ipp netip.AddrPort) (err error) { var c io.Closer addr := netutil.IPPort{IP: ip, Port: port}.String() switch network { case "tcp": c, err = net.Listen(network, addr)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
// CheckPort checks if the port is available for binding. network is expected // to be one of "udp" and "tcp". func CheckPort(network string, ip net.IP, port int) (err error) { var c io.Closer addr := netutil.IPPort{IP: ip, Port: port}.String() switch network { case "tcp": c, err = net.Listen(network, addr) case "udp": c, err = net.ListenPacket(network, addr)
</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> 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
addr := ipp.String()
// CheckPort checks if the port is available for binding. network is expected // to be one of "udp" and "tcp". func CheckPort(network string, ip net.IP, port int) (err error) { var c io.Closer addr := ipp.String() switch network { case "tcp": c, err = net.Listen(network, addr) case "udp": c, err = net.ListenPacket(network, addr)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
return addrs, nil } // BroadcastFromIPNet calculates the broadcast IP address for n. func BroadcastFromIPNet(n *net.IPNet) (dc net.IP) { dc = netutil.CloneIP(n.IP) mask := n.Mask if mask == nil { mask = dc.DefaultMask() }
</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 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 if ip4 := reqIP.To4(); ip4 == nil { </s> add ip4 := reqIP.To4() if ip4 == nil { </s> remove func GatewayIP(ifaceName string) (ip net.IP) { </s> add func GatewayIP(ifaceName string) (ip netip.Addr) {
// 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{} }
return addrs, nil } // 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{} } // 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{} } // 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{} } mask := n.Mask if mask == nil { mask = dc.DefaultMask() }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
// BroadcastFromIPNet calculates the broadcast IP address for n. func BroadcastFromIPNet(n *net.IPNet) (dc net.IP) { dc = netutil.CloneIP(n.IP) mask := n.Mask if mask == nil { mask = dc.DefaultMask() } for i, b := range mask { dc[i] |= ^b }
</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 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 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))))
maskLen, addrLen := p.Bits(), bc.BitLen() if maskLen == addrLen { return bc
// BroadcastFromIPNet calculates the broadcast IP address for n. func BroadcastFromIPNet(n *net.IPNet) (dc net.IP) { dc = netutil.CloneIP(n.IP) maskLen, addrLen := p.Bits(), bc.BitLen() if maskLen == addrLen { return bc maskLen, addrLen := p.Bits(), bc.BitLen() if maskLen == addrLen { return bc maskLen, addrLen := p.Bits(), bc.BitLen() if maskLen == addrLen { return bc } for i, b := range mask { dc[i] |= ^b }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
if mask == nil { mask = dc.DefaultMask() } for i, b := range mask { dc[i] |= ^b } return dc }
</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))))
ipBytes := bc.AsSlice() for i := maskLen; i < addrLen; i++ { ipBytes[i/8] |= 1 << (7 - (i % 8))
if mask == nil { mask = dc.DefaultMask() } ipBytes := bc.AsSlice() for i := maskLen; i < addrLen; i++ { ipBytes[i/8] |= 1 << (7 - (i % 8)) ipBytes := bc.AsSlice() for i := maskLen; i < addrLen; i++ { ipBytes[i/8] |= 1 << (7 - (i % 8)) } return dc }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
ipBytes := bc.AsSlice() for i := maskLen; i < addrLen; i++ { ipBytes[i/8] |= 1 << (7 - (i % 8)) } return bc }
</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)
bc, _ = netip.AddrFromSlice(ipBytes)
ipBytes := bc.AsSlice() for i := maskLen; i < addrLen; i++ { ipBytes[i/8] |= 1 << (7 - (i % 8)) } bc, _ = netip.AddrFromSlice(ipBytes) return bc }
[ "keep", "keep", "keep", "add", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
for i, b := range mask { dc[i] |= ^b } return dc }
</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))))
return bc
for i, b := range mask { dc[i] |= ^b } return bc }
[ "keep", "keep", "keep", "keep", "replace", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net.go
import ( "bufio" "fmt" "io" "net" "os" "strings" "github.com/AdguardTeam/AdGuardHome/internal/aghos" "github.com/AdguardTeam/golibs/errors"
</s> remove "net" </s> add "net/netip" </s> remove "net" </s> add
"net/netip"
import ( "bufio" "fmt" "io" "net/netip" "os" "strings" "github.com/AdguardTeam/AdGuardHome/internal/aghos" "github.com/AdguardTeam/golibs/errors"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_linux.go
// ifaceSetStaticIP configures the system to retain its current IP on the // interface through dhcpcd.conf. func ifaceSetStaticIP(ifaceName string) (err error) { ipNet := GetSubnet(ifaceName) if ipNet.IP == nil { return errors.Error("can't get IP address") } body, err := os.ReadFile(dhcpcdConf) if err != nil && !errors.Is(err, os.ErrNotExist) {
</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) {
if !ipNet.Addr().IsValid() {
// ifaceSetStaticIP configures the system to retain its current IP on the // interface through dhcpcd.conf. func ifaceSetStaticIP(ifaceName string) (err error) { ipNet := GetSubnet(ifaceName) if !ipNet.Addr().IsValid() { return errors.Error("can't get IP address") } body, err := os.ReadFile(dhcpcdConf) if err != nil && !errors.Is(err, os.ErrNotExist) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_linux.go
} // dhcpcdConfIface returns configuration lines for the dhcpdc.conf files that // configure the interface to have a static IP. func dhcpcdConfIface(ifaceName string, ipNet *net.IPNet, gwIP net.IP) (conf string) { b := &strings.Builder{} stringutil.WriteToBuilder( b, "\n# ", ifaceName,
</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() {
func dhcpcdConfIface(ifaceName string, subnet netip.Prefix, gateway netip.Addr) (conf string) {
} // dhcpcdConfIface returns configuration lines for the dhcpdc.conf files that // configure the interface to have a static IP. func dhcpcdConfIface(ifaceName string, subnet netip.Prefix, gateway netip.Addr) (conf string) { b := &strings.Builder{} stringutil.WriteToBuilder( b, "\n# ", ifaceName,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_linux.go
ifaceName, " added by AdGuard Home.\ninterface ", ifaceName, "\nstatic ip_address=", ipNet.String(), "\n", ) if gwIP != nil { stringutil.WriteToBuilder(b, "static routers=", gwIP.String(), "\n")
</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 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 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 err := aghnet.CheckPort("tcp", net.IP{127, 0, 0, 1}, defaultPortDNS) </s> add err := aghnet.CheckPort("tcp", netip.AddrPortFrom(aghnet.IPv4Localhost(), defaultPortDNS)) </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)) {
subnet.String(),
ifaceName, " added by AdGuard Home.\ninterface ", ifaceName, "\nstatic ip_address=", subnet.String(), "\n", ) if gwIP != nil { stringutil.WriteToBuilder(b, "static routers=", gwIP.String(), "\n")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_linux.go
ipNet.String(), "\n", ) if gwIP != nil { stringutil.WriteToBuilder(b, "static routers=", gwIP.String(), "\n") } stringutil.WriteToBuilder(b, "static domain_name_servers=", ipNet.IP.String(), "\n\n") return b.String()
</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 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 if !c.subnet.Contains(c.RangeStart) { </s> add if !c.subnet.Contains(rangeStart) {
if gateway != (netip.Addr{}) { stringutil.WriteToBuilder(b, "static routers=", gateway.String(), "\n")
ipNet.String(), "\n", ) if gateway != (netip.Addr{}) { stringutil.WriteToBuilder(b, "static routers=", gateway.String(), "\n") if gateway != (netip.Addr{}) { stringutil.WriteToBuilder(b, "static routers=", gateway.String(), "\n") } stringutil.WriteToBuilder(b, "static domain_name_servers=", ipNet.IP.String(), "\n\n") return b.String()
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_linux.go
if gwIP != nil { stringutil.WriteToBuilder(b, "static routers=", gwIP.String(), "\n") } stringutil.WriteToBuilder(b, "static domain_name_servers=", ipNet.IP.String(), "\n\n") return b.String() }
</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{}
stringutil.WriteToBuilder(b, "static domain_name_servers=", subnet.Addr().String(), "\n\n")
if gwIP != nil { stringutil.WriteToBuilder(b, "static routers=", gwIP.String(), "\n") } stringutil.WriteToBuilder(b, "static domain_name_servers=", subnet.Addr().String(), "\n\n") return b.String() }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_linux.go
"encoding/json" "fmt" "io/fs" "net" "os" "strings" "testing" "github.com/AdguardTeam/AdGuardHome/internal/aghtest" "github.com/AdguardTeam/golibs/errors"
</s> remove "net" </s> add "net/netip"
"net/netip"
"encoding/json" "fmt" "io/fs" "net" "net/netip" "os" "strings" "testing" "github.com/AdguardTeam/AdGuardHome/internal/aghtest" "github.com/AdguardTeam/golibs/errors"
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
const ifaceName = "ifaceName" const cmd = "ip route show dev " + ifaceName testCases := []struct { name string shell mapShell want net.IP }{{ name: "success_v4", shell: theOnlyCmd(cmd, 0, `default via 1.2.3.4 onlink`, nil),
</s> remove want net.IP </s> add want netip.Addr name string </s> remove name: "success_v4", </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_v6", </s> add </s> remove name: "err_runcmd", </s> add
const ifaceName = "ifaceName" const cmd = "ip route show dev " + ifaceName testCases := []struct { shell mapShell want net.IP }{{ name: "success_v4", shell: theOnlyCmd(cmd, 0, `default via 1.2.3.4 onlink`, nil),
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
testCases := []struct { name string shell mapShell want net.IP }{{ name: "success_v4", shell: theOnlyCmd(cmd, 0, `default via 1.2.3.4 onlink`, nil), want: net.IP{1, 2, 3, 4}.To16(), }, {
</s> remove name: "success_v4", </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 string </s> add </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",
want netip.Addr name string
testCases := []struct { name string shell mapShell want netip.Addr name string }{{ name: "success_v4", shell: theOnlyCmd(cmd, 0, `default via 1.2.3.4 onlink`, nil), want: net.IP{1, 2, 3, 4}.To16(), }, {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
name string shell mapShell want net.IP }{{ name: "success_v4", shell: theOnlyCmd(cmd, 0, `default via 1.2.3.4 onlink`, nil), want: net.IP{1, 2, 3, 4}.To16(), }, { name: "success_v6", shell: theOnlyCmd(cmd, 0, `default via ::ffff onlink`, nil),
</s> remove want: net.IP{1, 2, 3, 4}.To16(), </s> add want: netip.MustParseAddr("1.2.3.4"), name: "success_v4", </s> remove want net.IP </s> add want netip.Addr name string </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 name string </s> add
name string shell mapShell want net.IP }{{ shell: theOnlyCmd(cmd, 0, `default via 1.2.3.4 onlink`, nil), want: net.IP{1, 2, 3, 4}.To16(), }, { name: "success_v6", shell: theOnlyCmd(cmd, 0, `default via ::ffff onlink`, nil),
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
want net.IP }{{ name: "success_v4", shell: theOnlyCmd(cmd, 0, `default via 1.2.3.4 onlink`, nil), want: net.IP{1, 2, 3, 4}.To16(), }, { name: "success_v6", shell: theOnlyCmd(cmd, 0, `default via ::ffff onlink`, nil), want: net.IP{ 0x0, 0x0, 0x0, 0x0,
</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 name: "success_v4", </s> add </s> remove name: "bad_output", </s> add </s> remove want net.IP </s> add want netip.Addr name string
want: netip.MustParseAddr("1.2.3.4"), name: "success_v4",
want net.IP }{{ name: "success_v4", shell: theOnlyCmd(cmd, 0, `default via 1.2.3.4 onlink`, nil), want: netip.MustParseAddr("1.2.3.4"), name: "success_v4", }, { name: "success_v6", shell: theOnlyCmd(cmd, 0, `default via ::ffff onlink`, nil), want: net.IP{ 0x0, 0x0, 0x0, 0x0,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
name: "success_v4", shell: theOnlyCmd(cmd, 0, `default via 1.2.3.4 onlink`, nil), want: net.IP{1, 2, 3, 4}.To16(), }, { name: "success_v6", shell: theOnlyCmd(cmd, 0, `default via ::ffff onlink`, nil), want: net.IP{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
</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: "bad_output", </s> add </s> remove name: "success_v4", </s> add </s> remove want net.IP </s> add want netip.Addr name string
name: "success_v4", shell: theOnlyCmd(cmd, 0, `default via 1.2.3.4 onlink`, nil), want: net.IP{1, 2, 3, 4}.To16(), }, { shell: theOnlyCmd(cmd, 0, `default via ::ffff onlink`, nil), want: net.IP{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
want: net.IP{1, 2, 3, 4}.To16(), }, { name: "success_v6", shell: theOnlyCmd(cmd, 0, `default via ::ffff onlink`, nil), want: net.IP{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0xFF, }, }, { name: "bad_output", shell: theOnlyCmd(cmd, 0, `non-default via 1.2.3.4 onlink`, nil), want: nil, }, {
</s> remove name: "success_v6", </s> add </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 want: nil, </s> add want: netip.Addr{}, name: "bad_output",
want: netip.MustParseAddr("::ffff"), name: "success_v6",
want: net.IP{1, 2, 3, 4}.To16(), }, { name: "success_v6", shell: theOnlyCmd(cmd, 0, `default via ::ffff onlink`, nil), want: netip.MustParseAddr("::ffff"), name: "success_v6", want: netip.MustParseAddr("::ffff"), name: "success_v6", want: netip.MustParseAddr("::ffff"), name: "success_v6", want: netip.MustParseAddr("::ffff"), name: "success_v6", want: netip.MustParseAddr("::ffff"), name: "success_v6", want: netip.MustParseAddr("::ffff"), name: "success_v6", }, { name: "bad_output", shell: theOnlyCmd(cmd, 0, `non-default via 1.2.3.4 onlink`, nil), want: nil, }, {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0xFF, }, }, { name: "bad_output", shell: theOnlyCmd(cmd, 0, `non-default via 1.2.3.4 onlink`, nil), want: nil, }, { name: "err_runcmd", shell: theOnlyCmd(cmd, 0, "", errors.Error("can't run command")),
</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 name: "success_v6", </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: "err_runcmd", </s> add </s> remove want: nil, </s> add want: netip.Addr{}, name: "bad_output",
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0xFF, }, }, { shell: theOnlyCmd(cmd, 0, `non-default via 1.2.3.4 onlink`, nil), want: nil, }, { name: "err_runcmd", shell: theOnlyCmd(cmd, 0, "", errors.Error("can't run command")),
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
}, }, { name: "bad_output", shell: theOnlyCmd(cmd, 0, `non-default via 1.2.3.4 onlink`, nil), want: nil, }, { name: "err_runcmd", shell: theOnlyCmd(cmd, 0, "", errors.Error("can't run command")), want: nil, }, {
</s> remove name: "err_runcmd", </s> add </s> remove name: "bad_output", </s> add </s> remove want: nil, </s> add want: netip.Addr{}, name: "err_runcmd", </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",
want: netip.Addr{}, name: "bad_output",
}, }, { name: "bad_output", shell: theOnlyCmd(cmd, 0, `non-default via 1.2.3.4 onlink`, nil), want: netip.Addr{}, name: "bad_output", }, { name: "err_runcmd", shell: theOnlyCmd(cmd, 0, "", errors.Error("can't run command")), want: nil, }, {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
name: "bad_output", shell: theOnlyCmd(cmd, 0, `non-default via 1.2.3.4 onlink`, nil), want: nil, }, { name: "err_runcmd", shell: theOnlyCmd(cmd, 0, "", errors.Error("can't run command")), want: nil, }, { name: "bad_code", shell: theOnlyCmd(cmd, 1, "", nil),
</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",
name: "bad_output", shell: theOnlyCmd(cmd, 0, `non-default via 1.2.3.4 onlink`, nil), want: nil, }, { shell: theOnlyCmd(cmd, 0, "", errors.Error("can't run command")), want: nil, }, { name: "bad_code", shell: theOnlyCmd(cmd, 1, "", nil),
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
want: nil, }, { name: "err_runcmd", shell: theOnlyCmd(cmd, 0, "", errors.Error("can't run command")), want: nil, }, { name: "bad_code", shell: theOnlyCmd(cmd, 1, "", nil), want: nil, }}
</s> remove name: "bad_code", </s> add </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",
want: netip.Addr{}, name: "err_runcmd",
want: nil, }, { name: "err_runcmd", shell: theOnlyCmd(cmd, 0, "", errors.Error("can't run command")), want: netip.Addr{}, name: "err_runcmd", }, { name: "bad_code", shell: theOnlyCmd(cmd, 1, "", nil), want: nil, }}
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
name: "err_runcmd", shell: theOnlyCmd(cmd, 0, "", errors.Error("can't run command")), want: nil, }, { name: "bad_code", shell: theOnlyCmd(cmd, 1, "", nil), want: nil, }} for _, tc := range testCases {
</s> remove want: nil, </s> add want: netip.Addr{}, name: "err_runcmd", </s> remove name: "err_runcmd", </s> add </s> remove want: nil, </s> add want: netip.Addr{}, name: "bad_code", </s> remove want: nil, </s> add want: netip.Addr{}, name: "bad_output", </s> remove name: "bad_output", </s> add
name: "err_runcmd", shell: theOnlyCmd(cmd, 0, "", errors.Error("can't run command")), want: nil, }, { shell: theOnlyCmd(cmd, 1, "", nil), want: nil, }} for _, tc := range testCases {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
want: nil, }, { name: "bad_code", shell: theOnlyCmd(cmd, 1, "", nil), want: nil, }} for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { substShell(t, tc.shell.RunCmd)
</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",
want: netip.Addr{}, name: "bad_code",
want: nil, }, { name: "bad_code", shell: theOnlyCmd(cmd, 1, "", nil), want: netip.Addr{}, name: "bad_code", }} for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { substShell(t, tc.shell.RunCmd)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
} } func TestBroadcastFromIPNet(t *testing.T) { known6 := net.IP{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, } testCases := []struct { name string subnet *net.IPNet want net.IP
</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> remove gatewayIP net.IP subnetMask net.IP </s> add </s> remove dhcpv4.WithGatewayIP(DefaultGatewayIP), </s> add dhcpv4.WithGatewayIP(DefaultGatewayIP.AsSlice()), </s> remove name string </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")
} } func TestBroadcastFromIPNet(t *testing.T) { 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") 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") 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") 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") 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") 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") testCases := []struct { name string subnet *net.IPNet want net.IP
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
13, 14, 15, 16, } testCases := []struct { name string subnet *net.IPNet want net.IP }{{ name: "full", subnet: &net.IPNet{ IP: net.IP{192, 168, 0, 1}, Mask: net.IPMask{255, 255, 15, 0},
</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 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 subnet: &net.IPNet{ IP: net.IP{192, 168, 1, 2}, }, want: net.IP{192, 168, 1, 255}, </s> add </s> remove want net.IP </s> add want netip.Addr name string
pref netip.Prefix want netip.Addr name string
13, 14, 15, 16, } testCases := []struct { pref netip.Prefix want netip.Addr name string pref netip.Prefix want netip.Addr name string pref netip.Prefix want netip.Addr name string }{{ name: "full", subnet: &net.IPNet{ IP: net.IP{192, 168, 0, 1}, Mask: net.IPMask{255, 255, 15, 0},
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
pref netip.Prefix want netip.Addr name string }{{ name: "full", }, { pref: netip.PrefixFrom(known4, 20), want: netip.MustParseAddr("192.168.15.255"), name: "full", }, {
</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
pref: netip.PrefixFrom(known4, 0), want: fullBroadcast4,
pref netip.Prefix want netip.Addr name string }{{ pref: netip.PrefixFrom(known4, 0), want: fullBroadcast4, name: "full", }, { pref: netip.PrefixFrom(known4, 20), want: netip.MustParseAddr("192.168.15.255"), name: "full", }, {
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
subnet *net.IPNet want net.IP }{{ name: "full", subnet: &net.IPNet{ IP: net.IP{192, 168, 0, 1}, Mask: net.IPMask{255, 255, 15, 0}, }, want: net.IP{192, 168, 240, 255}, }, { name: "ipv6_no_mask", subnet: &net.IPNet{ IP: known6, },
</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 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> 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"),
subnet *net.IPNet want net.IP }{{ name: "full", }, { name: "ipv6_no_mask", subnet: &net.IPNet{ IP: known6, },
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
Mask: net.IPMask{255, 255, 15, 0}, }, want: net.IP{192, 168, 240, 255}, }, { name: "ipv6_no_mask", subnet: &net.IPNet{ IP: known6, }, want: known6, }, { name: "ipv4_no_mask", subnet: &net.IPNet{ IP: net.IP{192, 168, 1, 2},
</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 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 string subnet *net.IPNet want net.IP </s> add pref netip.Prefix want netip.Addr name string
pref: netip.PrefixFrom(known4, 20), want: netip.MustParseAddr("192.168.15.255"), name: "full", }, { pref: netip.PrefixFrom(known6, netutil.IPv6BitLen),
Mask: net.IPMask{255, 255, 15, 0}, }, want: net.IP{192, 168, 240, 255}, }, { pref: netip.PrefixFrom(known4, 20), want: netip.MustParseAddr("192.168.15.255"), name: "full", }, { pref: netip.PrefixFrom(known6, netutil.IPv6BitLen), pref: netip.PrefixFrom(known4, 20), want: netip.MustParseAddr("192.168.15.255"), name: "full", }, { pref: netip.PrefixFrom(known6, netutil.IPv6BitLen), pref: netip.PrefixFrom(known4, 20), want: netip.MustParseAddr("192.168.15.255"), name: "full", }, { pref: netip.PrefixFrom(known6, netutil.IPv6BitLen), pref: netip.PrefixFrom(known4, 20), want: netip.MustParseAddr("192.168.15.255"), name: "full", }, { pref: netip.PrefixFrom(known6, netutil.IPv6BitLen), want: known6, }, { name: "ipv4_no_mask", subnet: &net.IPNet{ IP: net.IP{192, 168, 1, 2},
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
}, { pref: netip.PrefixFrom(known6, netutil.IPv6BitLen), want: known6, }, { pref: netip.PrefixFrom(known4, netutil.IPv4BitLen), want: known4, name: "ipv4_no_mask", }, {
</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
name: "ipv6_no_mask",
}, { pref: netip.PrefixFrom(known6, netutil.IPv6BitLen), want: known6, name: "ipv6_no_mask", }, { pref: netip.PrefixFrom(known4, netutil.IPv4BitLen), want: known4, name: "ipv4_no_mask", }, {
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
name: "ipv6_no_mask", }, { name: "ipv4_no_mask", }, { pref: netip.PrefixFrom(netip.IPv4Unspecified(), 0), want: fullBroadcast4, name: "unspecified",
</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
pref: netip.PrefixFrom(known4, netutil.IPv4BitLen), want: known4,
name: "ipv6_no_mask", }, { pref: netip.PrefixFrom(known4, netutil.IPv4BitLen), want: known4, name: "ipv4_no_mask", }, { pref: netip.PrefixFrom(netip.IPv4Unspecified(), 0), want: fullBroadcast4, name: "unspecified",
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
}, want: known6, }, { name: "ipv4_no_mask", subnet: &net.IPNet{ IP: net.IP{192, 168, 1, 2}, }, want: net.IP{192, 168, 1, 255}, }, { name: "unspecified", subnet: &net.IPNet{ IP: net.IP{0, 0, 0, 0}, Mask: net.IPMask{0, 0, 0, 0},
</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
}, want: known6, }, { name: "ipv4_no_mask", }, { name: "unspecified", subnet: &net.IPNet{ IP: net.IP{0, 0, 0, 0}, Mask: net.IPMask{0, 0, 0, 0},
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
want: known4, name: "ipv4_no_mask", }, { name: "unspecified", }, { pref: netip.Prefix{}, want: netip.Addr{}, name: "invalid",
</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
pref: netip.PrefixFrom(netip.IPv4Unspecified(), 0), want: fullBroadcast4,
want: known4, name: "ipv4_no_mask", }, { pref: netip.PrefixFrom(netip.IPv4Unspecified(), 0), want: fullBroadcast4, name: "unspecified", }, { pref: netip.Prefix{}, want: netip.Addr{}, name: "invalid",
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
}, want: net.IP{192, 168, 1, 255}, }, { name: "unspecified", subnet: &net.IPNet{ IP: net.IP{0, 0, 0, 0}, Mask: net.IPMask{0, 0, 0, 0}, }, want: net.IPv4bcast, }} for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { bc := BroadcastFromIPNet(tc.subnet)
</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
}, { pref: netip.Prefix{}, want: netip.Addr{}, name: "invalid",
}, want: net.IP{192, 168, 1, 255}, }, { name: "unspecified", }, { pref: netip.Prefix{}, want: netip.Addr{}, name: "invalid", }, { pref: netip.Prefix{}, want: netip.Addr{}, name: "invalid", }, { pref: netip.Prefix{}, want: netip.Addr{}, name: "invalid", }, { pref: netip.Prefix{}, want: netip.Addr{}, name: "invalid", }, { pref: netip.Prefix{}, want: netip.Addr{}, name: "invalid", }} for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { bc := BroadcastFromIPNet(tc.subnet)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
}} for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { bc := BroadcastFromIPNet(tc.subnet) assert.True(t, bc.Equal(tc.want), bc) }) } } func TestCheckPort(t *testing.T) {
</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_code", </s> remove gatewayIP: net.IP{192, 168, 10, 1}, subnetMask: net.IP{255, 255, 255, 224}, </s> add </s> remove // Just to avoid nil pointer dereference. subnet: &net.IPNet{}, </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"),
assert.Equal(t, tc.want, BroadcastFromPref(tc.pref))
}} for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { assert.Equal(t, tc.want, BroadcastFromPref(tc.pref)) assert.Equal(t, tc.want, BroadcastFromPref(tc.pref)) }) } } func TestCheckPort(t *testing.T) {
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
} } func TestCheckPort(t *testing.T) { t.Run("tcp_bound", func(t *testing.T) { l, err := net.Listen("tcp", laddr.String()) require.NoError(t, err) testutil.CleanupAndRequireSuccess(t, l.Close)
</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))
laddr := netip.AddrPortFrom(IPv4Localhost(), 0)
} } func TestCheckPort(t *testing.T) { laddr := netip.AddrPortFrom(IPv4Localhost(), 0) t.Run("tcp_bound", func(t *testing.T) { l, err := net.Listen("tcp", laddr.String()) require.NoError(t, err) testutil.CleanupAndRequireSuccess(t, l.Close)
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
} func TestCheckPort(t *testing.T) { t.Run("tcp_bound", func(t *testing.T) { l, err := net.Listen("tcp", "127.0.0.1:") require.NoError(t, err) testutil.CleanupAndRequireSuccess(t, l.Close) ipp := netutil.IPPortFromAddr(l.Addr()) require.NotNil(t, 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 conn, err := net.ListenPacket("udp", "127.0.0.1:") </s> add conn, err := net.ListenPacket("udp", laddr.String()) </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 bc := BroadcastFromIPNet(tc.subnet) assert.True(t, bc.Equal(tc.want), bc) </s> add assert.Equal(t, tc.want, BroadcastFromPref(tc.pref))
l, err := net.Listen("tcp", laddr.String())
} func TestCheckPort(t *testing.T) { t.Run("tcp_bound", func(t *testing.T) { l, err := net.Listen("tcp", laddr.String()) require.NoError(t, err) testutil.CleanupAndRequireSuccess(t, l.Close) ipp := netutil.IPPortFromAddr(l.Addr()) require.NotNil(t, ipp)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
l, err := net.Listen("tcp", "127.0.0.1:") require.NoError(t, err) testutil.CleanupAndRequireSuccess(t, l.Close) ipp := netutil.IPPortFromAddr(l.Addr()) require.NotNil(t, ipp) require.NotNil(t, ipp.IP) require.NotZero(t, ipp.Port) err = CheckPort("tcp", ipp.IP, ipp.Port) target := &net.OpError{} require.ErrorAs(t, err, &target)
</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 err = CheckPort("udp", ipp.IP, ipp.Port) </s> add err = CheckPort("udp", ipp) </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())
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())
l, err := net.Listen("tcp", "127.0.0.1:") require.NoError(t, err) testutil.CleanupAndRequireSuccess(t, l.Close) 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()) 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()) 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()) 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()) err = CheckPort("tcp", ipp.IP, ipp.Port) target := &net.OpError{} require.ErrorAs(t, err, &target)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
require.NotNil(t, ipp) require.NotNil(t, ipp.IP) require.NotZero(t, ipp.Port) err = CheckPort("tcp", ipp.IP, ipp.Port) target := &net.OpError{} require.ErrorAs(t, err, &target) assert.Equal(t, "listen", target.Op) })
</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))
err = CheckPort("tcp", ipp)
require.NotNil(t, ipp) require.NotNil(t, ipp.IP) require.NotZero(t, ipp.Port) err = CheckPort("tcp", ipp) target := &net.OpError{} require.ErrorAs(t, err, &target) assert.Equal(t, "listen", target.Op) })
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
assert.Equal(t, "listen", target.Op) }) t.Run("udp_bound", func(t *testing.T) { conn, err := net.ListenPacket("udp", "127.0.0.1:") require.NoError(t, err) testutil.CleanupAndRequireSuccess(t, conn.Close) ipp := netutil.IPPortFromAddr(conn.LocalAddr()) require.NotNil(t, 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 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> remove err := CheckPort("bad_network", nil, 0) </s> add err := CheckPort("bad_network", netip.AddrPortFrom(netip.Addr{}, 0))
conn, err := net.ListenPacket("udp", laddr.String())
assert.Equal(t, "listen", target.Op) }) t.Run("udp_bound", func(t *testing.T) { conn, err := net.ListenPacket("udp", laddr.String()) require.NoError(t, err) testutil.CleanupAndRequireSuccess(t, conn.Close) ipp := netutil.IPPortFromAddr(conn.LocalAddr()) require.NotNil(t, ipp)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
conn, err := net.ListenPacket("udp", "127.0.0.1:") require.NoError(t, err) testutil.CleanupAndRequireSuccess(t, conn.Close) ipp := netutil.IPPortFromAddr(conn.LocalAddr()) require.NotNil(t, ipp) require.NotNil(t, ipp.IP) require.NotZero(t, ipp.Port) err = CheckPort("udp", ipp.IP, ipp.Port) target := &net.OpError{} require.ErrorAs(t, err, &target)
</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 err = CheckPort("tcp", ipp.IP, ipp.Port) </s> add err = CheckPort("tcp", ipp) </s> remove conn, err := net.ListenPacket("udp", "127.0.0.1:") </s> add conn, err := net.ListenPacket("udp", laddr.String()) </s> remove l, err := net.Listen("tcp", "127.0.0.1:") </s> add l, err := net.Listen("tcp", laddr.String())
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())
conn, err := net.ListenPacket("udp", "127.0.0.1:") require.NoError(t, err) testutil.CleanupAndRequireSuccess(t, conn.Close) 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()) 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()) 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()) 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()) err = CheckPort("udp", ipp.IP, ipp.Port) target := &net.OpError{} require.ErrorAs(t, err, &target)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
require.NotNil(t, ipp) require.NotNil(t, ipp.IP) require.NotZero(t, ipp.Port) err = CheckPort("udp", ipp.IP, ipp.Port) target := &net.OpError{} require.ErrorAs(t, err, &target) assert.Equal(t, "listen", target.Op) })
</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))
err = CheckPort("udp", ipp)
require.NotNil(t, ipp) require.NotNil(t, ipp.IP) require.NotZero(t, ipp.Port) err = CheckPort("udp", ipp) target := &net.OpError{} require.ErrorAs(t, err, &target) assert.Equal(t, "listen", target.Op) })
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
assert.Equal(t, "listen", target.Op) }) t.Run("bad_network", func(t *testing.T) { err := CheckPort("bad_network", nil, 0) assert.NoError(t, err) }) t.Run("can_bind", func(t *testing.T) { err := CheckPort("udp", net.IP{0, 0, 0, 0}, 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 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 assert.True(t, s.conf.GatewayIP.Equal(resp.Router()[0])) assert.True(t, s.conf.GatewayIP.Equal(resp.ServerIdentifier())) assert.Equal(t, s.conf.subnet.Mask, resp.SubnetMask()) </s> add assert.True(t, resp.Router()[0].Equal(s.conf.GatewayIP.AsSlice())) assert.True(t, resp.ServerIdentifier().Equal(s.conf.GatewayIP.AsSlice())) ones, _ := resp.SubnetMask().Size() assert.Equal(t, s.conf.subnet.Bits(), ones)
err := CheckPort("bad_network", netip.AddrPortFrom(netip.Addr{}, 0))
assert.Equal(t, "listen", target.Op) }) t.Run("bad_network", func(t *testing.T) { err := CheckPort("bad_network", netip.AddrPortFrom(netip.Addr{}, 0)) assert.NoError(t, err) }) t.Run("can_bind", func(t *testing.T) { err := CheckPort("udp", net.IP{0, 0, 0, 0}, 0)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
assert.NoError(t, err) }) t.Run("can_bind", func(t *testing.T) { err := CheckPort("udp", net.IP{0, 0, 0, 0}, 0) assert.NoError(t, err) }) } func TestCollectAllIfacesAddrs(t *testing.T) {
</s> remove err := CheckPort("bad_network", nil, 0) </s> add err := CheckPort("bad_network", netip.AddrPortFrom(netip.Addr{}, 0)) </s> remove IP: anotherIP, </s> add IP: anotherIP.AsSlice(), </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 conn, err := net.ListenPacket("udp", "127.0.0.1:") </s> add conn, err := net.ListenPacket("udp", laddr.String())
err := CheckPort("udp", netip.AddrPortFrom(netip.IPv4Unspecified(), 0))
assert.NoError(t, err) }) t.Run("can_bind", func(t *testing.T) { err := CheckPort("udp", netip.AddrPortFrom(netip.IPv4Unspecified(), 0)) assert.NoError(t, err) }) } func TestCollectAllIfacesAddrs(t *testing.T) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
`"name":"iface0",` + `"mtu":1500` + `}` + "\n" 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} mask4, mask6 := net.CIDRMask(24, netutil.IPv4BitLen), net.CIDRMask(8, netutil.IPv6BitLen) iface := &NetInterface{ Addresses: []net.IP{ip4, ip6}, Subnets: []*net.IPNet{{ IP: ip4.Mask(mask4),
</s> remove Addresses: []net.IP{ip4, ip6}, Subnets: []*net.IPNet{{ IP: ip4.Mask(mask4), Mask: mask4, }, { IP: ip6.Mask(mask6), Mask: mask6, }}, </s> add Addresses: []netip.Addr{ip4, ip6}, Subnets: []netip.Prefix{net4, net6}, </s> remove subnet: &net.IPNet{ IP: net.IP{192, 168, 1, 2}, }, want: net.IP{192, 168, 1, 255}, </s> add </s> remove BindHost: net.IP{0, 0, 0, 0}, </s> add BindHost: netip.IPv4Unspecified(), </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
ip4, ok := netip.AddrFromSlice([]byte{1, 2, 3, 4}) require.True(t, ok) ip6, ok := netip.AddrFromSlice([]byte{0xAA, 0xAA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}) require.True(t, ok) net4 := netip.PrefixFrom(ip4, 24) net6 := netip.PrefixFrom(ip6, 8)
`"name":"iface0",` + `"mtu":1500` + `}` + "\n" ip4, ok := netip.AddrFromSlice([]byte{1, 2, 3, 4}) require.True(t, ok) ip6, ok := netip.AddrFromSlice([]byte{0xAA, 0xAA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}) require.True(t, ok) net4 := netip.PrefixFrom(ip4, 24) net6 := netip.PrefixFrom(ip6, 8) ip4, ok := netip.AddrFromSlice([]byte{1, 2, 3, 4}) require.True(t, ok) ip6, ok := netip.AddrFromSlice([]byte{0xAA, 0xAA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}) require.True(t, ok) net4 := netip.PrefixFrom(ip4, 24) net6 := netip.PrefixFrom(ip6, 8) iface := &NetInterface{ Addresses: []net.IP{ip4, ip6}, Subnets: []*net.IPNet{{ IP: ip4.Mask(mask4),
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
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} mask4, mask6 := net.CIDRMask(24, netutil.IPv4BitLen), net.CIDRMask(8, netutil.IPv6BitLen) iface := &NetInterface{ Addresses: []net.IP{ip4, ip6}, Subnets: []*net.IPNet{{ IP: ip4.Mask(mask4), Mask: mask4, }, { IP: ip6.Mask(mask6), Mask: mask6, }}, Name: "iface0", HardwareAddr: net.HardwareAddr{0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}, Flags: net.FlagUp | net.FlagMulticast, MTU: 1500, }
</s> remove 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} mask4, mask6 := net.CIDRMask(24, netutil.IPv4BitLen), net.CIDRMask(8, netutil.IPv6BitLen) </s> add ip4, ok := netip.AddrFromSlice([]byte{1, 2, 3, 4}) require.True(t, ok) ip6, ok := netip.AddrFromSlice([]byte{0xAA, 0xAA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}) require.True(t, ok) net4 := netip.PrefixFrom(ip4, 24) net6 := netip.PrefixFrom(ip6, 8) </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(),
Addresses: []netip.Addr{ip4, ip6}, Subnets: []netip.Prefix{net4, net6},
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} mask4, mask6 := net.CIDRMask(24, netutil.IPv4BitLen), net.CIDRMask(8, netutil.IPv6BitLen) iface := &NetInterface{ Addresses: []netip.Addr{ip4, ip6}, Subnets: []netip.Prefix{net4, net6}, Addresses: []netip.Addr{ip4, ip6}, Subnets: []netip.Prefix{net4, net6}, Addresses: []netip.Addr{ip4, ip6}, Subnets: []netip.Prefix{net4, net6}, Addresses: []netip.Addr{ip4, ip6}, Subnets: []netip.Prefix{net4, net6}, Addresses: []netip.Addr{ip4, ip6}, Subnets: []netip.Prefix{net4, net6}, Addresses: []netip.Addr{ip4, ip6}, Subnets: []netip.Prefix{net4, net6}, Addresses: []netip.Addr{ip4, ip6}, Subnets: []netip.Prefix{net4, net6}, Addresses: []netip.Addr{ip4, ip6}, Subnets: []netip.Prefix{net4, net6}, Name: "iface0", HardwareAddr: net.HardwareAddr{0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}, Flags: net.FlagUp | net.FlagMulticast, MTU: 1500, }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/aghnet/net_test.go
import ( "fmt" "net" "time" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/AdGuardHome/internal/aghnet" "github.com/AdguardTeam/golibs/errors" )
</s> remove "net" </s> add </s> remove "net" </s> add "net/netip" </s> remove "net" </s> add
"net/netip"
import ( "fmt" "net" "net/netip" "time" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/AdGuardHome/internal/aghnet" "github.com/AdguardTeam/golibs/errors" )
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/dhcpd/config.go
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/AdGuardHome/internal/aghnet" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/netutil" ) // ServerConfig is the configuration for the DHCP server. The order of YAML // fields is important, since the YAML configuration file follows it. type ServerConfig struct {
</s> remove // migration. </s> add // migration. Also keep the blocked services in mind. </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"`
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/AdGuardHome/internal/aghnet" "github.com/AdguardTeam/golibs/errors" ) // ServerConfig is the configuration for the DHCP server. The order of YAML // fields is important, since the YAML configuration file follows it. type ServerConfig struct {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/dhcpd/config.go
type V4ServerConf struct { Enabled bool `yaml:"-" json:"-"` InterfaceName string `yaml:"-" json:"-"` GatewayIP net.IP `yaml:"gateway_ip" json:"gateway_ip"` SubnetMask net.IP `yaml:"subnet_mask" json:"subnet_mask"` // broadcastIP is the broadcasting address pre-calculated from the // configured gateway IP and subnet mask. broadcastIP net.IP // The first & the last IP address for dynamic leases
</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 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"`
GatewayIP netip.Addr `yaml:"gateway_ip" json:"gateway_ip"` SubnetMask netip.Addr `yaml:"subnet_mask" json:"subnet_mask"`
type V4ServerConf struct { Enabled bool `yaml:"-" json:"-"` InterfaceName string `yaml:"-" json:"-"` GatewayIP netip.Addr `yaml:"gateway_ip" json:"gateway_ip"` SubnetMask netip.Addr `yaml:"subnet_mask" json:"subnet_mask"` GatewayIP netip.Addr `yaml:"gateway_ip" json:"gateway_ip"` SubnetMask netip.Addr `yaml:"subnet_mask" json:"subnet_mask"` // broadcastIP is the broadcasting address pre-calculated from the // configured gateway IP and subnet mask. broadcastIP net.IP // The first & the last IP address for dynamic leases
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/dhcpd/config.go
GatewayIP net.IP `yaml:"gateway_ip" json:"gateway_ip"` SubnetMask net.IP `yaml:"subnet_mask" json:"subnet_mask"` // broadcastIP is the broadcasting address pre-calculated from the // configured gateway IP and subnet mask. broadcastIP net.IP // The first & the last IP address for dynamic leases // Bytes [0..2] of the last allowed IP address must match the first IP RangeStart net.IP `yaml:"range_start" json:"range_start"` RangeEnd net.IP `yaml:"range_end" json:"range_end"`
</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 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 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 subnet *net.IPNet </s> add subnet netip.Prefix </s> remove return nil </s> add return netip.Addr{}
broadcastIP netip.Addr
GatewayIP net.IP `yaml:"gateway_ip" json:"gateway_ip"` SubnetMask net.IP `yaml:"subnet_mask" json:"subnet_mask"` // broadcastIP is the broadcasting address pre-calculated from the // configured gateway IP and subnet mask. broadcastIP netip.Addr // The first & the last IP address for dynamic leases // Bytes [0..2] of the last allowed IP address must match the first IP RangeStart net.IP `yaml:"range_start" json:"range_start"` RangeEnd net.IP `yaml:"range_end" json:"range_end"`
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/dhcpd/config.go
broadcastIP net.IP // The first & the last IP address for dynamic leases // Bytes [0..2] of the last allowed IP address must match the first IP RangeStart net.IP `yaml:"range_start" json:"range_start"` RangeEnd net.IP `yaml:"range_end" json:"range_end"` LeaseDuration uint32 `yaml:"lease_duration" json:"lease_duration"` // in seconds // IP conflict detector: time (ms) to wait for ICMP reply // 0: disable
</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
RangeStart netip.Addr `yaml:"range_start" json:"range_start"` RangeEnd netip.Addr `yaml:"range_end" json:"range_end"`
broadcastIP net.IP // The first & the last IP address for dynamic leases // Bytes [0..2] of the last allowed IP address must match the first IP RangeStart netip.Addr `yaml:"range_start" json:"range_start"` RangeEnd netip.Addr `yaml:"range_end" json:"range_end"` RangeStart netip.Addr `yaml:"range_start" json:"range_start"` RangeEnd netip.Addr `yaml:"range_end" json:"range_end"` LeaseDuration uint32 `yaml:"lease_duration" json:"lease_duration"` // in seconds // IP conflict detector: time (ms) to wait for ICMP reply // 0: disable
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/dhcpd/config.go
ipRange *ipRange leaseTime time.Duration // the time during which a dynamic lease is considered valid dnsIPAddrs []net.IP // IPv4 addresses to return to DHCP clients as DNS server addresses // subnet contains the DHCP server's subnet. The IP is the IP of the // gateway. subnet *net.IPNet
</s> remove subnet *net.IPNet </s> add subnet netip.Prefix </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 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 var subnet *net.IPNet </s> add var subnet netip.Prefix
dnsIPAddrs []netip.Addr // IPv4 addresses to return to DHCP clients as DNS server addresses
ipRange *ipRange leaseTime time.Duration // the time during which a dynamic lease is considered valid dnsIPAddrs []netip.Addr // IPv4 addresses to return to DHCP clients as DNS server addresses // subnet contains the DHCP server's subnet. The IP is the IP of the // gateway. subnet *net.IPNet
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/dhcpd/config.go
dnsIPAddrs []net.IP // IPv4 addresses to return to DHCP clients as DNS server addresses // subnet contains the DHCP server's subnet. The IP is the IP of the // gateway. subnet *net.IPNet // notify is a way to signal to other components that leases have been // changed. notify must be called outside of locked sections, since the // clients might want to get the new data. //
</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 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 QueryLogInterval timeutil.Duration `yaml:"querylog_interval"` QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats </s> add QueryLogInterval timeutil.Duration `yaml:"querylog_interval"` // QueryLogMemSize is the number of entries kept in memory before they are // flushed to disk. QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // AnonymizeClientIP defines if clients' IP addresses should be anonymized // in query log and statistics. AnonymizeClientIP bool `yaml:"anonymize_client_ip"`
subnet netip.Prefix
dnsIPAddrs []net.IP // IPv4 addresses to return to DHCP clients as DNS server addresses // subnet contains the DHCP server's subnet. The IP is the IP of the // gateway. subnet netip.Prefix // notify is a way to signal to other components that leases have been // changed. notify must be called outside of locked sections, since the // clients might want to get the new data. //
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/dhcpd/config.go
// errNilConfig is an error returned by validation method if the config is nil. const errNilConfig errors.Error = "nil config" // 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) } return ip4, nil }
</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
// 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)
// errNilConfig is an error returned by validation method if the config is nil. const errNilConfig errors.Error = "nil config" // 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) // 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) // 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) // 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) // 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) // 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) // 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) // 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) // 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) // 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) } return ip4, nil }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/dhcpd/config.go
if c == nil { return errNilConfig } var gatewayIP net.IP gatewayIP, err = ensureV4(c.GatewayIP) if err != nil { // Don't wrap an errors since it's inforative 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 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 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
gatewayIP, err := ensureV4(c.GatewayIP, "address")
if c == nil { return errNilConfig } gatewayIP, err := ensureV4(c.GatewayIP, "address") gatewayIP, err := ensureV4(c.GatewayIP, "address") if err != nil { // Don't wrap an errors since it's inforative enough as is and there is // an annotation deferred already. return err }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/dhcpd/config.go
var gatewayIP net.IP gatewayIP, err = ensureV4(c.GatewayIP) if err != nil { // Don't wrap an errors since it's inforative enough as is and there is // an annotation deferred already. return err } if c.SubnetMask == nil {
</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 c.broadcastIP = aghnet.BroadcastFromIPNet(c.subnet) </s> add </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
// Don't wrap an errors since it's informative enough as is and there is
var gatewayIP net.IP gatewayIP, err = ensureV4(c.GatewayIP) if err != nil { // Don't wrap an errors since it's informative enough as is and there is // an annotation deferred already. return err } if c.SubnetMask == nil {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/dhcpd/config.go
// an annotation deferred already. return err } if c.SubnetMask == nil { return fmt.Errorf("invalid subnet mask: %v", c.SubnetMask) } subnetMask := net.IPMask(netutil.CloneIP(c.SubnetMask.To4())) c.subnet = &net.IPNet{ IP: gatewayIP,
</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()) {
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
// an annotation deferred already. return err } 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 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 } subnetMask := net.IPMask(netutil.CloneIP(c.SubnetMask.To4())) c.subnet = &net.IPNet{ IP: gatewayIP,
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/dhcpd/config.go
return err } rangeStart, err := ensureV4(c.RangeStart, "address") if err != nil { // 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 </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())
maskLen, _ := net.IPMask(subnetMask.AsSlice()).Size() c.subnet = netip.PrefixFrom(gatewayIP, maskLen) c.broadcastIP = aghnet.BroadcastFromPref(c.subnet)
return err } maskLen, _ := net.IPMask(subnetMask.AsSlice()).Size() c.subnet = netip.PrefixFrom(gatewayIP, maskLen) c.broadcastIP = aghnet.BroadcastFromPref(c.subnet) rangeStart, err := ensureV4(c.RangeStart, "address") if err != nil { // Don't wrap an errors since it's informative enough as is and there is
[ "keep", "add", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/dhcpd/config.go
if c.SubnetMask == nil { return fmt.Errorf("invalid subnet mask: %v", c.SubnetMask) } subnetMask := net.IPMask(netutil.CloneIP(c.SubnetMask.To4())) c.subnet = &net.IPNet{ IP: gatewayIP, Mask: subnetMask, } c.broadcastIP = aghnet.BroadcastFromIPNet(c.subnet) c.ipRange, err = newIPRange(c.RangeStart, c.RangeEnd) if err != nil {
</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 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 // 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
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
if c.SubnetMask == nil { return fmt.Errorf("invalid subnet mask: %v", c.SubnetMask) } 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 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 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 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 } c.broadcastIP = aghnet.BroadcastFromIPNet(c.subnet) c.ipRange, err = newIPRange(c.RangeStart, c.RangeEnd) if err != nil {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/dhcpd/config.go
c.subnet = &net.IPNet{ IP: gatewayIP, Mask: subnetMask, } c.broadcastIP = aghnet.BroadcastFromIPNet(c.subnet) c.ipRange, err = newIPRange(c.RangeStart, c.RangeEnd) if err != nil { // Don't wrap an errors since it's inforative enough as is and there is // an annotation deferred already.
</s> remove c.ipRange, err = newIPRange(c.RangeStart, c.RangeEnd) </s> add c.ipRange, err = newIPRange(rangeStart.AsSlice(), rangeEnd.AsSlice()) </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 </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
c.subnet = &net.IPNet{ IP: gatewayIP, Mask: subnetMask, } c.ipRange, err = newIPRange(c.RangeStart, c.RangeEnd) if err != nil { // Don't wrap an errors since it's inforative enough as is and there is // an annotation deferred already.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/dhcpd/config.go
Mask: subnetMask, } c.broadcastIP = aghnet.BroadcastFromIPNet(c.subnet) c.ipRange, err = newIPRange(c.RangeStart, c.RangeEnd) if err != nil { // Don't wrap an errors since it's inforative 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 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")
c.ipRange, err = newIPRange(rangeStart.AsSlice(), rangeEnd.AsSlice())
Mask: subnetMask, } c.broadcastIP = aghnet.BroadcastFromIPNet(c.subnet) c.ipRange, err = newIPRange(rangeStart.AsSlice(), rangeEnd.AsSlice()) if err != nil { // Don't wrap an errors since it's inforative enough as is and there is // an annotation deferred already. return err }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/dhcpd/config.go
c.broadcastIP = aghnet.BroadcastFromIPNet(c.subnet) c.ipRange, err = newIPRange(c.RangeStart, c.RangeEnd) if err != nil { // Don't wrap an errors since it's inforative enough as is and there is // an annotation deferred already. return err } if c.ipRange.contains(gatewayIP) {
</s> remove c.ipRange, err = newIPRange(c.RangeStart, c.RangeEnd) </s> add c.ipRange, err = newIPRange(rangeStart.AsSlice(), rangeEnd.AsSlice()) </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")
// Don't wrap an errors since it's informative enough as is and there is
c.broadcastIP = aghnet.BroadcastFromIPNet(c.subnet) c.ipRange, err = newIPRange(c.RangeStart, c.RangeEnd) if err != nil { // Don't wrap an errors since it's informative enough as is and there is // an annotation deferred already. return err } if c.ipRange.contains(gatewayIP) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/dhcpd/config.go
// an annotation deferred already. return err } if c.ipRange.contains(gatewayIP) { return fmt.Errorf("gateway ip %v in the ip range: %v-%v", gatewayIP, c.RangeStart, c.RangeEnd, )
</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
if c.ipRange.contains(gatewayIP.AsSlice()) {
// an annotation deferred already. return err } if c.ipRange.contains(gatewayIP.AsSlice()) { return fmt.Errorf("gateway ip %v in the ip range: %v-%v", gatewayIP, c.RangeStart, c.RangeEnd, )
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/dhcpd/config.go
c.RangeEnd, ) } if !c.subnet.Contains(c.RangeStart) { return fmt.Errorf("range start %v is outside network %v", c.RangeStart, c.subnet, ) }
</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
if !c.subnet.Contains(rangeStart) {
c.RangeEnd, ) } if !c.subnet.Contains(rangeStart) { return fmt.Errorf("range start %v is outside network %v", c.RangeStart, c.subnet, ) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/dhcpd/config.go
c.subnet, ) } if !c.subnet.Contains(c.RangeEnd) { return fmt.Errorf("range end %v is outside network %v", c.RangeEnd, c.subnet, ) }
</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"),
if !c.subnet.Contains(rangeEnd) {
c.subnet, ) } if !c.subnet.Contains(rangeEnd) { return fmt.Errorf("range end %v is outside network %v", c.RangeEnd, c.subnet, ) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/dhcpd/config.go
} return &dhcpConn{ udpConn: bcast, bcastIP: s.conf.broadcastIP, rawConn: ucast, srcMAC: iface.HardwareAddr, srcIP: s.conf.dnsIPAddrs[0], }, nil }
</s> remove srcIP: s.conf.dnsIPAddrs[0], </s> add srcIP: s.conf.dnsIPAddrs[0].AsSlice(), </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()
bcastIP: s.conf.broadcastIP.AsSlice(),
} return &dhcpConn{ udpConn: bcast, bcastIP: s.conf.broadcastIP.AsSlice(), rawConn: ucast, srcMAC: iface.HardwareAddr, srcIP: s.conf.dnsIPAddrs[0], }, nil }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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
https://github.com/AdguardTeam/AdGuardHome/commit/4582b1c9198dcbc1927b74080839e81ba347265a
internal/dhcpd/conn_unix.go