mirror of
https://github.com/0ceanSlim/grain.git
synced 2024-10-30 01:26:32 +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++
|
currentConnections++
|
||||||
mu.Unlock()
|
mu.Unlock()
|
||||||
|
|
||||||
clientInfo := relay.ClientInfo{
|
clientInfo := utils.ClientInfo{
|
||||||
IP: utils.GetClientIP(ws.Request()),
|
IP: utils.GetClientIP(ws.Request()),
|
||||||
UserAgent: ws.Request().Header.Get("User-Agent"),
|
UserAgent: ws.Request().Header.Get("User-Agent"),
|
||||||
Origin: ws.Request().Header.Get("Origin"),
|
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"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type ClientInfo struct {
|
||||||
|
IP string
|
||||||
|
UserAgent string
|
||||||
|
Origin string
|
||||||
|
}
|
||||||
|
|
||||||
func GetClientIP(r *http.Request) string {
|
func GetClientIP(r *http.Request) string {
|
||||||
xff := r.Header.Get("X-Forwarded-For")
|
xff := r.Header.Get("X-Forwarded-For")
|
||||||
if xff != "" {
|
if xff != "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user