Skip to content

Commit d4eb61f

Browse files
committed
Improving localhost check
1 parent 4f043f9 commit d4eb61f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/api/integrations/event/websocket/websocket.controller.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@ export class WebsocketController extends EventController implements EventControl
2828
allowRequest: async (req, callback) => {
2929
try {
3030
const url = new URL(req.url || '', 'http://localhost');
31-
const isInternalConnection = req.socket.remoteAddress === '127.0.0.1' || req.socket.remoteAddress === '::1';
3231
const params = new URLSearchParams(url.search);
3332

33+
const remoteAddress = req.socket.remoteAddress;
34+
const isLocalhost =
35+
remoteAddress === '127.0.0.1' || remoteAddress === '::1' || remoteAddress === '::ffff:127.0.0.1';
36+
3437
// Permite conexões internas do Socket.IO (EIO=4 é o Engine.IO v4)
35-
if (params.has('EIO') && isInternalConnection) {
38+
if (params.has('EIO') && isLocalhost) {
3639
return callback(null, true);
3740
}
3841

0 commit comments

Comments
 (0)