Add multi-proxy support & granular proxy selection#160
Add multi-proxy support & granular proxy selection#160
Conversation
- Support multiple proxies with round-robin selection - Add ProxyNetwork enum (IPv4/IPv6 filtering) - Add ProxyType enum (Mobile/Residential/Datacenter) - Add per-domain routing with glob patterns - Add per-proxy statistics (RequestCount, ErrorCount, LastUsed) - Add context-based proxy type selection - Breaking change: replace Proxy string with Proxies []ProxyConfig
| // ProxyNetwork defines the network layer (IPv4/IPv6) a proxy can support | ||
| type ProxyNetwork int | ||
|
|
||
| const ( | ||
| // ProxyNetworkUnset is the zero value and must not be used - forces explicit selection | ||
| ProxyNetworkUnset ProxyNetwork = iota | ||
| // ProxyNetworkAny means the proxy can be used for both IPv4 and IPv6 connections | ||
| ProxyNetworkAny | ||
| // ProxyNetworkIPv4 means the proxy should only be used for IPv4 connections | ||
| ProxyNetworkIPv4 | ||
| // ProxyNetworkIPv6 means the proxy should only be used for IPv6 connections | ||
| ProxyNetworkIPv6 | ||
| ) |
There was a problem hiding this comment.
Love to see the golang-style enum pattern being used here!
| if proxyConfig.URL == "" { | ||
| continue | ||
| } |
There was a problem hiding this comment.
Why continue without error if URL is blank?
| // ProxyType defines the infrastructure type of a proxy | ||
| type ProxyType int | ||
|
|
||
| const ( | ||
| // ProxyTypeAny means the proxy can be used for any type of request | ||
| ProxyTypeAny ProxyType = iota | ||
| // ProxyTypeMobile means the proxy uses mobile network infrastructure | ||
| ProxyTypeMobile | ||
| // ProxyTypeResidential means the proxy uses residential IP addresses | ||
| ProxyTypeResidential | ||
| // ProxyTypeDatacenter means the proxy uses datacenter infrastructure | ||
| ProxyTypeDatacenter | ||
| ) |
There was a problem hiding this comment.
To me, it seems that ProxyTypeAny represents something different than the other ProxyTypes because it describes the traffic's preference, where as the other types describe the kind of infrastructure the proxy uses
I think part of my confusion is that I understand you might want to send a URL to a proxy with residential IPs, or you might want to send a URL to a proxy with datacenter IPs, but ProxyTypeAny isn't a kind of proxy but is actually a decision that you don't care which proxy type you send the data to
So I'm confused under what condition you would define a proxy as ProxyTypeAny?
|
I didn't finish submitting my review back when this was fresh, so concluded my thoughts and pushed the review today. That being said, perhaps this issue should be closed given the discussion in #186, specifically #186 (comment). @NGTmeaty ? |
Implements a granular multi-proxy system with fine-grained control over proxy selection.
Features
ProxyNetworkenumProxyTypeenumExample: Context-based proxy type selection
Breaking change
Replaces
Proxy stringfield withProxies []ProxyConfiginHTTPClientSettings.