chore: import improved bogons handling code (#723)
This diff imports improved bogons handling code from websteps
winter 2022 edition's repository.
See https://github.com/ooni/probe/issues/2095
See a65f3e8579/internal/netxlite/bogon.go
This commit is contained in:
parent
1776ea1288
commit
0efd4ff130
5 changed files with 148 additions and 24 deletions
|
|
@ -12,7 +12,40 @@ func TestIsBogon(t *testing.T) {
|
|||
if IsBogon("1.1.1.1") != false {
|
||||
t.Fatal("unexpected result")
|
||||
}
|
||||
if IsBogon("8.8.4.4") != false {
|
||||
t.Fatal("unexpected result")
|
||||
}
|
||||
if IsBogon("2001:4860:4860::8844") != false {
|
||||
t.Fatal("unexpected result")
|
||||
}
|
||||
if IsBogon("10.0.1.1") != true {
|
||||
t.Fatal("unexpected result")
|
||||
}
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue