mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-08-29 02:36:11 -06:00
Securing websockets
This commit is contained in:
parent
9cdb897a0f
commit
4f043f9576
@ -28,10 +28,11 @@ export class WebsocketController extends EventController implements EventControl
|
|||||||
allowRequest: async (req, callback) => {
|
allowRequest: async (req, callback) => {
|
||||||
try {
|
try {
|
||||||
const url = new URL(req.url || '', 'http://localhost');
|
const url = new URL(req.url || '', 'http://localhost');
|
||||||
|
const isInternalConnection = req.socket.remoteAddress === '127.0.0.1' || req.socket.remoteAddress === '::1';
|
||||||
const params = new URLSearchParams(url.search);
|
const params = new URLSearchParams(url.search);
|
||||||
|
|
||||||
// Permite conexões internas do Socket.IO (EIO=4 é o Engine.IO v4)
|
// 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);
|
return callback(null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user