-
Notifications
You must be signed in to change notification settings - Fork 5.4k
fix(baileys): enforce correct SOCKS5 protocol usage in service integr… #2416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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]; | ||||||||||||||||||||||||||||
|
Comment on lines
612
to
+613
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: Handle the case where the filtered proxy list is empty before picking a random entry. With |
||||||||||||||||||||||||||||
| // 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}`; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
Comment on lines
+613
to
+618
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Protocol normalization may produce malformed URLs if the configured protocol includes If
Suggested change
|
||||||||||||||||||||||||||||
| options = { agent: makeProxyAgent(proxyUrl), fetchAgent: makeProxyAgentUndici(proxyUrl) }; | ||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||
| this.localProxy.enabled = false; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Use a more robust line-splitting strategy for different newline conventions.
Splitting only on
"\r\n"assumes Windows line endings. If the list is served with Unix-style"\n"only, you’ll get a single, newline-containing entry andfilter(Boolean)won’t fix it. Using something liketext.split(/\r?\n/).filter(Boolean)will correctly handle both CRLF and LF cases.