Some time ago I found using COW this projectAgents do have a very nice feature is that two agents can achieve load balancing and more lines! It is a major default do other backup,By configuring,The proxy mode to hash, you can achieve load balancing multiple lines!
Of course, COW is flawed,It is strange for the first site will be directly connected at least once,This will cause DNS leak,I wrote about this before the specialan articleTalked about,Not repeat them here;The second with a long time do not know my habits problem or algorithm problems,Often encounter can still walk straight Agent,Go straight to the agent;The third rule gave me written on the inside of the network configuration to ignore the agent in frame,I'll go,Although it does not matter but it looks good perverted!
Ok,For intelligent agents for COW,I prefer it this load balancing feature - after all,,I respected whitelist。to this end,I specifically wrote an article,Say"It is time to use the PAC whitelist”。
But usually buy a SS account,We will give you more than one line,Only a simply a waste ah! Especially in the experience COW load balancing - the first time I know that a broadband,Agents can also load balancing ah I went - how ordinary agents can meet my needs ~~~
So I put before breakwa11 whitelist PAC profiles have been used to make a point to modify,It also implements a simple load balancing。
principle
In fact, we are talking about pac is an automatic proxy configuration file to obtain,Browser calls with hooks in resolving the domain name when FindProxyForURL(url, host) This function,In fact,pac profile essence is a javascript script!
so,We only need to write a function pac Rideau,In return, when the agent returns multiple random on the line,So the browser each time you visit a different URL,We will request to a different proxy configuration,So as to achieve load balancing effect。
Shortcoming
Ok,In fact, this is a false load balancing,But it works,Just not so smart,Simple and crude! IP encountered need to verify site you need to set a global proxy or off the job in order to avoid the PAC (fortunately not many sites like this,Cookie are now friends)。
Code
We only returned at the end of the agent configuration to make changes,So it will not affect any other configuration,Theoretically you can use any version of pac do is patch,First we read the proxy address from the array variable:
1 2 3 4 5 |
var wall_proxy = new Array( "SOCKS5 127.0.0.1:1080; SOCKS 127.0.0.1:1080;", "SOCKS5 127.0.0.1:1081; SOCKS 127.0.0.1:1081;", "SOCKS5 127.0.0.1:1081; SOCKS 127.0.0.1:1082;", //add more proxy to loadbalance! "SOCKS5 127.0.0.1:1082; SOCKS 127.0.0.1:1083;"); |
So add up more than one proxy,Then insert a function returning the proxy places:
1 2 3 |
if (okToLoadBalance) { return loadBalance(); } |
Here I inserted a okToLoadBalanceVariable as a switch,If you close the same as ordinary pac,It takes effect only on the first agent。
1 2 3 4 5 6 7 8 9 |
function loadBalance() { var random = 0; while(1) { random = Math.round((Math.random() * 10) - 1); if (random < wall_proxy.length) { return wall_proxy[random]; } } } |
Then according javascript random number generation to implement an array of randomly selected agents entries returned,Here I made a selector,Will be selected according to the number of elements in the array - so that you can support the "arbitrary" number of the proxy entry。
Arbitrary here is the 10 Ha,Well because the random number is 0-1,I think more ...... no sense, right?
So this pac to support load balancing。Safari 9.0.2 100000 Discover execute the query takes a little more than 100 ms,Speed than if no load balancing is not very different。
use
All right,In fact, you do not need to modify yourself,I've been changing for the better too! Download to GitHubI modified version.。
Note that I only modified whitelist.pac-- ie domain whitelist,The other did not move!
1 2 3 4 5 6 7 8 |
cd ~ mkdir git cd git git clone https://github.com/R0uter/gfw_whitelist.git cd gfw_whitelist python main.py //编辑whitelist.pac文件,在第一行打开负载均衡并添加你的代理配置 |
If you're too lazy to generate,Click here to download directlyThe pac file,Open the Edit Proxy can be eaten!
Original article written by LogStudio:R0uter's Blog » PAC with multi-proxy load balancing is similar COW
Reproduced Please keep the source and description link:https://www.logcg.com/archives/1412.html
tcproute2 tried? He said to be better than the cow,You can also write a tutorial ah,Thank you!
cow is softer policy,The advantage is that I read load balancing -,It is also fast iterative,Unstable ah。Not the first test,The main is also not a good client,I still use that no one's goagentx ...... Well maintained。