Merge pull request #30 from daftaupe/#26

Add support for X-Forwarded-For
This commit is contained in:
Ken-Håvard Lieng 2018-07-25 00:18:29 +02:00 committed by GitHub
commit e2c6cedc27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()