mirror of
https://github.com/0ceanSlim/grain.git
synced 2024-10-29 17:16:31 +00:00
client info struct moved into function
This commit is contained in:
parent
9a4a55e914
commit
921b1adead
@ -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"),
|
||||
|
@ -1,7 +0,0 @@
|
||||
package relay
|
||||
|
||||
type ClientInfo struct {
|
||||
IP string
|
||||
UserAgent string
|
||||
Origin string
|
||||
}
|
@ -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 != "" {
|
||||
|
Loading…
Reference in New Issue
Block a user