fix: support explicit http proxy protocol#13
fix: support explicit http proxy protocol#13TBDevMaster wants to merge 1 commit intoEvolutionAPI:mainfrom
Conversation
Reviewer's GuideAdds protocol-aware proxy support (HTTP/HTTPS/SOCKS5) to Evolution Go by normalizing proxy protocol, building generic proxy URLs, wiring configuration/env/instance APIs to carry the protocol field, and updating docs and logging, so QR pairing works behind HTTP proxies instead of assuming SOCKS5 only. Sequence diagram for updating and applying instance proxy with protocolsequenceDiagram
actor Client
participant InstanceHandler
participant InstancesService
participant Utils
participant InstanceRepository
participant WhatsmeowService
participant WhatsmeowClient
Client->>InstanceHandler: POST /instance/proxy/{id} body SetProxyStruct
InstanceHandler->>InstancesService: SetProxyFromStruct(id, data)
InstancesService->>InstancesService: build InstanceProxyConfig from SetProxyStruct
InstancesService->>InstancesService: SetProxy(id, proxyConfig)
InstancesService->>Utils: NormalizeProxyProtocol(proxyConfig.Protocol, proxyConfig.Port)
Utils-->>InstancesService: normalizedProtocol
InstancesService->>InstancesService: set proxyConfig.Protocol = normalizedProtocol
InstancesService->>InstanceRepository: UpdateProxy(id, proxyJSON)
InstanceRepository-->>InstancesService: ok
InstancesService->>InstancesService: log Proxy configuration updated
InstancesService->>WhatsmeowService: Reconnect(instance)
WhatsmeowService->>WhatsmeowService: StartClient(cd)
WhatsmeowService->>WhatsmeowService: resolve proxyHost, proxyPort, proxyProtocol, proxyUsername, proxyPassword
WhatsmeowService->>Utils: BuildProxyAddress(proxyProtocol, proxyHost, proxyPort, proxyUsername, proxyPassword)
Utils-->>WhatsmeowService: proxyAddress or error
alt proxyAddress built
WhatsmeowService->>WhatsmeowClient: SetProxyAddress(proxyAddress)
WhatsmeowClient-->>WhatsmeowService: ok
WhatsmeowService->>WhatsmeowService: log Proxy enabled (protocol)
else build or set failed
WhatsmeowService->>WhatsmeowService: log Proxy error, continuing without proxy
end
Class diagram for updated proxy configuration and utilitiesclassDiagram
class Config {
+string ProxyHost
+string ProxyProtocol
+string ProxyPort
+string ProxyUsername
+string ProxyPassword
}
class InstanceProxyConfig {
+string Protocol
+string Host
+string Port
+string Username
+string Password
}
class WhatsmeowProxyConfig {
+string Protocol
+string Host
+string Port
+string Username
+string Password
}
class SetProxyStruct {
+string Protocol
+string Host
+string Port
+string Username
+string Password
}
class CreateStruct {
+InstanceProxyConfig Proxy
}
class InstancesService {
+Create(data CreateStruct) Instance
+SetProxy(id string, proxyConfig InstanceProxyConfig) error
+SetProxyFromStruct(id string, data SetProxyStruct) error
}
class Utils {
+NormalizeProxyProtocol(protocol string, port string) string
+BuildProxyAddress(protocol string, host string, port string, user string, password string) (string, error)
}
class WhatsmeowService {
+StartClient(cd ClientData) void
+StartInstance(instanceId string) error
}
Config --> WhatsmeowService : provides proxy settings
Config --> InstancesService : provides default proxy
SetProxyStruct --> InstancesService : input
InstanceProxyConfig <-- CreateStruct : field Proxy
InstanceProxyConfig <-- InstancesService : uses
InstanceProxyConfig <-- WhatsmeowService : uses
WhatsmeowProxyConfig <-- WhatsmeowService : uses
Utils <.. InstancesService : uses NormalizeProxyProtocol
Utils <.. WhatsmeowService : uses NormalizeProxyProtocol
Utils <.. WhatsmeowService : uses BuildProxyAddress
Flow diagram for NormalizeProxyProtocol behaviorflowchart TD
A[Input protocol and port] --> B[normalized = lowercased trimmed protocol]
B --> C{normalized is socks?}
C -- yes --> D[return socks5]
C -- no --> E{normalized is http, https or socks5?}
E -- yes --> F[return normalized]
E -- no --> G{port is 1080 or 2080?}
G -- yes --> H[return socks5]
G -- no --> I[try parse port as integer]
I --> J{parse ok and 42000 <= port <= 43000?}
J -- yes --> H
J -- no --> K[return http]
D --> L[End]
F --> L
H --> L
K --> L
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
BuildProxyAddress, you validate against the normalized protocol but emit an error message using the originalprotocolvalue; consider either validating against the raw value or using the normalized one in the error message so users get clearer, more consistent feedback (e.g., if they passedSOCKS). - There are now two
ProxyConfigstructs (inpkg/whatsmeow/serviceandpkg/instance/service) that must stay in sync as new fields likeprotocolare added; consider extracting a shared type to reduce duplication and the risk of divergence.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `BuildProxyAddress`, you validate against the normalized protocol but emit an error message using the original `protocol` value; consider either validating against the raw value or using the normalized one in the error message so users get clearer, more consistent feedback (e.g., if they passed `SOCKS`).
- There are now two `ProxyConfig` structs (in `pkg/whatsmeow/service` and `pkg/instance/service`) that must stay in sync as new fields like `protocol` are added; consider extracting a shared type to reduce duplication and the risk of divergence.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
I opened a PR with a proposed fix: What I validated:
So this appears to fix the proxy bootstrap issue for HTTP proxies while preserving SOCKS5 support. |
|
Thanks for the quick fix — just dropping in to confirm this is exactly the bug we were seeing with Evolution Go + NodeMaven residential proxy, and that this branch resolves it in our real deployment. Same root cause, independently reproducedWe hit the identical symptom in our DES environment using NodeMaven HTTP proxy ( Measured traffic delta on the NodeMaven API (stats endpoint) during a stuck pairing attempt: 0 bytes. So we confirmed independently that the whatsmeow client never actually reached the HTTP proxy — it was trying SOCKS5 on an HTTP endpoint and failing silently. Your source-code analysis ( Validation of this PR's patchInstead of writing a parallel fix, I built
Additional notes from our testing
Would love to see this merged so we can switch back to |
Summary
This fixes proxy-based QR pairing for HTTP proxies.
Evolution Go documentation currently describes instance proxy configuration in a way that suggests HTTP proxy support, but the runtime client bootstrap was always creating a SOCKS5 dialer. In practice, this caused QR pairing to hang when using HTTP proxy providers such as NodeMaven on port 8080.
What changed
protocolsupport to proxy configurationPROXY_PROTOCOLto global config/envclient.SetProxyAddress(...)socks5for common SOCKS ports (1080,2080,42000-43000)httpotherwiseprotocolWhy
I reproduced the issue with the same proxy in two stacks:
After this patch, local testing with the same NodeMaven HTTP proxy produced:
Proxy enabled (http)Notes
This keeps SOCKS5 support available, but stops forcing SOCKS5 for proxy configurations that are actually HTTP.
Summary by Sourcery
Add protocol-aware proxy configuration and fix HTTP proxy support for instance connections and QR pairing.
New Features:
Bug Fixes:
Enhancements:
Documentation: