From 6653f7613e0723f5c1d9f93dadb895c50c99c6ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Fri, 27 Sep 2024 22:35:47 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20windows=E7=9A=84=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E4=BB=A3=E7=90=86=E6=8E=92=E9=99=A4=E5=88=97=E8=A1=A8=E4=B8=AD?= =?UTF-8?q?=EF=BC=8C=E6=8E=92=E9=99=A4=E6=8E=89=E4=B8=AD=E5=9B=BD=E5=9F=9F?= =?UTF-8?q?=E5=90=8D=E7=99=BD=E5=90=8D=E5=8D=95=EF=BC=8C=E5=B9=B6=E6=8F=90?= =?UTF-8?q?=E4=BE=9B=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0=E4=B8=AD=E5=9B=BD?= =?UTF-8?q?=E5=9F=9F=E5=90=8D=E7=99=BD=E5=90=8D=E5=8D=95=E7=9A=84=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=20(#366)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/modules/proxy/index.js | 9 + .../shell/scripts/set-system-proxy/index.js | 152 +++ .../extra/proxy/china-domain-allowlist.txt | 1202 +++++++++++++++++ packages/gui/src/view/pages/proxy.vue | 17 + .../src/lib/proxy/middleware/overwall.js | 9 +- .../src/lib/proxy/middleware/source/pac.js | 2 +- 6 files changed, 1387 insertions(+), 4 deletions(-) create mode 100644 packages/gui/extra/proxy/china-domain-allowlist.txt diff --git a/packages/core/src/modules/proxy/index.js b/packages/core/src/modules/proxy/index.js index 76b4c64..6ce4519 100644 --- a/packages/core/src/modules/proxy/index.js +++ b/packages/core/src/modules/proxy/index.js @@ -56,6 +56,15 @@ module.exports = { other: [], proxyHttp: false, // false=只代理HTTPS请求 true=同时代理HTTP和HTTPS请求 setEnv: false, + + // 排除中国域名 所需配置 + excludeChinaDomainAllowList: true, // 是否排除中国域名,默认:需要排除 + autoUpdateChinaDomainAllowList: true, // 是否自动更新中国域名 + remoteChinaDomainAllowListFileUrl: 'https://raw.githubusercontent.com/pluwen/china-domain-allowlist/refs/heads/main/allow-list.sorl', + chinaDomainAllowListFileAbsolutePath: null, // 自定义 china-domain-allowlist.txt 文件位置,可以是本地文件路径 + chinaDomainAllowListFilePath: './extra/proxy/china-domain-allowlist.txt', // 内置中国域名文件 + + // 自定义系统代理排除列表 excludeIpList: { // region 常用国内可访问域名 diff --git a/packages/core/src/shell/scripts/set-system-proxy/index.js b/packages/core/src/shell/scripts/set-system-proxy/index.js index 09edddf..ae88efd 100644 --- a/packages/core/src/shell/scripts/set-system-proxy/index.js +++ b/packages/core/src/shell/scripts/set-system-proxy/index.js @@ -8,6 +8,9 @@ const execute = Shell.execute const execFile = Shell.execFile const log = require('../../../utils/util.log') const extraPath = require('../extra-path/index') +const fs = require('fs') +const path = require('path') +const request = require('request') let config = null function loadConfig () { @@ -47,6 +50,137 @@ async function _winUnsetProxy (exec, setEnv) { } } +function getChinaDomainAllowListTmpFilePath () { + return path.join(config.get().server.setting.userBasePath, '/china-domain-allowlist.txt') +} + +async function downloadChinaDomainAllowListAsync () { + loadConfig() + + const remoteFileUrl = config.get().proxy.remoteChinaDomainAllowListFileUrl + log.info('开始下载远程 china-domain-allowlist.txt 文件:', remoteFileUrl) + request(remoteFileUrl, (error, response, body) => { + if (error) { + log.error('下载远程 china-domain-allowlist.txt 文件失败, error:', error, ', response:', response, ', body:', body) + return + } + if (response && response.statusCode === 200) { + if (body == null || body.length < 100) { + log.warn('下载远程 china-domain-allowlist.txt 文件成功,但内容为空或内容太短,判断为无效的 china-domain-allowlist.txt 文件:', remoteFileUrl, ', body:', body) + return + } else { + log.info('下载远程 china-domain-allowlist.txt 文件成功:', remoteFileUrl) + } + + let fileTxt = body + try { + if (fileTxt.indexOf('*.') < 0) { + fileTxt = Buffer.from(fileTxt, 'base64').toString('utf8') + // log.debug('解析 base64 后的 china-domain-allowlist:', fileTxt) + } + } catch (e) { + if (fileTxt.indexOf('*.') < 0) { + log.error(`远程 china-domain-allowlist.txt 文件内容即不是base64格式,也不是要求的格式,url: ${remoteFileUrl},body: ${body}`) + return + } + } + + // 保存到本地 + saveChinaDomainAllowListFile(fileTxt) + } else { + log.error('下载远程 china-domain-allowlist.txt 文件失败, response:', response, ', body:', body) + } + }) +} + +function loadLastModifiedTimeFromTxt (fileTxt) { + const matched = fileTxt.match(/(?<=; Update Date: )[^\r\n]+/g) + if (matched && matched.length > 0) { + try { + return new Date(matched[0]) + } catch (ignore) { + return null + } + } +} + +// 保存 中国域名白名单 内容到 `~/china-domain-allowlist.txt.txt` 文件中 +function saveChinaDomainAllowListFile (fileTxt) { + const filePath = getChinaDomainAllowListTmpFilePath() + fs.writeFileSync(filePath, fileTxt.replaceAll(/\r\n?/g, '\n')) + log.info('保存 china-domain-allowlist.txt 文件成功:', filePath) + + // 尝试解析和修改 china-domain-allowlist.txt 文件时间 + const lastModifiedTime = loadLastModifiedTimeFromTxt(fileTxt) + if (lastModifiedTime) { + fs.stat(filePath, (err, stats) => { + if (err) { + log.error('修改 china-domain-allowlist.txt 文件时间失败:', err) + return + } + + // 修改文件的访问时间和修改时间为当前时间 + fs.utimes(filePath, lastModifiedTime, lastModifiedTime, (utimesErr) => { + if (utimesErr) { + log.error('修改 china-domain-allowlist.txt 文件时间失败:', utimesErr) + } else { + log.info(`'${filePath}' 文件的修改时间已更新为其最近更新时间 '${formatDate(lastModifiedTime)}'`) + } + }) + }) + } + + return filePath +} + +function formatDate (date) { + const year = date.getFullYear() + const month = (date.getMonth() + 1).toString().padStart(2, '0') + const day = date.getDate().toString().padStart(2, '0') + const hours = date.getHours().toString().padStart(2, '0') + const minutes = date.getMinutes().toString().padStart(2, '0') + const seconds = date.getSeconds().toString().padStart(2, '0') + return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}` +} + +function getChinaDomainAllowList () { + loadConfig() + + if (!config.get().proxy.excludeChinaDomainAllowList) { + return null + } + + // 判断是否需要自动更新中国域名 + let fileAbsolutePath = config.get().proxy.chinaDomainAllowListFileAbsolutePath + if (!fileAbsolutePath && config.get().proxy.autoUpdateChinaDomainAllowList) { + // 异步下载,下载成功后,下次系统代理生效 + downloadChinaDomainAllowListAsync().then() + } + + // 加载本地文件 + if (!fileAbsolutePath) { + const tmpFilePath = getChinaDomainAllowListTmpFilePath() + if (fs.existsSync(tmpFilePath)) { + // 如果临时文件已存在,则使用临时文件 + fileAbsolutePath = tmpFilePath + log.info('读取已下载的 china-domain-allowlist.txt 文件:', fileAbsolutePath) + } else { + // 如果临时文件不存在,则使用内置文件 + fileAbsolutePath = path.join(__dirname, '../../gui/', config.get().proxy.chinaDomainAllowListFilePath) + log.info('读取内置的 china-domain-allowlist.txt 文件:', fileAbsolutePath) + } + } else { + log.info('读取自定义路径的 china-domain-allowlist.txt 文件:', fileAbsolutePath) + } + + try { + return fs.readFileSync(fileAbsolutePath).toString() + } catch (e) { + log.error('读取 china-domain-allowlist.txt 文件失败:', fileAbsolutePath) + return null + } +} + async function _winSetProxy (exec, ip, port, setEnv) { // 延迟加载config loadConfig() @@ -58,6 +192,24 @@ async function _winSetProxy (exec, ip, port, setEnv) { } } + // 排除中国域名 + if (config.get().proxy.excludeChinaDomainAllowList) { + try { + let chinaDomainAllowList = getChinaDomainAllowList() + if (chinaDomainAllowList) { + chinaDomainAllowList = (chinaDomainAllowList + '\n').replaceAll(/[\r\n]+/g, '\n').replaceAll(/[^\n]*[^*.a-zA-Z\d-\n]+[^\n]*\r?\n/g, '').replaceAll(/\s*\n+\s*/g, ';') + if (chinaDomainAllowList) { + excludeIpStr += chinaDomainAllowList + log.info('系统代理排除列表拼接中国域名') + } else { + log.info('中国域名为空,不进行系统代理排除列表拼接中国域名') + } + } + } catch (e) { + log.error('系统代理排除列表拼接中国域名失败:', e) + } + } + const proxyPath = extraPath.getProxyExePath() const execFun = 'global' diff --git a/packages/gui/extra/proxy/china-domain-allowlist.txt b/packages/gui/extra/proxy/china-domain-allowlist.txt new file mode 100644 index 0000000..2669990 --- /dev/null +++ b/packages/gui/extra/proxy/china-domain-allowlist.txt @@ -0,0 +1,1202 @@ +[SwitchyOmega Conditions] +; Require: SwitchyOmega >= 2.3.2 +; Update Date: 2024/09/26 +; Author: Pluwen +; Usage: https://github.com/FelisCatus/SwitchyOmega/wiki/RuleListUsage + +; IP 地址段 +10.*.*.* +100.64.*.* +127.*.*.* +172.16.*.* +192.168.*.* + +; cn 域名都不走代理 +*.cn + +; 其他域名 +*.00cdn.com +*.0daydown.com +*.0o0.ooo +*.10010.com +*.114la.com +*.114yygh.com +*.115.com +*.123pan.com +*.126.com +*.126.net +*.127.net +*.139.com +*.163.com +*.163yun.com +*.1688.com +*.17173.com +*.178.com +*.17ce.com +*.17font.com +*.17k.com +*.199it.com +*.1ptba.com +*.1qimg.com +*.1qmsg.com +*.1tpic.com +*.1year.cc +*.1years.cc +*.21cn.com +*.21tb.com +*.2345.com +*.2cto.com +*.3322.cc +*.3366.com +*.33ss.tech +*.360.com +*.360buy.com +*.360buyimg.com +*.360doc.com +*.360in.com +*.36kr.com +*.39.net +*.3dmgame.com +*.4399.com +*.51.la +*.51.net +*.5173.com +*.5173cdn.com +*.51cto.com +*.51job.com +*.51ym.me +*.52audio.com +*.52yuwan.com +*.56.com +*.58.com +*.58pic.com +*.591mogu.com +*.616pic.com +*.699pic.com +*.71.am +*.7k7k.com +*.8686c.com +*.86ps.com +*.91.com +*.91118.com +*.91mjw.com +*.99.com +*.a9vg.com +*.aaplimg.com +*.abchina.com +*.accuweather.com +*.acfun.tv +*.acg.rip +*.acg.tv +*.acggate.net +*.acgvideo.com +*.acs.org +*.aday01.com +*.adf.ly +*.agora.io +*.aicdn.com +*.aicheren.com +*.aicoinstorge.com +*.aipai.com +*.air-matters.com +*.air-matters.io +*.airbnb.com +*.aiwebcom.com +*.aixifan.com +*.aizhan.com +*.akadns.net +*.akamaihd.net +*.akamaized.net +*.akarin.me +*.akarin.top +*.aldwx.com +*.aliapp.org +*.alibaba-inc.com +*.alibaba.com +*.alibabacloud.com +*.alibabausercontent.com +*.alicdn.com +*.alicloudccp.com +*.alikunlun.com +*.alikunlun.net +*.alimama.com +*.alipan.com +*.alipay.com +*.alipayobjects.com +*.alisports.com +*.aliued.com +*.aliyun.com +*.aliyuncs.com +*.aliyundrive.com +*.aliyunpds.com +*.allhistory.com +*.alltuu.com +*.amap.com +*.amd.com +*.ancda.com +*.animebytes.tv +*.anjuke.com +*.anquan.org +*.ant.design +*.antfin-inc.com +*.antfin.com +*.anw.red +*.anyway.fm +*.anzhi.com +*.appclub.in +*.appgame.com +*.appinn.com +*.appinn.net +*.apple-cloudkit.com +*.apple.co +*.apple.com +*.appletuan.com +*.appstore.com +*.aps.org +*.archlinux.org +*.archlinuxcn.org +*.areyoucereal.com +*.arubanetworks.com +*.atomicstryker.net +*.augix.me +*.autonavi.com +*.awesome-hd.me +*.axhub.im +*.axshare.com +*.axure.org +*.axureux.com +*.b612.net +*.babybus.com +*.baidu.com +*.baidubcr.com +*.baiducontent.com +*.baidupan.com +*.baidupcs.com +*.baidustatic.com +*.baiduwp.com +*.baiduyundns.com +*.baiduyundns.net +*.baimiaoapp.com +*.bankcomm.com +*.baomihua.com +*.baomitu.com +*.baozoumanhua.com +*.battle.net +*.bbtree.com +*.bcebos.com +*.bcedns.com +*.bcedns.net +*.bcy.net +*.bdatu.com +*.bdimg.com +*.bdstatic.com +*.bdydns.com +*.bdydns.net +*.behe.com +*.beianbeian.com +*.beisen.com +*.beitaichufang.com +*.bejson.com +*.bendibao.com +*.bible.com +*.biliapi.com +*.biliapi.net +*.bilibili.com +*.bilibili.tv +*.biligame.com +*.biligame.net +*.bilivideo.com +*.bitbucket.org +*.blackyau.cc +*.blizzard.com +*.blogchina.com +*.blogjava.net +*.bluedoc.io +*.booking.com +*.bootcss.com +*.bqtalk.com +*.broadcasthe.net +*.bstatic.com +*.bt0.com +*.btdx8.com +*.btsync.org +*.btyingshi.com +*.bumimi.com +*.bybbs.org +*.bytecdntp.com +*.ca001.com +*.cachemoment.com +*.cailianpress.com +*.caiyunapp.com +*.camera360.com +*.ccb.com +*.ccgslb.com +*.ccgslb.net +*.cctv.com +*.cctvpic.com +*.cdn-apple.com +*.cdn.hockeyapp.net +*.cdn.jsdelivr.net +*.cdnbee.com +*.cdndm.com +*.cdndm5.com +*.cdnjs.com +*.cdnst.net +*.cdntip.com +*.cdog.me +*.ceair.com +*.cebbank.com +*.cee.network +*.chainnews.com +*.chaoxing.com +*.chdbits.co +*.china.com +*.chinanetcenter.com +*.chinaso.com +*.chinassl.net +*.chinaunix.net +*.chinauos.com +*.chinaz.com +*.chiphell.com +*.chongdiantou.com +*.chuangzaoshi.com +*.chuimg.com +*.chunyu.mobi +*.chunyuanfood.com +*.ciligod.com +*.citicbank.com +*.classix-unlimited.co.uk +*.cli.im +*.clouddn.com +*.cloudinary.com +*.cloudxns.net +*.cmbchina.com +*.cmbimg.com +*.cn-ki.net +*.cn.engadget.com +*.cnbeta.com +*.cnbetacdn.com +*.cnblogs.com +*.cnki.net +*.cnsageo.com +*.cnzz.com +*.cnzz.net +*.code4app.com +*.coding.io +*.coding.me +*.coding.net +*.coloros.com +*.comicat.org +*.coolapk.com +*.coolpad.com +*.cootekservice.com +*.cowtransfer.com +*.csair.com +*.csdn.net +*.css-js.com +*.css.net +*.css.network +*.ct10000.com +*.ctrip.com +*.cupfox.app +*.d7vg.com +*.damengxiang.me +*.dandanplay.com +*.dangdang.com +*.daocloud.io +*.datagrand.com +*.dbankcdn.com +*.ddos.cc +*.ddrk.me +*.deepin.com +*.deepin.org +*.deepinos.org +*.deliwenku.com +*.dfcfw.com +*.dgtle.com +*.dianping.com +*.didialift.com +*.didiglobal.com +*.dilidili.com +*.dilidili.wang +*.dingtalk.com +*.dingtalkapps.com +*.diybeta.com +*.diyvm.com +*.dji.com +*.dji.net +*.dm5.com +*.dmzj.com +*.dns.com +*.dnspao.com +*.docer.com +*.docin.com +*.docschina.org +*.dopa.com +*.douban.* +*.douban.com +*.douban.fm +*.doubanio.com +*.doubleclick.net +*.douyin.com +*.douyu.com +*.douyutv.com +*.doyoo.net +*.doyoudo.com +*.dpfile.com +*.draw.io +*.drivergenius.com +*.dsxys.com +*.duanwenxue.com +*.duguletian.com +*.duokan.com +*.duoshao.app +*.duoshao.net +*.duoshuo.com +*.duowan.com +*.dwstatic.com +*.dxycdn.com +*.dygod.net +*.dytt8.net +*.easou.com +*.eastmoney.com +*.ecitic.com +*.edifier.com +*.eebbk.com +*.eeboard.com +*.eggjs.org +*.ele.me +*.elemecdn.com +*.elong.com +*.elsevier.com +*.empornium.me +*.enkj.com +*.epicgames.com +*.epubw.com +*.erp321.com +*.etao.com +*.eudic.net +*.ewei.com +*.fang.com +*.fatetypo.xyz +*.feiliao.com +*.feishucdn.com +*.feng.com +*.fengkongcloud.com +*.fengniao.com +*.ffalcon.com +*.figma.cool +*.figmachina.com +*.figmacn.com +*.fiio.com +*.fir.im +*.firefox.com +*.fjgdwl.com +*.fjhxbank.com +*.fliggy.com +*.flomoapp.com +*.flow.ci +*.flyertea.com +*.fnnas.com +*.fontke.com +*.foundertype.com +*.foxirj.com +*.frdic.com +*.freebuf.com +*.freeziti.com +*.futu5.com +*.futunn.com +*.fydeos.com +*.fzzfgjj.com +*.g-cores.com +*.galstars.net +*.gamersky.com +*.gandi.net +*.ganji.com +*.gank.io +*.gazellegames.net +*.gcores.com +*.geetest.com +*.geilicdn.com +*.getfedora.org +*.getpricetag.com +*.getui.com +*.gfan.com +*.gifshow.com +*.gitee.com +*.gitee.io +*.godic.net +*.golaravel.com +*.goofish.com +*.googletagmanager.com +*.gratisography.com +*.growingio.com +*.gtimg.com +*.guazi.com +*.guokr.com +*.gwdang.com +*.h-ui.net +*.h2os.com +*.hacpai.com +*.haitum.com +*.halyul.cc +*.hao123.com +*.haosou.com +*.happyeo.com +*.harmonyos.com +*.hasee.com +*.hdb.com +*.hdbits.org +*.hdchina.org +*.hddolby.com +*.hdfans.org +*.hdhome.org +*.hdsky.me +*.hdslb.com +*.hdslb.net +*.hejie.me +*.heweather.com +*.hexun.com +*.hexunimg.com +*.hicloud.com +*.hihonor.com +*.hikvision.com +*.hitv.com +*.hiwifi.com +*.homestyler.com +*.hommk.com +*.hongxiu.com +*.hostbuf.com +*.hostker.com +*.hotmail.com +*.houxu.app +*.huaban.com +*.huabanimg.com +*.huanmusic.com +*.huanqiu.com +*.huawei.com +*.huaweicloud.com +*.huiji.wiki +*.huijistatic.com +*.huijiwiki.com +*.hujiang.com +*.huomao.com +*.hupu.com +*.huxiu.com +*.huxiucdn.com +*.huya.com +*.hxcdn.net +*.hxjyb.com +*.hy233.tv +*.i-meto.com +*.iapps.im +*.iaweg.com +*.iaxure.com +*.ibm.com +*.ibruce.info +*.ibucm.com +*.icetorrent.org +*.iciba.com +*.icloud-content.com +*.icloud.com +*.idqqimg.com +*.ieee.org +*.iesdouyin.com +*.ifanr.com +*.ifanr.in +*.ifdream.net +*.ifeng.com +*.ifengimg.com +*.ifigma.design +*.igamecj.com +*.iguoguo.net +*.iguxuan.com +*.iina.io +*.ijinshan.com +*.iknoworld.net +*.iknowwhatyoudownload.com +*.im9.com +*.imiku.me +*.imooc.com +*.imququ.com +*.indienova.com +*.infinitynewtab.com +*.infoq.com +*.installbi.me +*.intercomcdn.com +*.ip-api.com +*.ip-cdn.com +*.ip.la +*.ip.sb +*.ipip.net +*.iplaysoft.com +*.ipv6-test.com +*.iqihang.com +*.iqing.in +*.iqiyi.com +*.iqiyipic.com +*.irs01.com +*.isharepc.com +*.it168.com +*.iteye.com +*.ithome.com +*.itjuzi.com +*.jandan.net +*.java.com +*.javaeye.com +*.jb51.net +*.jcodecraeer.com +*.jd.com +*.jd.hk +*.jdkindle.com +*.jdpay.com +*.jetbrains.com +*.jfrft.com +*.jhdec.com +*.jianguoyun.com +*.jianshu.* +*.jianshu.com +*.jianshu.io +*.jianshuapi.com +*.jiathis.com +*.jidian.im +*.jiemian.com +*.jikexueyuan.com +*.jikipedia.com +*.jinshuju.net +*.jisuanke.com +*.jomodns.com +*.joyneop.xyz +*.joyyang.com +*.jpopsuki.eu +*.jqhtml.com +*.js.design +*.jsdelivr.com +*.jsdelivr.net +*.juejin.im +*.juji.tv +*.kaiyanapp.com +*.kan300.com +*.kankan.com +*.kanzhun.com +*.kaspersky-labs.com +*.kcdnvip.com +*.ke.com +*.keepcdn.com +*.keepfrds.com +*.kekenet.com +*.kele5240.com +*.kf5.com +*.kingsoft.com +*.kkmh.com +*.kmf.com +*.knewone.com +*.knownsec.com +*.ksosoft.com +*.ksyun.com +*.ksyungslb.com +*.ku6.com +*.kuaidi100.com +*.kuaishou.com +*.kuaizhan.com +*.kugou.com +*.kujiale.com +*.kunlunaq.com +*.kunlunar.com +*.kunlunca.com +*.kunluncan.com +*.kunlunea.com +*.kunlungem.com +*.kunlungr.com +*.kunlunhuf.com +*.kunlunle.com +*.kunlunli.com +*.kunlunno.com +*.kunlunpi.com +*.kunlunra.com +*.kunlunsa.com +*.kunlunsc.com +*.kunlunsl.com +*.kunlunso.com +*.kunlunta.com +*.kunlunvi.com +*.kunlunwe.com +*.kyoceraconnect.com +*.lackar.com +*.lagou.com +*.lanhuapp.com +*.lanjinger.com +*.lany.me +*.lanyus.com +*.lanzous.com +*.lanzoux.com +*.laravel-china.org +*.layui.com +*.lbesec.com +*.le.com +*.lecloud.com +*.leetcode-cn.com +*.lemicp.com +*.lenovomobile.com +*.letv.com +*.letvimg.com +*.lianjia.com +*.liantu.com +*.liaoxuefeng.com +*.licdn.com +*.liepin.com +*.lifan.ooo +*.likefont.com +*.lilithgames.com +*.linuxidc.com +*.livechina.com +*.liyin.date +*.lizhi.fm +*.lizhi.io +*.lkkdesign.com +*.lncld.net +*.locoy.com +*.locvps.com +*.lofter.com +*.loj.ac +*.loli.net +*.lolinet.com +*.longzhu.com +*.lucifr.com +*.ludashi.com +*.luogu.org +*.luojilab.com +*.luoo.net +*.lvmama.com +*.lwl12.com +*.ly.com +*.lyjsws.com +*.m-team.cc +*.macpaw.com +*.macrr.com +*.macw.com +*.macwk.com +*.madsrevolution.net +*.magi.com +*.mail4geek.com +*.manmanbuy.com +*.maoyan.com +*.maoyun.tv +*.masadora.net +*.mastergo.com +*.maxfox.me +*.mcbbs.net +*.mdnice.com +*.mdui.org +*.me.com +*.mediav.com +*.megvii.com +*.meican.com +*.meiin.com +*.meijutw.com +*.meipai.com +*.meiqia.com +*.meitu.com +*.meituan.com +*.meituan.net +*.meitudata.com +*.meitustat.com +*.meixincdn.com +*.meizu.com +*.mengniang.org +*.mgtv.com +*.mi-img.com +*.mi.com +*.miaopai.com +*.microbit.org +*.midifan.com +*.mikanani.me +*.minapp.com +*.mindstore.io +*.mingdao.com +*.miui.com +*.miwifi.com +*.mls-cdn.com +*.mmstat.com +*.mmtrix.com +*.mob.com +*.mobike.com +*.moe.im +*.moe123.net +*.moegirl.org +*.moetransit.com +*.mojidoc.com +*.moke.com +*.mokeedev.com +*.momentcdn.com +*.momoyu.cc +*.moonvy.com +*.morethan.tv +*.mozilla.org +*.mp4ba.cc +*.msftconnecttest.com +*.mtyun.com +*.mu6.me +*.mubu.com +*.muchong.com +*.mukewang.com +*.mumayi.com +*.muscache.com +*.mxhichina.com +*.myanonamouse.net +*.myapp.com +*.mydrivers.com +*.myip.la +*.myqcloud.com +*.myzaker.com +*.mzstatic.com +*.naixue.com +*.nanyangpt.com +*.nature.com +*.ncore.cc +*.nekonazo.com +*.netease.com +*.netease.im +*.netseer.com +*.netspeedtestmaster.com +*.newsmth.net +*.ngacn.cc +*.nim-lang-cn.org +*.nipic.com +*.nlark.com +*.nobook.com +*.nocode.com +*.now.sh +*.nowcoder.com +*.nowcoder.net +*.ntp.org +*.nuomi.com +*.nvidia.com +*.nyato.com +*.obsapp.com +*.oekaki.so +*.office.net +*.office365.com +*.okii.com +*.omico.me +*.onekbit.com +*.oneplus.com +*.oneplusbbs.com +*.onlinedown.net +*.open-open.com +*.open.cd +*.oppo.com +*.ops.moe +*.oracle.com +*.oray.com +*.oray.net +*.orayimg.com +*.oschina.io +*.oschina.net +*.ourbits.club +*.ourdvs.com +*.ourdvsss.com +*.oursketch.com +*.outlook.com +*.pag.art +*.paipai.com +*.panda.tv +*.panduoduo.net +*.passthepopcorn.me +*.pc6.com +*.pcbeta.com +*.pdcicons.ml +*.pdim.gs +*.pengyou.com +*.pexels.com +*.pgyer.com +*.phonegap100.com +*.phpcomposer.com +*.piaoquantv.com +*.pingan.com +*.pingwest.com +*.planetmeican.com +*.plex.tv +*.polyfill.io +*.pomotodo.com +*.ppgame.com +*.pplink.link +*.ppsimg.com +*.pptv.com +*.privatehd.to +*.processon.com +*.psbc.com +*.psnine.com +*.pstatp.com +*.pterclub.com +*.pythonclub.org +*.qbox.me +*.qcloud.com +*.qcloudcdn.com +*.qcwgg.com +*.qdaily.com +*.qdan.me +*.qdmm.com +*.qeeyou.com +*.qhimg.com +*.qhmsg.com +*.qhres.com +*.qichacha.com +*.qidian.com +*.qihucdn.com +*.qimiaomh.com +*.qingmang.me +*.qingting.fm +*.qiniu.com +*.qiniucdn.com +*.qiniudn.com +*.qiniudns.com +*.qiniup.com +*.qiniuts.com +*.qiuziti.com +*.qiyi.com +*.qiyipic.com +*.qiyukf.com +*.qnssl.com +*.qq.com +*.qqmail.com +*.qqurl.com +*.qqzzz.net +*.quanmingjiexi.com +*.qudong.com +*.qunar.com +*.qweather.com +*.qyer.com +*.qyerstatic.com +*.rapoo.com +*.rarbg.to +*.raychase.net +*.realme.com +*.redacted.ch +*.renren.com +*.renrenche.com +*.researchgate.net +*.rework.tools +*.rkecloud.com +*.rkidc.net +*.rlcdn.com +*.rom.mk +*.ronghub.com +*.rr.tv +*.rrfmn.com +*.rrimg.com +*.rsc.org +*.ruanmei.com +*.ruanyifeng.com +*.ruby-china.org +*.ruguoapp.com +*.runoob.com +*.s-reader.com +*.sandai.net +*.sankuai.com +*.sarm.net +*.sb.sb +*.sc115.com +*.sciencedirect.com +*.sciencemag.org +*.scomper.me +*.sdbeta.com +*.sdo.com +*.seafile.com +*.seele.tech +*.segmentfault.com +*.sekorm.com +*.servicewechat.com +*.sf-express.com +*.shejijia.com +*.shidianguji.com +*.shikezhi.com +*.shimo.im +*.shiyanlou.com +*.shssp.org +*.shxibank.com +*.shyywz.com +*.sigmaaldrich.com +*.sigujiexi.com +*.sina.com +*.sinaapp.com +*.since1989.org +*.siweiearth.com +*.sketchchina.com +*.slack.com +*.sm.ms +*.smart2pay.com +*.smartgslb.com +*.smartisan.com +*.smzdm.com +*.snapdrop.net +*.snssdk.com +*.snwx.com +*.so.com +*.sobot.com +*.sogo.com +*.sogou.com +*.sogoucdn.com +*.sohu-inc.com +*.sohu.com +*.sohucs.com +*.soku.com +*.solidot.org +*.songshuhui.net +*.soso.com +*.soufun.com +*.sourcegcdn.com +*.speedtest.net +*.springer.com +*.springerlink.com +*.springleaf-biomax.com +*.springsunday.net +*.sspai.com +*.stargame.com +*.staticdn.net +*.staticfile.org +*.steamcn.com +*.steamcontent.com +*.steamdb.info +*.steamstatic.com +*.subhd.tv +*.sui.com +*.suning.com +*.surface.wiki +*.sznews.com +*.t.tt +*.taichi.graphics +*.taihe.com +*.takungpao.com +*.talkingdata.com +*.tangdou.com +*.tangdouddn.com +*.tanx.com +*.taobao.com +*.taobao.org +*.taobaocdn.com +*.tapdb.net +*.tapimg.com +*.taptap.com +*.tbcache.com +*.tcdn.qq.com +*.tcl.com +*.teambition.com +*.teamviewer.com +*.tencent-cloud.com +*.tencent-cloud.net +*.tencent.com +*.tencentmind.com +*.tengshiauto.com +*.tenpay.com +*.tenxcloud.com +*.test-ipv6.com +*.tgbus.com +*.thefuture.top +*.thomsonreuters.com +*.tianyancha.com +*.tietuku.com +*.tigerlust.com +*.tingyun.com +*.tinyservices.net +*.tinywow.com +*.tjupt.org +*.tmall.com +*.tmall.hk +*.todesk.com +*.tool.lu +*.tophub.today +*.totheglory.im +*.toushibao.com +*.toutiao.com +*.toutiao.io +*.toutiaoimg.com +*.tower.im +*.trontv.com +*.truevue.org +*.ttt.tt +*.tuchong.com +*.tudou.com +*.tuicool.com +*.tuna.moe +*.tuniu.com +*.typeisbeautiful.com +*.u9u9.com +*.ubuntukylin.com +*.ucweb.com +*.ucxinwen.com +*.udache.com +*.udacity.com +*.uedna.com +*.uigreat.com +*.uisdc.com +*.uisheji.com +*.umeng.com +*.umengcloud.com +*.umetrip.com +*.undraw.co +*.uning.com +*.upai.com +*.upaiyun.com +*.upyun.com +*.ustclug.org +*.uuu.moe +*.uxengine.net +*.v-56.com +*.vamaker.com +*.vaptcha.net +*.veryzhun.com +*.vhall.com +*.vhallyun.com +*.videojj.com +*.viosey.com +*.vip.com +*.visualhunt.com +*.visualstudio.com +*.vite.org +*.vjudge.net +*.vmall.com +*.vmware.com +*.voidcn.com +*.vostic.net +*.vpgame.com +*.vpgcdn.com +*.vpsmm.com +*.vss.im +*.vzan.com +*.wacai.com +*.waerfa.com +*.walklake.com +*.wallhaven.cc +*.wandoujia.com +*.wangsu.com +*.wanmei.com +*.weather.com +*.web.guoweishu.net +*.webfont.com +*.webofknowledge.com +*.wechat.com +*.weibo.com +*.weibocdn.com +*.weico.cc +*.weidian.com +*.weidown.com +*.weidunewtab.com +*.weiosx.com +*.weixinbridge.com +*.weiyun.com +*.westlakemuseum.com +*.whatismyip.com +*.wht.im +*.wiley.com +*.windows.com +*.windowsupdate.com +*.wisenjoy.com +*.wjx.top +*.wodemo.com +*.wolai.com +*.woozooo.com +*.woshipm.com +*.woyoo.com +*.wps.com +*.wscdns.com +*.wulihub.com +*.wxb.com +*.xbongbong.com +*.xclient.info +*.xdccpro.com +*.xf9168.com +*.xiachufang.com +*.xiami.com +*.xiami.net +*.xiaoe-tech.com +*.xiaoe-tools.com +*.xiaohongshu.com +*.xiaoka.tv +*.xiaomark.com +*.xiaomi.com +*.xiaomi.net +*.xiaomicp.com +*.xiaomiyoupin.com +*.xiaotu.io +*.xiazaiziti.com +*.ximalaya.com +*.xinhuanet.com +*.xiniu.com +*.xinquji.com +*.xitu.io +*.xiya.vip +*.xldns.net +*.xmac.app +*.xmcdn.com +*.xnpic.com +*.xpcha.com +*.xuanfengge.com +*.xueqiu.com +*.xuetangx.com +*.xujc.com +*.xunlei.com +*.xunyou.com +*.xx1t.com +*.xxsy.net +*.xycdn.com +*.xywy.com +*.yamibo.com +*.yangkeduo.com +*.yangwangauto.com +*.yaohuo.me +*.yd-jxt.com +*.ydstatic.com +*.yecdn.com +*.yesky.com +*.yeyfree.com +*.yfscdn.net +*.yfsvdn.net +*.yhd.com +*.yi2.net +*.yiche.com +*.yihaodianimg.com +*.yinxiang.com +*.yinyuetai.com +*.yizhibo.com +*.ykimg.com +*.ylmf.net +*.youdao.com +*.youku.com +*.youlebe.com +*.youzan.com +*.yunjiasu-cdn.net +*.yunpian.com +*.yunshipei.com +*.yuque.com +*.yuwantech.com +*.yxt.com +*.yy.com +*.z-bank.com +*.zaih.com +*.zanata.org +*.zanmeishi.com +*.zdic.net +*.zealer.com +*.zh.moegirl.org +*.zhan.com +*.zhangxinxu.com +*.zhangyao.name +*.zhangzishi.cc +*.zhanqi.tv +*.zhaopin.com +*.zhihu.com +*.zhihuishu.com +*.zhimap.com +*.zhimg.com +*.zhipin.com +*.zhiye.com +*.zhiziyun.com +*.zhongguose.com +*.zhuihd.com +*.zhujike.com +*.zijieapi.com +*.zimuzu.tv +*.zku.net +*.znyj365.com +*.zto.com diff --git a/packages/gui/src/view/pages/proxy.vue b/packages/gui/src/view/pages/proxy.vue index 0b423f3..38a3230 100644 --- a/packages/gui/src/view/pages/proxy.vue +++ b/packages/gui/src/view/pages/proxy.vue @@ -43,6 +43,23 @@ 去设置
解决OneNoteMicrosoftStoreOutlookUWP应用开启代理后无法访问网络的问题
+
+ + + 是否排除中国域名白名单 + + + + + 自动下载远程中国域名文件。未开启自动更新时,将使用内置中国域名文件 + + + + +
+ 远程中国域名白名单文件内容可以是base64编码格式,也可以是未经过编码的 +
+
diff --git a/packages/mitmproxy/src/lib/proxy/middleware/overwall.js b/packages/mitmproxy/src/lib/proxy/middleware/overwall.js index ac89efb..d69ac9b 100644 --- a/packages/mitmproxy/src/lib/proxy/middleware/overwall.js +++ b/packages/mitmproxy/src/lib/proxy/middleware/overwall.js @@ -38,7 +38,7 @@ function getTmpPacFilePath () { } function loadPacLastModifiedTime (pacTxt) { - const matched = pacTxt.match(/(?<=! Last Modified: )[^\n]+/g) + const matched = pacTxt.match(/(?<=! Last Modified: )[^\r\n]+/g) if (matched && matched.length > 0) { try { return new Date(matched[0]) @@ -107,9 +107,12 @@ async function downloadPacAsync (pacConfig) { // 尝试解析Base64(注:https://gitlab.com/gfwlist/gfwlist/raw/master/gfwlist.txt 下载下来的是Base64格式) let pacTxt = body try { - pacTxt = Buffer.from(pacTxt, 'base64').toString('utf8') + if (pacTxt.indexOf('!---------------------EOF') < 0) { + pacTxt = Buffer.from(pacTxt, 'base64').toString('utf8') + // log.debug('解析 base64 后的 pax:', pacTxt) + } } catch (e) { - if (pacTxt.indexOf('||') < 0) { // TODO: 待优化,需要判断下载的 pac.txt 文件内容是否正确,目前暂时先简单判断一下 + if (pacTxt.indexOf('!---------------------EOF') < 0) { log.error(`远程 pac.txt 文件内容即不是base64格式,也不是要求的格式,url: ${remotePacFileUrl},body: ${body}`) return } diff --git a/packages/mitmproxy/src/lib/proxy/middleware/source/pac.js b/packages/mitmproxy/src/lib/proxy/middleware/source/pac.js index 1a1ce3c..5c0e00c 100644 --- a/packages/mitmproxy/src/lib/proxy/middleware/source/pac.js +++ b/packages/mitmproxy/src/lib/proxy/middleware/source/pac.js @@ -19,7 +19,7 @@ function createPacClient (pacFilePath) { const getRules = function (pacFilePath) { let text = readFile(pacFilePath) - if (text.indexOf('!---------------------EOF') === -1) { + if (text.indexOf('!---------------------EOF') < 0) { text = Buffer.from(text, 'base64').toString() } const rules = []