Saturday, October 8, 2011

PAC and DNS requests annoyed problem

there are serveral functions that are not working properly as we expected, they always perform DNS request to DNS servers which we do not like to see:

isResolvable(host);

isInNet(host, "999.99.9.9", "255.0.255.0");

If those functions are invoked, a numerous DNS requests are generated from the client, so the clients just dully wait for the responses for those requests, therefore to the end-users, it just like the broswer is dreadfully dead there.



if (isResolvable(host))
 return "DIRECT";
 else
 return "PROXY 172.30.19.190:8080";

this, the "isResolvable" evil cuased a lot of troubles to our broswers, we did not expect the client initiate DNS request, instead, we would work everything with proxy, every request is and should be performed by proxy. Unfortunately, our PAC script is not that clever, since it is a locally functioned script, it cannot ask proxy server to the "isResolvable" functionality, it has to be done by the broswer which employs so many useless DNS requests to us. In order to avoid this scenario happens to us, we should avoid to use those functions.

Here below is my solution, I know, it's really far away from perfect, if you have any better ideas, just share it!


 if (isPlainHostName(host)
     || dnsDomainIs(host, "companydomain.com")
     || (url.substring(7, 12) == "192.10.") //for ftp
     || (url.substring(7, 12) == "192.11.")
     || (url.substring(8, 13) == "192.11.") //for http
     || (url.substring(8, 13) == "192.10.")
     || (host == "127.0.0.1"))
 return "DIRECT";
 else
 return "PROXY proxy:8080";

No comments:

Post a Comment