Skip to content
Merged
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion src/api/integrations/event/websocket/websocket.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ export class WebsocketController extends EventController implements EventControl
allowRequest: async (req, callback) => {
try {
const url = new URL(req.url || '', 'http://localhost');
const isInternalConnection = req.socket.remoteAddress === '127.0.0.1' || req.socket.remoteAddress === '::1';
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 handling IPv6-mapped IPv4 addresses for localhost.

Also include '::ffff:127.0.0.1' in the internal connection check to cover IPv6-mapped IPv4 localhost addresses.

Suggested change
const isInternalConnection = req.socket.remoteAddress === '127.0.0.1' || req.socket.remoteAddress === '::1';
const isInternalConnection =
req.socket.remoteAddress === '127.0.0.1' ||
req.socket.remoteAddress === '::1' ||
req.socket.remoteAddress === '::ffff:127.0.0.1';

const params = new URLSearchParams(url.search);

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

Expand Down