mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-27 10:47:06 +02:00
refactor(proxmox): rename checkIPPrivate to privateIPOrNil
This commit is contained in:
@@ -122,10 +122,10 @@ func parseCIDR(s string) net.IP {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return checkIPPrivate(ip)
|
return privateIPOrNil(ip)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkIPPrivate(ip net.IP) net.IP {
|
func privateIPOrNil(ip net.IP) net.IP {
|
||||||
if ip == nil {
|
if ip == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -145,9 +145,9 @@ func getIPFromNet(s string) (res []net.IP) { // name:...,bridge:...,gw=..,ip=...
|
|||||||
cidrIndex += 3
|
cidrIndex += 3
|
||||||
slash := strings.Index(s[cidrIndex:], "/")
|
slash := strings.Index(s[cidrIndex:], "/")
|
||||||
if slash != -1 {
|
if slash != -1 {
|
||||||
i4 = checkIPPrivate(net.ParseIP(s[cidrIndex : cidrIndex+slash]))
|
i4 = privateIPOrNil(net.ParseIP(s[cidrIndex : cidrIndex+slash]))
|
||||||
} else {
|
} else {
|
||||||
i4 = checkIPPrivate(net.ParseIP(s[cidrIndex:]))
|
i4 = privateIPOrNil(net.ParseIP(s[cidrIndex:]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cidr6Index := strings.Index(s, "ip6=")
|
cidr6Index := strings.Index(s, "ip6=")
|
||||||
@@ -155,9 +155,9 @@ func getIPFromNet(s string) (res []net.IP) { // name:...,bridge:...,gw=..,ip=...
|
|||||||
cidr6Index += 4
|
cidr6Index += 4
|
||||||
slash := strings.Index(s[cidr6Index:], "/")
|
slash := strings.Index(s[cidr6Index:], "/")
|
||||||
if slash != -1 {
|
if slash != -1 {
|
||||||
i6 = checkIPPrivate(net.ParseIP(s[cidr6Index : cidr6Index+slash]))
|
i6 = privateIPOrNil(net.ParseIP(s[cidr6Index : cidr6Index+slash]))
|
||||||
} else {
|
} else {
|
||||||
i6 = checkIPPrivate(net.ParseIP(s[cidr6Index:]))
|
i6 = privateIPOrNil(net.ParseIP(s[cidr6Index:]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if i4 != nil {
|
if i4 != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user