mirror of
https://github.com/miniflux/v2.git
synced 2025-09-15 18:57:04 +00:00
Fix inaccessible metrics endpoint when listening on Unix socket
This commit is contained in:
parent
95039410b5
commit
698bea4ec8
3 changed files with 14 additions and 15 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue