mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 03:53:22 +02:00
Websocket loadbalancers might run in tcp mode, which makes it difficult to add the X-Forwarded-For header. Pass the IP in the query string instead.
This commit is contained in:
@@ -66,10 +66,12 @@ module.exports = function(options) {
|
||||
io.use(auth)
|
||||
|
||||
io.on('connection', function(socket) {
|
||||
var channels = []
|
||||
, user = socket.request.user
|
||||
var req = socket.request
|
||||
, user = req.user
|
||||
, channels = []
|
||||
|
||||
socket.emit('socket.ip', socket.request.ip)
|
||||
user.ip = socket.handshake.query.uip || req.ip
|
||||
socket.emit('socket.ip', user.ip)
|
||||
|
||||
function joinChannel(channel) {
|
||||
channels.push(channel)
|
||||
@@ -672,7 +674,7 @@ module.exports = function(options) {
|
||||
.on('forward.test', function(channel, responseChannel, data) {
|
||||
joinChannel(responseChannel)
|
||||
if (!data.targetHost || data.targetHost === 'localhost') {
|
||||
data.targetHost = socket.request.ip
|
||||
data.targetHost = user.ip
|
||||
}
|
||||
push.send([
|
||||
channel
|
||||
@@ -684,7 +686,7 @@ module.exports = function(options) {
|
||||
})
|
||||
.on('forward.create', function(channel, responseChannel, data) {
|
||||
if (!data.targetHost || data.targetHost === 'localhost') {
|
||||
data.targetHost = socket.request.ip
|
||||
data.targetHost = user.ip
|
||||
}
|
||||
joinChannel(responseChannel)
|
||||
push.send([
|
||||
|
||||
Reference in New Issue
Block a user