From 921b1adeade58ca0d3edf2ea03043d91bee33281 Mon Sep 17 00:00:00 2001 From: 0ceanSlim Date: Fri, 9 Aug 2024 09:03:14 -0400 Subject: [PATCH] client info struct moved into function --- server/relay.go | 2 +- server/types/clientInfo.go | 7 ------- server/utils/getClientInfo.go | 6 ++++++ 3 files changed, 7 insertions(+), 8 deletions(-) delete mode 100644 server/types/clientInfo.go diff --git a/server/relay.go b/server/relay.go index d45b641..1004408 100644 --- a/server/relay.go +++ b/server/relay.go @@ -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"), diff --git a/server/types/clientInfo.go b/server/types/clientInfo.go deleted file mode 100644 index 8f08429..0000000 --- a/server/types/clientInfo.go +++ /dev/null @@ -1,7 +0,0 @@ -package relay - -type ClientInfo struct { - IP string - UserAgent string - Origin string -} \ No newline at end of file diff --git a/server/utils/getClientInfo.go b/server/utils/getClientInfo.go index 99613e4..1963ad1 100644 --- a/server/utils/getClientInfo.go +++ b/server/utils/getClientInfo.go @@ -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 != "" {