1
0
Fork 0
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:
Ole Bertram 2023-12-06 19:48:05 +01:00 committed by Frédéric Guillot
parent 95039410b5
commit 698bea4ec8
3 changed files with 14 additions and 15 deletions

View file

@ -30,20 +30,13 @@ func FindClientIP(r *http.Request) string {
return FindRemoteIP(r)
}
// FindRemoteIP returns remote client IP address.
// FindRemoteIP returns remote client IP address without considering HTTP headers.
func FindRemoteIP(r *http.Request) string {
remoteIP, _, err := net.SplitHostPort(r.RemoteAddr)
if err != nil {
remoteIP = r.RemoteAddr
}
remoteIP = dropIPv6zone(remoteIP)
// When listening on a Unix socket, RemoteAddr is empty.
if remoteIP == "" {
remoteIP = "127.0.0.1"
}
return remoteIP
return dropIPv6zone(remoteIP)
}
func dropIPv6zone(address string) string {