Skip to content

Commit 332f802

Browse files
committed
fix(baileys): enforce correct SOCKS5 protocol usage in service integration
1 parent cd800f2 commit 332f802

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,9 +608,14 @@ export class BaileysStartupService extends ChannelStartupService {
608608
try {
609609
const response = await axios.get(this.localProxy?.host);
610610
const text = response.data;
611-
const proxyUrls = text.split('\r\n');
611+
const proxyUrls = text.split('\r\n').filter(Boolean);
612612
const rand = Math.floor(Math.random() * Math.floor(proxyUrls.length));
613-
const proxyUrl = 'http://' + proxyUrls[rand];
613+
let proxyUrl = proxyUrls[rand];
614+
// Si la línea ya tiene protocolo, úsala tal cual. Si no, anteponer el protocolo configurado
615+
if (!/^\w+:\/\//.test(proxyUrl)) {
616+
const proto = this.localProxy?.protocol?.replace(':', '') || 'http';
617+
proxyUrl = `${proto}://${proxyUrl}`;
618+
}
614619
options = { agent: makeProxyAgent(proxyUrl), fetchAgent: makeProxyAgentUndici(proxyUrl) };
615620
} catch {
616621
this.localProxy.enabled = false;

0 commit comments

Comments
 (0)