网络相关
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

3 years ago
  1. package network
  2. import (
  3. "fmt"
  4. "testing"
  5. )
  6. func Test_IsPrivateIp(t *testing.T) {
  7. str := "10.1.77.54"
  8. is := IsPrivateIp(str)
  9. fmt.Println("is private ip", is)
  10. }
  11. func Test_GetLocalIps(t *testing.T) {
  12. ips := GetLocalIps()
  13. fmt.Println(ips)
  14. }
  15. func Test_GetInternetIps(t *testing.T) {
  16. ips := GetInternetIps()
  17. fmt.Println(ips)
  18. }
  19. func Test_GetNumber(t *testing.T) {
  20. ip := "192.168.122.21"
  21. mask := "255.255.255.0"
  22. n, err := GetNumber(ip, mask)
  23. t.Log(n, err)
  24. ip = "192.168.112.253"
  25. mask = "255.255.120.0"
  26. n, err = GetNumber(ip, mask)
  27. t.Log(n, err)
  28. ip = "172.16.23.23"
  29. mask = "255.255.255.0"
  30. n, err = GetNumber(ip, mask)
  31. t.Log(n, err)
  32. }
  33. func Test_GetIpMaskFromCIDR(t *testing.T) {
  34. ip := "192.168.141.22/24"
  35. ip, mask, err := GetIpMaskFromCIDR(ip)
  36. t.Log(ip, mask, err)
  37. }
  38. func Test_ChangeMask(t *testing.T) {
  39. mask := "255.255.255.0"
  40. a := ChangeMask(mask)
  41. t.Log(a)
  42. }