Use referrer host for remote

This commit is contained in:
Ingo Oppermann 2024-03-11 14:47:09 +01:00
parent ebcde477eb
commit 5ba18569e9
No known key found for this signature in database
GPG Key ID: 2AB32426E9DD229E

View File

@ -1,6 +1,8 @@
package session
import (
"net/url"
"github.com/labstack/echo/v4"
"github.com/lithammer/shortuuid/v4"
)
@ -19,7 +21,11 @@ func (h *handler) handleHTTP(c echo.Context, ctxuser string, data map[string]int
if len(req.URL.RawQuery) != 0 {
location += "?" + req.URL.RawQuery
}
remote := req.RemoteAddr
referrer := req.Header.Get("Referer")
if u, err := url.Parse(referrer); err == nil {
referrer = u.Host
}
id := shortuuid.New()
@ -35,7 +41,7 @@ func (h *handler) handleHTTP(c echo.Context, ctxuser string, data map[string]int
}
res.Writer = w
h.httpCollector.RegisterAndActivate(id, "", location, remote)
h.httpCollector.RegisterAndActivate(id, "", location, referrer)
h.httpCollector.Extra(id, data)
defer h.httpCollector.Close(id)