Changes between Version 2 and Version 3 of TipAndDoc/network/proxy


Ignore:
Timestamp:
Jan 1, 2013 10:47:12 AM (11 years ago)
Author:
mitty
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TipAndDoc/network/proxy

    v2 v3  
    7070  * [http://yuichi.tea-nifty.com/blog/2008/12/googlechrome-c0.html GoogleChrome に独立したプロキシ設定: な○の 屋] 
    7171  * {{{--proxy-pac-url}}}によるpacファイルの指定は、インターネットオプション > 接続 > LANの設定 > 自動構成スクリプト よりも優先される 
     72 
     73 == example == 
     74 * chrome-proxy.pac 
     75{{{#!javascript 
     76function useProxy(host) { 
     77    if ( 
     78            dnsDomainIs(host, "mitty.jp") 
     79        ||  dnsDomainIs(host, "tsukuba.ac.jp") 
     80    ) { 
     81        return true; 
     82    } 
     83    return false; 
     84} 
     85 
     86function detectNet(ipaddr) { 
     87    if (isInNet(ipaddr, "192.168.0.0", "255.255.255.0")) { 
     88        // maybe local 
     89        if (isInNet(dnsResolve("some.host.example.jp"), "192.168.0.0", "255.255.255.0")) { 
     90            return 'LOCAL'; 
     91        } 
     92        else { 
     93            return 'UNKNOWN'; 
     94        } 
     95    } 
     96    if (isInNet(ipaddr, "192.168.100.0", "255.255.255.0")) { 
     97        return 'GUEST'; 
     98    } 
     99     
     100    return 'UNKNOWN'; 
     101} 
     102 
     103var localnet = detectNet(myIpAddress()); 
     104 
     105function FindProxyForURL(url, host) { 
     106    if (! useProxy(host)) { 
     107        return "DIRECT"; 
     108    } 
     109    if (localnet == 'LOCAL') { 
     110        return "PROXY proxy.local.example.net:8080"; 
     111    } 
     112    if (localnet == 'GUEST') { 
     113        // alternative port 
     114        return "HTTPS proxy.example.net:8443"; 
     115    } 
     116     
     117    return "HTTPS proxy.example.jp:443"; 
     118} 
     119}}} 
     120 * HTTPSを使用しているので、chrome専用 
     121 * mitty.jp, tsukuba.ac.jpで終わるドメインに対してのみプロクシを使用 
     122 * 現在のネットワークをmyIpAddress()から判断し、プロクシを切り替えている 
     123  * 特定のFQDN(some.host.example.jp)がプライベートIPに名前解決できるかで確認を取っている