#118: Crash on STDIO doors when logged in via WebSocket
This commit is contained in:
parent
95696912ed
commit
d5954f8198
|
@ -13,7 +13,7 @@ const WebSocketServer = require('ws').Server;
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
const https = require('https');
|
const https = require('https');
|
||||||
const fs = require('graceful-fs');
|
const fs = require('graceful-fs');
|
||||||
const EventEmitter = require('events');
|
const Writable = require('stream');
|
||||||
|
|
||||||
const ModuleInfo = exports.moduleInfo = {
|
const ModuleInfo = exports.moduleInfo = {
|
||||||
name : 'WebSocket',
|
name : 'WebSocket',
|
||||||
|
@ -34,7 +34,7 @@ function WebSocketClient(ws, req, serverType) {
|
||||||
// This bridge makes accessible various calls that client sub classes
|
// This bridge makes accessible various calls that client sub classes
|
||||||
// want to access on I/O socket
|
// want to access on I/O socket
|
||||||
//
|
//
|
||||||
this.socketBridge = new class SocketBridge extends EventEmitter {
|
this.socketBridge = new class SocketBridge extends Writable {
|
||||||
constructor(ws) {
|
constructor(ws) {
|
||||||
super();
|
super();
|
||||||
this.ws = ws;
|
this.ws = ws;
|
||||||
|
@ -48,6 +48,15 @@ function WebSocketClient(ws, req, serverType) {
|
||||||
return this.ws.send(data, { binary : true }, cb);
|
return this.ws.send(data, { binary : true }, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we need to fake some streaming work
|
||||||
|
unpipe() {
|
||||||
|
Log.trace('WebSocket SocketBridge unpipe()');
|
||||||
|
}
|
||||||
|
|
||||||
|
resume() {
|
||||||
|
Log.trace('WebSocket SocketBridge resume()');
|
||||||
|
}
|
||||||
|
|
||||||
get remoteAddress() {
|
get remoteAddress() {
|
||||||
// Support X-Forwarded-For and X-Real-IP headers for proxied connections
|
// Support X-Forwarded-For and X-Real-IP headers for proxied connections
|
||||||
return (self.proxied && (req.headers['x-forwarded-for'] || req.headers['x-real-ip'])) || req.connection.remoteAddress;
|
return (self.proxied && (req.headers['x-forwarded-for'] || req.headers['x-real-ip'])) || req.connection.remoteAddress;
|
||||||
|
|
Loading…
Reference in New Issue