mirror of https://github.com/schollz/croc.git
split host port
This commit is contained in:
parent
16fef9e9f7
commit
e145f6c61a
|
@ -278,7 +278,8 @@ var PrivateIPNetworks = []net.IPNet{
|
|||
}
|
||||
|
||||
func IsLocalIP(ipaddress string) bool {
|
||||
ip := net.ParseIP(ipaddress)
|
||||
host, _, _ := net.SplitHostPort(ipaddress)
|
||||
ip := net.ParseIP(host)
|
||||
for _, ipNet := range PrivateIPNetworks {
|
||||
if ipNet.Contains(ip) {
|
||||
return true
|
||||
|
|
|
@ -191,3 +191,7 @@ func TestFindOpenPorts(t *testing.T) {
|
|||
openPorts := FindOpenPorts("localhost", 9009, 4)
|
||||
assert.Equal(t, []int{9009, 9010, 9011, 9012}, openPorts)
|
||||
}
|
||||
|
||||
func TestIsLocalIP(t *testing.T) {
|
||||
assert.True(t, IsLocalIP("192.168.0.14:9009"))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue