Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ SQS_REGION=
# Websocket - Environment variables
WEBSOCKET_ENABLED=false
WEBSOCKET_GLOBAL_EVENTS=false
WEBSOCKET_ALLOWED_HOSTS=127.0.0.1,::1,::ffff:127.0.0.1

# Pusher - Environment variables
PUSHER_ENABLED=false
Expand Down
9 changes: 5 additions & 4 deletions src/api/integrations/event/websocket/websocket.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ export class WebsocketController extends EventController implements EventControl
const params = new URLSearchParams(url.search);

const { remoteAddress } = req.socket;
const isLocalhost =
remoteAddress === '127.0.0.1' || remoteAddress === '::1' || remoteAddress === '::ffff:127.0.0.1';
const isAllowedHost = (process.env.WEBSOCKET_ALLOWED_HOSTS || '127.0.0.1,::1,::ffff:127.0.0.1')
.split(',')
.map((h) => h.trim())
.includes(remoteAddress);

// Permite conexões internas do Socket.IO (EIO=4 é o Engine.IO v4)
if (params.has('EIO') && isLocalhost) {
if (params.has('EIO') && isAllowedHost) {
return callback(null, true);
}

Expand Down