PAC with multi-proxy load balancing is similar COW

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:

So add up more than one proxy,Then insert a function returning the proxy places:

Here I inserted a okToLoadBalanceVariable as a switch,If you close the same as ordinary pac,It takes effect only on the first agent。

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!

 

 

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 Gerber drop-off: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

About the Author

R0uter

The non-declaration,I have written articles are original,Reproduced, please indicate the link on this page and my name。

Comments

    1. 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。

Leave a Reply

Your email address will not be published. Required fields are marked *