网络相关
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
886 B

package network
import (
"fmt"
"testing"
)
func Test_IsPrivateIp(t *testing.T) {
str := "10.1.77.54"
is := IsPrivateIp(str)
fmt.Println("is private ip", is)
}
func Test_GetLocalIps(t *testing.T) {
ips := GetLocalIps()
fmt.Println(ips)
}
func Test_GetInternetIps(t *testing.T) {
ips := GetInternetIps()
fmt.Println(ips)
}
func Test_GetNumber(t *testing.T) {
ip := "192.168.122.21"
mask := "255.255.255.0"
n, err := GetNumber(ip, mask)
t.Log(n, err)
ip = "192.168.112.253"
mask = "255.255.120.0"
n, err = GetNumber(ip, mask)
t.Log(n, err)
ip = "172.16.23.23"
mask = "255.255.255.0"
n, err = GetNumber(ip, mask)
t.Log(n, err)
}
func Test_GetIpMaskFromCIDR(t *testing.T) {
ip := "192.168.141.22/24"
ip, mask, err := GetIpMaskFromCIDR(ip)
t.Log(ip, mask, err)
}
func Test_ChangeMask(t *testing.T) {
mask := "255.255.255.0"
a := ChangeMask(mask)
t.Log(a)
}