client info struct moved into function

This commit is contained in:
0ceanSlim 2024-08-09 09:03:14 -04:00
parent 9a4a55e914
commit 921b1adead
3 changed files with 7 additions and 8 deletions

View File

@ -40,7 +40,7 @@ func WebSocketHandler(ws *websocket.Conn) {
currentConnections++
mu.Unlock()
clientInfo := relay.ClientInfo{
clientInfo := utils.ClientInfo{
IP: utils.GetClientIP(ws.Request()),
UserAgent: ws.Request().Header.Get("User-Agent"),
Origin: ws.Request().Header.Get("Origin"),

View File

@ -1,7 +0,0 @@
package relay
type ClientInfo struct {
IP string
UserAgent string
Origin string
}

View File

@ -5,6 +5,12 @@ import (
"strings"
)
type ClientInfo struct {
IP string
UserAgent string
Origin string
}
func GetClientIP(r *http.Request) string {
xff := r.Header.Get("X-Forwarded-For")
if xff != "" {