Permalink
Browse files

Merge pull request #298 from sveisvei/master

Report correct clientIp when using reverse/forward-proxies
  • Loading branch information...
2 parents e6d4094 + 8a22f18 commit 435f4725ac376f16ea923cd33447bdbb0d17ae7d Owen Barnes committed Sep 23, 2012
Showing with 6 additions and 0 deletions.
  1. +3 −0 lib/websocket/transports/socketio/index.js
  2. +3 −0 src/websocket/transports/socketio/index.coffee

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -35,6 +35,9 @@ module.exports = (ss, emitter, httpServer, config = {}) ->
try
[responderId, content] = utils.parseWsMessage(msg)
clientIp = socket.manager.handshaken[socket.id].address.address
+ if socket.manager.handshaken[socket.id].headers['x-forwarded-for']
+ clientIp = socket.manager.handshaken[socket.id].headers['x-forwarded-for'].split(',')[0]
+
meta = {socketId: socket.id, sessionId: socket.sessionId, clientIp: clientIp, transport: 'socketio'}
emitter.emit responderId, content, meta, (data) ->
socket.send(responderId + '|' + data)

0 comments on commit 435f472

Please sign in to comment.