|
|
@@ -104,20 +104,20 @@ func TestClientIPWithBothHeaders(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func TestClientIPWithNoRemoteAddress(t *testing.T) {
|
|
|
- r := &http.Request{}
|
|
|
+func TestClientIPWithUnixSocketRemoteAddress(t *testing.T) {
|
|
|
+ r := &http.Request{RemoteAddr: "@"}
|
|
|
|
|
|
- if ip := FindClientIP(r); ip != "127.0.0.1" {
|
|
|
+ if ip := FindClientIP(r); ip != "@" {
|
|
|
t.Fatalf(`Unexpected result, got: %q`, ip)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func TestClientIPWithoutRemoteAddrAndBothHeaders(t *testing.T) {
|
|
|
+func TestClientIPWithUnixSocketRemoteAddrAndBothHeaders(t *testing.T) {
|
|
|
headers := http.Header{}
|
|
|
headers.Set("X-Forwarded-For", "203.0.113.195, 70.41.3.18, 150.172.238.178")
|
|
|
headers.Set("X-Real-Ip", "192.168.122.1")
|
|
|
|
|
|
- r := &http.Request{RemoteAddr: "", Header: headers}
|
|
|
+ r := &http.Request{RemoteAddr: "@", Header: headers}
|
|
|
|
|
|
if ip := FindClientIP(r); ip != "203.0.113.195" {
|
|
|
t.Fatalf(`Unexpected result, got: %q`, ip)
|