From 17dc2a031c56a67c115229bad258bb55bbfe4d13 Mon Sep 17 00:00:00 2001 From: cha0s Date: Sun, 13 Dec 2020 06:02:21 -0600 Subject: [PATCH] refactor: trust --- packages/socket/package.json | 1 - packages/socket/src/server.js | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/socket/package.json b/packages/socket/package.json index 164a58e..6ca8aae 100644 --- a/packages/socket/package.json +++ b/packages/socket/package.json @@ -27,7 +27,6 @@ "@latus/react": "^1.0.0", "buffer": "^6.0.3", "debug": "4.3.1", - "express": "^4.17.1", "proxy-addr": "^2.0.6", "schemapack": "^1.4.2", "socket.io": "2.3.0", diff --git a/packages/socket/src/server.js b/packages/socket/src/server.js index 4c2e5e0..fea12c9 100644 --- a/packages/socket/src/server.js +++ b/packages/socket/src/server.js @@ -1,4 +1,3 @@ -import {compileTrust} from 'express/lib/utils'; import proxyaddr from 'proxy-addr'; import SocketIoServer from 'socket.io'; @@ -8,7 +7,6 @@ import SocketIoParser from './packet/socket.io-parser'; export default class SocketServer { constructor(httpServer, latus) { - const {config: {'@latus/http': {trust}}} = latus; // eslint-disable-next-line no-param-reassign latus.config['%sockets'] = this; this.onConnect = this.onConnect.bind(this); @@ -27,7 +25,7 @@ export default class SocketServer { }); latus.invoke('@latus/socket/server.io', this.io); this.io.on('connect', this.onConnect); - const trustFn = compileTrust(trust); + const {app} = httpServer; this.io.use((socket, next) => { Object.defineProperty(socket.handshake, 'ip', { configurable: true, @@ -35,7 +33,7 @@ export default class SocketServer { get: () => proxyaddr({ connection: socket.conn, headers: socket.request.headers, - }, trustFn), + }, app.get('trust proxy fn')), }); latus.invokeMiddleware('@latus/socket/authenticate', socket, next); });