18 lines
379 B
Go
18 lines
379 B
Go
package service
|
|
|
|
import (
|
|
"net"
|
|
"testing"
|
|
)
|
|
|
|
func TestPrivateIP(t *testing.T) {
|
|
for _, value := range []string{"127.0.0.1", "10.0.0.1", "172.16.0.1", "192.168.1.1", "169.254.1.1", "::1"} {
|
|
if !privateIP(net.ParseIP(value)) {
|
|
t.Fatalf("expected %s to be private", value)
|
|
}
|
|
}
|
|
if privateIP(net.ParseIP("8.8.8.8")) {
|
|
t.Fatal("public IP was classified as private")
|
|
}
|
|
}
|