Add support for X-Forwarded-For

This commit is contained in:
Pierre-Alain TORET 2018-07-24 22:01:01 +02:00
parent a4d2cf17aa
commit 8ed27bf54b

View File

@ -17,10 +17,18 @@ type wsHandler struct {
} }
func newWSHandler(conn *websocket.Conn, state *State, r *http.Request) *wsHandler { 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{ h := &wsHandler{
ws: newWSConn(conn), ws: newWSConn(conn),
state: state, state: state,
addr: conn.RemoteAddr().String(), addr: address,
} }
h.init(r) h.init(r)
h.initHandlers() h.initHandlers()