PAC 代理配置问题 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
请不要在回答技术问题时复制粘贴 AI 生成的内容
lancn

PAC 代理配置问题

  •  
  •   lancn 2017 年 7 月 27 日 4190 次点击
    这是一个创建于 3195 天前的主题,其中的信息可能已经有所发展或是发生改变。

    是这样的 我的网站最近部分移动用户反映打不开,想通过代理的方式实现移动宽带用户访问 PAC 可单独控制代理规则,想做一个 PAC 文件,用户访问 aaa.cn 走代理,其余正常

    function FindProxyForURL(url, host) {

    if (shExpMatch(url, ".aaa.cn/")) { return "SOCKS5 59.110.224.187:1080"; } if (shExpMatch(url, ".bbb.cn/")) { return "SOCKS5 59.110.224.187:1080"; } if (shExpMatch(url, ".ip138.com/")) { return "SOCKS5 59.110.224.187:1080"; } if (shExpMatch(url, ".ip.cn/")) { return "SOCKS5 59.110.224.187:1080"; }

    }

    pac 代理配置如上,但是网站域名 aaa.cn (无 www )怎么也不生效,只有 www 的生效的,是我配置的设置有误嘛,之前尝试过各种 url ( aaa.cn *.aaa.cn http://aaa.cn http://aaa.cn/*)

    求解~

    4 条回复    2017-07-28 11:59:45 +08:00
    ajan
        1
    ajan  
       2017 年 7 月 27 日   1
    去掉 shExpMatch 判断方法!

    这里面是 js 脚本,随便写写
    lancn
        2
    lancn  
    OP
       2017 年 7 月 27 日
    JS 不是太懂,去掉判断的话就不可以区分域名代理了 /哭
    flynaj
        3
    flynaj  
       2017 年 7 月 27 日   1
    var domains = { //google
    "googleusercontent.com": 1,
    "google.com": 1,
    "gstatic.com": 1,
    "youtube.com": 1,
    "ytimg.com": 1,
    "ggpht.com": 1,
    "googlevideo.com": 1,
    "chromium.org": 1,
    "appspot.com": 1,
    "golang.org": 1,
    "googleapis.com": 1,
    "chrome.com": 1,
    "google.tk": 1,
    "android.com": 1,
    "goo.gl": 1

    };

    var proxy = "proxy 127.0.0.1:8080;";

    var direct = 'DIRECT;';


    var hasOwnProperty = Object.hasOwnProperty;

    function FindProxyForURL(url, host) {
    var suffix;
    var pos = host.lastIndexOf('.');
    pos = host.lastIndexOf('.', pos - 1);
    while(1) {
    if (pos == -1) {
    if (hasOwnProperty.call(domains, host)) {
    return proxy;
    } else {
    return direct;
    }
    }
    suffix = host.substring(pos + 1);
    if (hasOwnProperty.call(domains, suffix)) {
    return proxy;
    }
    pos = host.lastIndexOf('.', pos - 1);
    }
    }
    stevegy
        4
    stevegy  
       2017 年 7 月 28 日   1
    我这里用了 host 参数,没使用 url。名单的话,维护那个数组就可以了。shExpMatch 是正则表达式,注意这里那些星号。我只是比较偷懒。。。


    function FindProxyForURL(url, host)
    {
    var proxy_yes = "SOCKS5 59.110.224.187:1080";

    var proxy_no = "DIRECT";

    var l = [
    "*google*",
    "*goo.gl*",
    "*gmail*",
    "*youtube*",
    "*ytimg.com*",
    "*chrome.com*",
    "*android.com*",
    "*ggpht.com*",
    "*blogger.com*",
    "*wordpress.com*",
    "*facebook.com*",
    "*twitter.com*",
    "*twimg.com*",
    "*tumblr.com*",
    "*instagram.com*",
    "*blogspot.com*",
    "*blogblog.com*",
    "dist.github.com*",
    "*.tensorflow.org*",
    "*shadowsocks.org*",
    ];

    for(var i=0; i<l.length; i++) {
    if ( shExpMatch(host, l[i]) ) return proxy_yes;
    }
    return proxy_no;

    }
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2661 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 61ms UTC 04:12 PVG 12:12 LAX 21:12 JFK 00:12
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86