Cache myIpAddress() result
Maxoudela opened this issue · comments
I have a PAC script that is very long and very complex. Basically it makes more than 600 calls to myIpAddress()
. One solution would be to put the result into a variable in the pac script and then use that variable instead of calling my myIpAddress()
over and over. Unfortunately, I cannot force my client to modify their PAC script.
If I profile my application, it seems that most of the time is spent in the getLocalAddressOfType
method, especially on
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
My guess is that Windows has a security for process that are requesting too many things and put requests on hold on purpose.
I believe we could then cache the IP address returned in myIpAddress() somehow. What are you thoughts on that?
For example, one quick and dirty fix in PacScriptMethods
:
public static String CACHED_IP = null;
/**
* ***********************************************************************
* Returns the IP address of the host that the process is running on, as a
* string in the dot-separated integer format.
*
* @return an IP as string.
* **********************************************************************
*/
public String myIpAddress() {
if (CACHED_IP == null) {
CACHED_IP = getLocalAddressOfType(Inet4Address.class);
}
return CACHED_IP;
}
Markus doesn't answer any issues or pull requests here for nearly a year now. This project is dead, I think. Unfortunately. :-(
I don't think that commenting on every issues will bring Markus back..
I've checked its github and I've seen some activities. This is a personal project and it's being updated/maintained by Markus on its free time. I can understand, for some reasons, that he does not have the time to handle this project.
But maybe he will in the future :)
That doesn't stop us from opening issues, making some pull request and have our own version of the Proxy-vole.
I do confirm that this issue has been fixed in https://github.com/akuhtz/proxy-vole/
Switching to this fork from now on, closing issue.