Compare commits

..

No commits in common. "f3e5cebe45981c344f2bf1fbf95448f90d9c8a52" and "3a1ea39a799f073431fcfea698b6c67a46de8c9a" have entirely different histories.

2 changed files with 20 additions and 24 deletions

View File

@ -164,19 +164,17 @@ class MultiSocketProxy extends proxy_js_1.default {
decode: this._server ? compact_encoding_1.json.decode : socketEncoding.decode, decode: this._server ? compact_encoding_1.json.decode : socketEncoding.decode,
}, },
async onmessage(m) { async onmessage(m) {
if (self._server) { if (self._allowedPorts.length &&
if (self._allowedPorts.length && !self._allowedPorts.includes(m.port)) {
!self._allowedPorts.includes(m.port)) { self.get(await self._getPublicKey(peer)).messages.errorSocket.send({
self.get(await self._getPublicKey(peer)).messages.errorSocket.send({ id: m.id,
id: m.id, err: new Error(`port ${m.port} not allowed`),
err: new Error(`port ${m.port} not allowed`), });
}); return;
return;
}
} }
m = m; m = m;
if (self._server) { if (self._server) {
new self.socketClass(nextSocketId(), m.id, self, self.get(await self._getPublicKey(peer)), m).connect(); new self.socketClass(nextSocketId(), m, self, self.get(await self._getPublicKey(peer)), m).connect();
return; return;
} }
const socket = self._sockets.get(m.id); const socket = self._sockets.get(m.id);

View File

@ -204,19 +204,17 @@ 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) ) {
) { self.get(await self._getPublicKey(peer)).messages.errorSocket.send({
self.get(await self._getPublicKey(peer)).messages.errorSocket.send({ id: (m as SocketRequest).id,
id: (m as SocketRequest).id, err: new Error(
err: new Error( `port ${(m as TcpSocketConnectOpts).port} not allowed`
`port ${(m as TcpSocketConnectOpts).port} not allowed` ),
), });
}); return;
return;
}
} }
m = m as SocketRequest; m = m as SocketRequest;
@ -224,7 +222,7 @@ export default class MultiSocketProxy extends Proxy {
if (self._server) { if (self._server) {
new self.socketClass( new self.socketClass(
nextSocketId(), nextSocketId(),
m.id, m,
self, self,
self.get(await self._getPublicKey(peer)) as PeerEntity, self.get(await self._getPublicKey(peer)) as PeerEntity,
m m