Refuse a host in a short or legacy numeric form (127.1, 2130706433, 0x7f.0.0.1) in netcheck_request before any lookup, so the refusal does not depend on the resolver
mesh/merge-gate head a01e1ea7fb64 merged into trunk d74c1cb995a4 — pass: builds netcheck → ace, g14, novox, shanks; no bus step; every machine composes wit…
mesh/repo-check head a01e1ea7fb64 merged into trunk d74c1cb995a4 — pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (go), merge-…
mesh/delivery delivered
mesh/merge-gate head a01e1ea7fb64 merged into trunk d74c1cb995a4 — pass: builds netcheck → ace, g14, novox, shanks; no bus step; every machine composes wit…
mesh/repo-check head a01e1ea7fb64 merged into trunk d74c1cb995a4 — pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (go), merge-…
mesh/delivery delivered
This commit is contained in:
@@ -34,7 +34,7 @@ func TestRequestRefusesLocalAddresses(t *testing.T) {
|
||||
port := srv.Listener.Addr().(*net.TCPAddr).Port
|
||||
refusing(t)
|
||||
for _, host := range []string{
|
||||
"127.0.0.1", "localhost", "127.1", "[::1]", "[::ffff:127.0.0.1]", "0.0.0.0", "[::]",
|
||||
"127.0.0.1", "localhost", "127.1", "2130706433", "0x7f.0.0.1", "0x7f.1", "0177.0.0.1", "[::1]", "[::ffff:127.0.0.1]", "0.0.0.0", "[::]",
|
||||
"169.254.169.254", "[fe80::1]",
|
||||
} {
|
||||
u := "http://" + host + ":" + strconv.Itoa(port) + "/"
|
||||
@@ -45,6 +45,20 @@ func TestRequestRefusesLocalAddresses(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestShortFormAddressIsRefusedOnItsOwnWords(t *testing.T) {
|
||||
for _, host := range []string{"127.1", "2130706433", "0x7f.0.0.1", "0x7f.1", "0177.0.0.1"} {
|
||||
_, err := asked(t, map[string]any{"url": "http://" + host + ":1/", "timeout_ms": float64(2000)})
|
||||
if err == nil || !strings.Contains(err.Error(), "short or legacy form") {
|
||||
t.Errorf("%s: want the short-form refusal, got %v", host, err)
|
||||
}
|
||||
}
|
||||
for _, host := range []string{"example.com", "127.0.0.1", "1.example.com", "[::1]", "10.0.0.1"} {
|
||||
if shortFormAddress(strings.Trim(host, "[]")) {
|
||||
t.Errorf("%s taken for a short form", host)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRequestIgnoresProxyEnvironment(t *testing.T) {
|
||||
t.Setenv("HTTP_PROXY", "http://127.0.0.1:1")
|
||||
t.Setenv("http_proxy", "http://127.0.0.1:1")
|
||||
|
||||
Reference in New Issue
Block a user