mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
chore: optimize dhcpd and dns and more
This commit is contained in:
1 parent
7e7c7553cc
commit
f2eb638b91
9 files changed
+56
-54
No files matched your search
+3
-6
@@ -32,18 +32,15 @@ type Port uint16
|
||||
|
||||
// ParseAddr parses the address in string s.
|
||||
func ParseAddr(s string) (Atyp, Addr, Port, error) {
|
||||
var atyp Atyp
|
||||
var addr Addr
|
||||
|
||||
host, port, err := net.SplitHostPort(s)
|
||||
if err != nil {
|
||||
return 0, nil, 0, err
|
||||
}
|
||||
|
||||
var addr Addr
|
||||
var atyp Atyp = AtypIP4
|
||||
if ip, err := netip.ParseAddr(host); err == nil {
|
||||
if ip.Is4() {
|
||||
atyp = AtypIP4
|
||||
} else {
|
||||
if ip.Is6() {
|
||||
atyp = AtypIP6
|
||||
}
|
||||
addr = ip.AsSlice()
|
||||
|
||||
+3
-6
@@ -28,18 +28,15 @@ type Port uint16
|
||||
|
||||
// ParseAddr parses the address in string s.
|
||||
func ParseAddr(s string) (Atyp, Addr, Port, error) {
|
||||
var atyp Atyp
|
||||
var addr Addr
|
||||
|
||||
host, port, err := net.SplitHostPort(s)
|
||||
if err != nil {
|
||||
return 0, nil, 0, err
|
||||
}
|
||||
|
||||
var addr Addr
|
||||
var atyp Atyp = AtypIP4
|
||||
if ip, err := netip.ParseAddr(host); err == nil {
|
||||
if ip.Is4() {
|
||||
atyp = AtypIP4
|
||||
} else {
|
||||
if ip.Is6() {
|
||||
atyp = AtypIP6
|
||||
}
|
||||
addr = ip.AsSlice()
|
||||
|
||||
Reference in new issue
Block a user