Support IPv4 HTTP public gateway entries
This commit is contained in:
1 parent
6f01d31f97
commit
6d5973bea3
11 files changed
+146
-32
No files matched your search
@@ -43,6 +43,35 @@ func TestDomainValidationAndRestart(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestHTTPIPv4PublicEntry(t *testing.T) {
|
||||
for _, host := range []string{"121.4.111.208", "127.0.0.1", "vpn.example.com"} {
|
||||
if !ValidPublicHost("http", host) {
|
||||
t.Fatalf("valid HTTP host rejected: %s", host)
|
||||
}
|
||||
}
|
||||
for _, host := range []string{"999.4.111.208", "121.4.111.208:28080", "0.0.0.0", "224.0.0.1", "::1", "123.456", "121.4.111.208/evil"} {
|
||||
if ValidPublicHost("http", host) {
|
||||
t.Fatalf("invalid HTTP host accepted: %s", host)
|
||||
}
|
||||
}
|
||||
if ValidPublicHost("https", "121.4.111.208") {
|
||||
t.Fatal("HTTPS IPv4 must require a domain")
|
||||
}
|
||||
if got := PublicBaseURL("http", "121.4.111.208", 28080); got != "http://121.4.111.208:28080" {
|
||||
t.Fatalf("unexpected public URL: %s", got)
|
||||
}
|
||||
t.Setenv("VPN_TLS_DOMAIN", "")
|
||||
t.Setenv("VPN_TLS_SCHEME", "")
|
||||
t.Setenv("VPN_TLS_PORT", "")
|
||||
dir := t.TempDir()
|
||||
if err := ConfigurePublicEntry(dir, "http", "121.4.111.208", 28080); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := ConfigurePublicEntry(dir, "https", "121.4.111.208", 443); err == nil {
|
||||
t.Fatal("HTTPS IPv4 was persisted")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFailedHTTPSBindReleasesHTTPPort(t *testing.T) {
|
||||
t.Setenv("VPN_TLS_DOMAIN", "test-link.appx365.com")
|
||||
occupied, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
|
||||
Reference in new issue
Block a user