jeansaad/hotel

View on GitHub
src/daemon/views/proxy-pac-with-proxy.pug

Summary

Maintainability
Test Coverage
.
  // Set conf.proxy in ~/.chalet/conf.json to your proxy address and port.
  // For example: { "proxy": "1.2.3.4:5000" }
  //
  // See also https://en.wikipedia.org/wiki/Private_network
  function FindProxyForURL (url, host) {
    if (dnsDomainIs(host, '.#{conf.tld}')) {
      return 'PROXY #{hostname}:#{conf.port}';
    }

    var address = dnsResolve(host);
    if (
      isPlainHostName(host) ||
      dnsDomainIs(host, '.local') ||
      isInNet(address, '10.0.0.0', '255.0.0.0') ||
      isInNet(address, '172.16.0.0',  '255.240.0.0') ||
      isInNet(address, '192.168.0.0',  '255.255.0.0') ||
      isInNet(address, '127.0.0.0', '255.255.255.0')
    ) {
      return 'DIRECT';
    }

    return 'PROXY #{conf.proxy}';
  }