2021-11-02 12:20:04 +01:00
|
|
|
package netxlite
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
func TestIsBogon(t *testing.T) {
|
|
|
|
if IsBogon("antani") != true {
|
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
|
|
|
if IsBogon("127.0.0.1") != true {
|
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
|
|
|
if IsBogon("1.1.1.1") != false {
|
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
2022-05-13 15:32:47 +02:00
|
|
|
if IsBogon("8.8.4.4") != false {
|
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
|
|
|
if IsBogon("2001:4860:4860::8844") != false {
|
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
2021-11-02 12:20:04 +01:00
|
|
|
if IsBogon("10.0.1.1") != true {
|
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
2022-05-13 15:32:47 +02:00
|
|
|
if IsBogon("::1") != true {
|
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestIsLoopback(t *testing.T) {
|
|
|
|
if IsLoopback("antani") != true {
|
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
|
|
|
if IsLoopback("127.0.0.1") != true {
|
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
|
|
|
if IsLoopback("1.1.1.1") != false {
|
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
|
|
|
if IsLoopback("8.8.4.4") != false {
|
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
|
|
|
if IsLoopback("2001:4860:4860::8844") != false {
|
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
|
|
|
if IsLoopback("10.0.1.1") != false {
|
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
|
|
|
if IsLoopback("::1") != true {
|
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
2021-11-02 12:20:04 +01:00
|
|
|
}
|