1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-23 20:05:59 +00:00

add the stale release

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-08-12 23:41:20 +03:00
parent 535fb6dc0d
commit 2a4ce876b6
793 changed files with 188 additions and 52415 deletions

View File

@@ -1,43 +0,0 @@
package netutil
import (
"testing"
)
func TestIsLoopbackHost(t *testing.T) {
tests := []struct {
host string
valid bool
}{
{"subdomain.127.0.0.1:8080", true},
{"subdomain.127.0.0.1", true},
{"subdomain.localhost:8080", true},
{"subdomain.localhost", true},
{"subdomain.127.0000.0000.1:8080", true},
{"subdomain.127.0000.0000.1", true},
{"subdomain.127.255.255.254:8080", true},
{"subdomain.127.255.255.254", true},
{"subdomain.0000:0:0000::01.1:8080", false},
{"subdomain.0000:0:0000::01", false},
{"subdomain.0000:0:0000::01.1:8080", false},
{"subdomain.0000:0:0000::01", false},
{"subdomain.0000:0000:0000:0000:0000:0000:0000:0001:8080", true},
{"subdomain.0000:0000:0000:0000:0000:0000:0000:0001", false},
{"subdomain.example:8080", false},
{"subdomain.example", false},
{"subdomain.example.com:8080", false},
{"subdomain.example.com", false},
{"subdomain.com", false},
{"subdomain", false},
{".subdomain", false},
{"127.0.0.1.com", false},
}
for i, tt := range tests {
if expected, got := tt.valid, IsLoopbackHost(tt.host); expected != got {
t.Fatalf("[%d] expected %t but got %t for %s", i, expected, got, tt.host)
}
}
}

View File

@@ -1,62 +0,0 @@
package netutil
import (
"net"
"testing"
)
func TestIP(t *testing.T) {
privateRanges := []IPRange{
{
Start: net.ParseIP("10.0.0.0"),
End: net.ParseIP("10.255.255.255"),
},
{
Start: net.ParseIP("100.64.0.0"),
End: net.ParseIP("100.127.255.255"),
},
{
Start: net.ParseIP("172.16.0.0"),
End: net.ParseIP("172.31.255.255"),
},
{
Start: net.ParseIP("192.0.0.0"),
End: net.ParseIP("192.0.0.255"),
},
{
Start: net.ParseIP("192.168.0.0"),
End: net.ParseIP("192.168.255.255"),
},
{
Start: net.ParseIP("198.18.0.0"),
End: net.ParseIP("198.19.255.255"),
},
}
addresses := []string{
"201.37.138.59",
"159.117.3.153",
"166.192.97.84",
"225.181.213.210",
"124.50.84.134",
"87.53.250.102",
"106.79.33.62",
"242.120.17.144",
"131.179.101.254",
"103.11.11.174",
"115.97.0.114",
"219.202.120.251",
"37.72.123.120",
"154.94.78.101",
"126.105.144.250",
}
got, ok := GetIPAddress(addresses, privateRanges)
if !ok {
t.Logf("expected addr to be matched")
}
if expected := "126.105.144.250"; expected != got {
t.Logf("expected addr to be found: %s but got: %s", expected, got)
}
}