From d5954f81981193208f0f23b8438f01f2617a4711 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Sun, 6 Aug 2017 10:20:55 -0600 Subject: [PATCH] #118: Crash on STDIO doors when logged in via WebSocket --- core/servers/login/websocket.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core/servers/login/websocket.js b/core/servers/login/websocket.js index 6f826cc9..3e018370 100644 --- a/core/servers/login/websocket.js +++ b/core/servers/login/websocket.js @@ -13,7 +13,7 @@ const WebSocketServer = require('ws').Server; const http = require('http'); const https = require('https'); const fs = require('graceful-fs'); -const EventEmitter = require('events'); +const Writable = require('stream'); const ModuleInfo = exports.moduleInfo = { name : 'WebSocket', @@ -34,7 +34,7 @@ function WebSocketClient(ws, req, serverType) { // This bridge makes accessible various calls that client sub classes // want to access on I/O socket // - this.socketBridge = new class SocketBridge extends EventEmitter { + this.socketBridge = new class SocketBridge extends Writable { constructor(ws) { super(); this.ws = ws; @@ -48,6 +48,15 @@ function WebSocketClient(ws, req, serverType) { 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() { // 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;