From 8ed27bf54bce1077b1807d17c2267f7b12de842d Mon Sep 17 00:00:00 2001 From: Pierre-Alain TORET Date: Tue, 24 Jul 2018 22:01:01 +0200 Subject: [PATCH] Add support for X-Forwarded-For --- server/websocket_handler.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server/websocket_handler.go b/server/websocket_handler.go index fa87aabb..4772e467 100644 --- a/server/websocket_handler.go +++ b/server/websocket_handler.go @@ -17,10 +17,18 @@ type wsHandler struct { } func newWSHandler(conn *websocket.Conn, state *State, r *http.Request) *wsHandler { + var address string + + if r.Header.Get("X-Forwarded-For") != "" { + address = r.Header.Get("X-Forwarded-For") + } else { + address = conn.RemoteAddr().String() + } + h := &wsHandler{ ws: newWSConn(conn), state: state, - addr: conn.RemoteAddr().String(), + addr: address, } h.init(r) h.initHandlers()