diff --git a/site_analytics.go b/site_analytics.go index 7312952..eff5ad4 100644 --- a/site_analytics.go +++ b/site_analytics.go @@ -172,16 +172,7 @@ func analyticsSameOriginRequest(r *http.Request) bool { } func analyticsRemoteAddress(r *http.Request) string { - if r == nil { - return "unknown" - } - if forwarded := strings.TrimSpace(strings.Split(r.Header.Get("X-Forwarded-For"), ",")[0]); forwarded != "" { - return forwarded - } - if host, _, err := net.SplitHostPort(strings.TrimSpace(r.RemoteAddr)); err == nil { - return host - } - return strings.TrimSpace(r.RemoteAddr) + return requestClientIP(r) } func (s *siteAnalyticsStore) allowRequest(r *http.Request) bool {