Skip to content

Commit b5f0446

Browse files
feat(tunnel): prevent tunnel id collision (#638)
Co-authored-by: Xavier Hamel <xavier.hamel@botpress.com> Co-authored-by: Xavier Hamel <76625630+xavierhamel@users.noreply.github.com>
1 parent 4a430e4 commit b5f0446

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

tunnel/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bpinternal/tunnel",
3-
"version": "0.1.24",
3+
"version": "0.1.25",
44
"description": "Tunneling logic for client and server",
55
"main": "./dist/index.cjs",
66
"browser": "./dist/index.mjs",

tunnel/src/tunnel-server.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,17 @@ export class TunnelServer {
9090
ws.close(code, reason)
9191
return
9292
}
93+
9394
const { tunnelId } = parseResult
95+
if (this._tunnels[tunnelId]) {
96+
ws.close(errors.CLOSE_CODES.TUNNEL_ID_CONFLICT, 'tunnel ID already in use')
97+
return
98+
}
99+
94100
const tunnel = new TunnelHead(tunnelId, ws)
95101
tunnel.events.once('close', () => this._handleDisconnection(tunnelId))
96102
this.events.emit('connection', tunnel)
103+
97104
this._tunnels[tunnelId] = tunnel
98105
}
99106

0 commit comments

Comments
 (0)