From 332f8025858e008f4f963d52788aed1ef1dfbae9 Mon Sep 17 00:00:00 2001 From: wikirp Date: Thu, 5 Feb 2026 23:01:27 -0600 Subject: [PATCH] fix(baileys): enforce correct SOCKS5 protocol usage in service integration --- .../channel/whatsapp/whatsapp.baileys.service.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts index 60e857fcc..bd9b986ec 100644 --- a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts +++ b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts @@ -608,9 +608,14 @@ export class BaileysStartupService extends ChannelStartupService { try { const response = await axios.get(this.localProxy?.host); const text = response.data; - const proxyUrls = text.split('\r\n'); + const proxyUrls = text.split('\r\n').filter(Boolean); const rand = Math.floor(Math.random() * Math.floor(proxyUrls.length)); - const proxyUrl = 'http://' + proxyUrls[rand]; + let proxyUrl = proxyUrls[rand]; + // Si la línea ya tiene protocolo, úsala tal cual. Si no, anteponer el protocolo configurado + if (!/^\w+:\/\//.test(proxyUrl)) { + const proto = this.localProxy?.protocol?.replace(':', '') || 'http'; + proxyUrl = `${proto}://${proxyUrl}`; + } options = { agent: makeProxyAgent(proxyUrl), fetchAgent: makeProxyAgentUndici(proxyUrl) }; } catch { this.localProxy.enabled = false;