pac-resolver-gh-3.js 683 B

123456789101112131415161718192021222324
  1. // FindProxyForURL, isInNet
  2. function FindProxyForURL(url, host) {
  3. if (isHostInAnySubnet(host, ['10.1.2.0', '10.1.3.0'], '255.255.255.0')) {
  4. return "HTTPS proxy.example.com";
  5. }
  6. if (isHostInAnySubnet(host, ['10.2.2.0', '10.2.3.0'], '255.255.255.0')) {
  7. return "HTTPS proxy.example.com";
  8. }
  9. // Everything else, go direct:
  10. return "DIRECT";
  11. }
  12. // Checks if the single host is within a list of subnets using the single mask.
  13. function isHostInAnySubnet(host, subnets, mask) {
  14. var subnets_length = subnets.length;
  15. for (i = 0; i < subnets_length; i++) {
  16. if (isInNet(host, subnets[i], mask)) {
  17. return true;
  18. }
  19. }
  20. }