Show the IP information API on the home page (closes #156)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
The home page gets an IP information API card. It shows the curl
command that looks up the visitor's own address at /ip/{addr}. The page
then makes that same request and shows the JSON answer, pretty-printed.
An error answer, such as a 404 for an address with no route, is shown
the same way. A request that fails shows an error line.
The server gives the page the visitor's address, found as /ip/ finds
it, so a trusted proxy's X-Forwarded-For is honoured. The command takes
its origin from the browser, so it names the host the visitor used.
Model: opus-5-5
This commit was merged in pull request #183.
This commit is contained in:
@@ -11,11 +11,12 @@ import (
|
||||
)
|
||||
|
||||
// The addresses the forwarding tests use: the client a proxy names in
|
||||
// X-Forwarded-For, a peer inside the trusted range of
|
||||
// TestRealIPMiddlewareTrustsOnlyConfiguredProxies, and a peer outside it,
|
||||
// which lies in testPrefixV4 so that an IP lookup of it finds a route.
|
||||
// X-Forwarded-For, the range of trusted proxies, a peer inside it, and a peer
|
||||
// outside it, which lies in testPrefixV4 so that an IP lookup of it finds a
|
||||
// route.
|
||||
const (
|
||||
forwardedClient = "203.0.113.9"
|
||||
trustedProxyRange = "10.0.0.0/8"
|
||||
trustedPeer = "10.0.0.2:1234"
|
||||
untrustedPeerAddr = "192.0.2.1"
|
||||
untrustedPeer = untrustedPeerAddr + ":1234"
|
||||
@@ -189,7 +190,7 @@ func TestForwardedForFromUntrustedPeerIsIgnored(t *testing.T) {
|
||||
func TestRealIPMiddlewareTrustsOnlyConfiguredProxies(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
trusted := []netip.Prefix{netip.MustParsePrefix("10.0.0.0/8")}
|
||||
trusted := []netip.Prefix{netip.MustParsePrefix(trustedProxyRange)}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
Reference in New Issue
Block a user