Compare commits

..

3 Commits

2 changed files with 24 additions and 20 deletions

View File

@ -164,6 +164,7 @@ class MultiSocketProxy extends proxy_js_1.default {
decode: this._server ? compact_encoding_1.json.decode : socketEncoding.decode,
},
async onmessage(m) {
if (self._server) {
if (self._allowedPorts.length &&
!self._allowedPorts.includes(m.port)) {
self.get(await self._getPublicKey(peer)).messages.errorSocket.send({
@ -172,9 +173,10 @@ class MultiSocketProxy extends proxy_js_1.default {
});
return;
}
}
m = m;
if (self._server) {
new self.socketClass(nextSocketId(), m, self, self.get(await self._getPublicKey(peer)), m).connect();
new self.socketClass(nextSocketId(), m.id, self, self.get(await self._getPublicKey(peer)), m).connect();
return;
}
const socket = self._sockets.get(m.id);

View File

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