Compare commits
3 Commits
3a1ea39a79
...
f3e5cebe45
Author | SHA1 | Date |
---|---|---|
Derrick Hammer | f3e5cebe45 | |
Derrick Hammer | 9cb6d0b6e4 | |
Derrick Hammer | e3e6757e47 |
|
@ -164,17 +164,19 @@ class MultiSocketProxy extends proxy_js_1.default {
|
|||
decode: this._server ? compact_encoding_1.json.decode : socketEncoding.decode,
|
||||
},
|
||||
async onmessage(m) {
|
||||
if (self._allowedPorts.length &&
|
||||
!self._allowedPorts.includes(m.port)) {
|
||||
self.get(await self._getPublicKey(peer)).messages.errorSocket.send({
|
||||
id: m.id,
|
||||
err: new Error(`port ${m.port} not allowed`),
|
||||
});
|
||||
return;
|
||||
if (self._server) {
|
||||
if (self._allowedPorts.length &&
|
||||
!self._allowedPorts.includes(m.port)) {
|
||||
self.get(await self._getPublicKey(peer)).messages.errorSocket.send({
|
||||
id: m.id,
|
||||
err: new Error(`port ${m.port} not allowed`),
|
||||
});
|
||||
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);
|
||||
|
|
|
@ -204,17 +204,19 @@ export default class MultiSocketProxy extends Proxy {
|
|||
decode: this._server ? json.decode : socketEncoding.decode,
|
||||
},
|
||||
async onmessage(m: SocketRequest | TcpSocketConnectOpts) {
|
||||
if (
|
||||
self._allowedPorts.length &&
|
||||
!self._allowedPorts.includes((m as TcpSocketConnectOpts).port)
|
||||
) {
|
||||
self.get(await self._getPublicKey(peer)).messages.errorSocket.send({
|
||||
id: (m as SocketRequest).id,
|
||||
err: new Error(
|
||||
`port ${(m as TcpSocketConnectOpts).port} not allowed`
|
||||
),
|
||||
});
|
||||
return;
|
||||
if (self._server) {
|
||||
if (
|
||||
self._allowedPorts.length &&
|
||||
!self._allowedPorts.includes((m as TcpSocketConnectOpts).port)
|
||||
) {
|
||||
self.get(await self._getPublicKey(peer)).messages.errorSocket.send({
|
||||
id: (m as SocketRequest).id,
|
||||
err: new Error(
|
||||
`port ${(m as TcpSocketConnectOpts).port} not allowed`
|
||||
),
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m = m as SocketRequest;
|
||||
|
@ -222,7 +224,7 @@ export default class MultiSocketProxy extends Proxy {
|
|||
if (self._server) {
|
||||
new self.socketClass(
|
||||
nextSocketId(),
|
||||
m,
|
||||
m.id,
|
||||
self,
|
||||
self.get(await self._getPublicKey(peer)) as PeerEntity,
|
||||
m
|
||||
|
|
Loading…
Reference in New Issue