Pull request: dhcpd: add purge, imp code
Updates #1691. Squashed commit of the following: commit 2ce6cc005d09ac7d63e4e575705d86e92046697f Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Jun 16 16:42:57 2021 +0300 dhcp: imp code commit 8f2bd7048d864e10aaed9e7338c0bbe852699a31 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Jun 16 16:27:06 2021 +0300 dhcpd: add purge, imp code
This commit is contained in:
@@ -10,6 +10,24 @@ import (
|
||||
"golang.org/x/net/idna"
|
||||
)
|
||||
|
||||
// CloneIP returns a clone of an IP address.
|
||||
func CloneIP(ip net.IP) (clone net.IP) {
|
||||
if ip != nil && len(ip) == 0 {
|
||||
return net.IP{}
|
||||
}
|
||||
|
||||
return append(clone, ip...)
|
||||
}
|
||||
|
||||
// CloneMAC returns a clone of a MAC address.
|
||||
func CloneMAC(mac net.HardwareAddr) (clone net.HardwareAddr) {
|
||||
if mac != nil && len(mac) == 0 {
|
||||
return net.HardwareAddr{}
|
||||
}
|
||||
|
||||
return append(clone, mac...)
|
||||
}
|
||||
|
||||
// IPFromAddr returns an IP address from addr. If addr is neither
|
||||
// a *net.TCPAddr nor a *net.UDPAddr, it returns nil.
|
||||
func IPFromAddr(addr net.Addr) (ip net.IP) {
|
||||
@@ -31,6 +49,12 @@ func IsValidHostOuterRune(r rune) (ok bool) {
|
||||
(r >= '0' && r <= '9')
|
||||
}
|
||||
|
||||
// JoinHostPort is a convinient wrapper for net.JoinHostPort with port of type
|
||||
// int.
|
||||
func JoinHostPort(host string, port int) (hostport string) {
|
||||
return net.JoinHostPort(host, strconv.Itoa(port))
|
||||
}
|
||||
|
||||
// isValidHostRune returns true if r is a valid rune for a hostname label.
|
||||
func isValidHostRune(r rune) (ok bool) {
|
||||
return r == '-' || IsValidHostOuterRune(r)
|
||||
|
||||
Reference in New Issue
Block a user