* Refactor multiSocket.ts to check for server mode before checking for allowedPorts inclusion when accepting a new socket connection.

This commit is contained in:
Derrick Hammer 2023-04-16 17:13:47 -04:00
parent 3a1ea39a79
commit e3e6757e47
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 13 additions and 11 deletions

View File

@ -204,6 +204,7 @@ export default class MultiSocketProxy extends Proxy {
decode: this._server ? json.decode : socketEncoding.decode, decode: this._server ? json.decode : socketEncoding.decode,
}, },
async onmessage(m: SocketRequest | TcpSocketConnectOpts) { async onmessage(m: SocketRequest | TcpSocketConnectOpts) {
if (self._server) {
if ( if (
self._allowedPorts.length && self._allowedPorts.length &&
!self._allowedPorts.includes((m as TcpSocketConnectOpts).port) !self._allowedPorts.includes((m as TcpSocketConnectOpts).port)
@ -216,6 +217,7 @@ export default class MultiSocketProxy extends Proxy {
}); });
return; return;
} }
}
m = m as SocketRequest; m = m as SocketRequest;