Closed GoogleCodeExporter closed 9 years ago
Hi,
Yes this looks even better. I will need to write some more extensive unit tests
for this method and then see if this is all covered by the implementation.
Thanks for your good input.
Have fun,
- Rossi
Original comment by rosstaus...@googlemail.com
on 24 Mar 2011 at 2:56
Hi, the current (SVN) Version still lacks resolving the host for isInNet. If
host is an hostname a NumberFormatException is thrown.
Why not use a fallback method to parse the hostname (disregarding the costs for
DNS resolving..):
private long parseIpAddressOrHostToLong(String host) {
long result = 0;
try {
result = parseIpAddressToLong(host);
} catch (NumberFormatException e) {
result = parseIpAddressToLong(dnsResolve(host));
}
return result;
}
.. it's easier to implement then an automatic notification "please use the
already resolved IP Address for all the isInNet calls" sent to the "pac script
writer".
Original comment by tuxatwor...@gmail.com
on 24 May 2012 at 9:45
Hi, today I stucked in this isInNet problem and this solutions worked for me,
too! So to make it easy to the others:
1. Check out the latest SVN Version and open it in Eclipse, for example.
2. Open the com.btr.proxy.selector.pac.PacScriptMethods class.
3. Find the function isInNet and replace it with the following two funcs:
public boolean isInNet(String host, String pattern, String mask) {
long lhost = parseIpAddressOrHostToLong(host);
long lpattern = parseIpAddressToLong(pattern);
long lmask = parseIpAddressToLong(mask);
boolean result = (lhost & lmask) == lpattern;
return result;
}
private long parseIpAddressOrHostToLong(String host) {
long result = 0;
try {
result = parseIpAddressToLong(host);
} catch (NumberFormatException e) {
result = parseIpAddressToLong(dnsResolve(host));
}
return result;
}
Thanks you, tuxatwor...@gmail.com
Тoshe
Original comment by toshe...@gmail.com
on 24 May 2012 at 1:53
Hi,
It took some time. Finally I fixed this (hopefully)
Please check out the newest version.
Have fun,
- Rossi
Original comment by rosstaus...@googlemail.com
on 27 Jul 2012 at 9:30
Original issue reported on code.google.com by
jeff%sta...@gtempaccount.com
on 23 Mar 2011 at 4:10Attachments: