Skip to content
Merged
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
6 changes: 5 additions & 1 deletion src/api/integrations/event/websocket/websocket.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ export class WebsocketController extends EventController implements EventControl
const url = new URL(req.url || '', 'http://localhost');
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';
Comment on lines +34 to +35
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider IPv6-mapped IPv4 and proxy scenarios for localhost detection.

This check may not handle all localhost scenarios, such as alternative IPv6-mapped formats or proxy headers like X-Forwarded-For. Consider updating the logic or documenting these limitations if relevant to your deployment.


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

Expand Down