* Refactor multiSocket.ts to check for server mode before checking for allowedPorts inclusion when accepting a new socket connection.
This commit is contained in:
parent
3a1ea39a79
commit
e3e6757e47
|
@ -204,17 +204,19 @@ 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 (
|
if (self._server) {
|
||||||
self._allowedPorts.length &&
|
if (
|
||||||
!self._allowedPorts.includes((m as TcpSocketConnectOpts).port)
|
self._allowedPorts.length &&
|
||||||
) {
|
!self._allowedPorts.includes((m as TcpSocketConnectOpts).port)
|
||||||
self.get(await self._getPublicKey(peer)).messages.errorSocket.send({
|
) {
|
||||||
id: (m as SocketRequest).id,
|
self.get(await self._getPublicKey(peer)).messages.errorSocket.send({
|
||||||
err: new Error(
|
id: (m as SocketRequest).id,
|
||||||
`port ${(m as TcpSocketConnectOpts).port} not allowed`
|
err: new Error(
|
||||||
),
|
`port ${(m as TcpSocketConnectOpts).port} not allowed`
|
||||||
});
|
),
|
||||||
return;
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m = m as SocketRequest;
|
m = m as SocketRequest;
|
||||||
|
|
Loading…
Reference in New Issue