From d1555d32383229c45b39c443d910526bc6756d9b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=92=80=E7=92=A8=E6=A2=A6=E6=98=9F?=
<157385609+cuicanmengxing@users.noreply.github.com>
Date: Mon, 8 Jul 2024 16:39:34 +0800
Subject: [PATCH] =?UTF-8?q?feature:=201=EF=BC=89=E5=A2=9E=E5=8A=A0=20`safe?=
=?UTF-8?q?360`=20DNS=EF=BC=8C=E5=B9=B6=E5=B0=86=20`usa`=20=E9=87=8D?=
=?UTF-8?q?=E5=91=BD=E5=90=8D=E4=B8=BA=20`cloudflare`=EF=BC=9B2=EF=BC=89?=
=?UTF-8?q?=E4=B8=BA=E9=83=A8=E5=88=86=E5=9F=9F=E5=90=8D=E9=A2=84=E8=AE=BE?=
=?UTF-8?q?IP=EF=BC=9B3=EF=BC=89PIP=E5=8A=A0=E9=80=9F=E4=B8=AD=EF=BC=8C?=
=?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=A4=E4=B8=AA=E9=95=9C=E5=83=8F=E3=80=82?=
=?UTF-8?q?=20(#312)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
packages/core/src/config/index.js | 9 ++++-
packages/gui/src/view/pages/plugin/pip.vue | 6 +++
packages/mitmproxy/src/lib/dns/https.js | 45 +++++++++++++++++++++-
3 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/packages/core/src/config/index.js b/packages/core/src/config/index.js
index 1a63b82..2a30654 100644
--- a/packages/core/src/config/index.js
+++ b/packages/core/src/config/index.js
@@ -281,7 +281,7 @@ module.exports = {
server: 'https://dns.alidns.com/dns-query',
cacheSize: 1000
},
- usa: {
+ cloudflare: {
type: 'https',
server: 'https://1.1.1.1/dns-query',
cacheSize: 1000
@@ -291,6 +291,11 @@ module.exports = {
server: 'https://9.9.9.9/dns-query',
cacheSize: 1000
},
+ safe360: {
+ type: 'https',
+ server: 'https://doh.360.cn/dns-query',
+ cacheSize: 1000
+ },
rubyfish: {
type: 'https',
server: 'https://rubyfish.cn/dns-query',
@@ -320,7 +325,7 @@ module.exports = {
enabled: true,
interval: 300000,
hostnameList: ['github.com'],
- dnsProviders: ['usa', 'quad9', 'rubyfish']
+ dnsProviders: ['safe360', 'cloudflare', 'rubyfish']
}
}
},
diff --git a/packages/gui/src/view/pages/plugin/pip.vue b/packages/gui/src/view/pages/plugin/pip.vue
index ccf6cdc..294d58f 100644
--- a/packages/gui/src/view/pages/plugin/pip.vue
+++ b/packages/gui/src/view/pages/plugin/pip.vue
@@ -32,6 +32,12 @@
aliyun镜像
+
+ 北京外国语大学镜像
+
+
+ 南京大学镜像
+
设置后立即生效,即使关闭ds也会继续保持
diff --git a/packages/mitmproxy/src/lib/dns/https.js b/packages/mitmproxy/src/lib/dns/https.js
index 0abe080..4168f4c 100644
--- a/packages/mitmproxy/src/lib/dns/https.js
+++ b/packages/mitmproxy/src/lib/dns/https.js
@@ -11,6 +11,49 @@ module.exports = class DNSOverHTTPS extends BaseDNS {
}
async _lookup (hostname) {
+ // 直接判断域名是否为example.com
+ if (hostname === 'github.com') {
+ log.info('域名github.com使用内置IP集')
+ // 返回预设的IP地址集
+ return ['140.82.114.4', '20.87.245.0', '20.27.177.113', '20.205.243.166', '20.248.137.48', '140.82.121.3', '140.82.116.4', '20.200.245.247', '20.26.156.215', '140.82.113.3', '140.82.121.4', '20.201.28.151']
+ }
+ // 直接判断域名是否为example.com
+ if (hostname === 'api.github.com') {
+ log.info('域名api.github.com使用内置IP集')
+ // 返回预设的IP地址集
+ return ['20.87.245.6', '140.82.112.5', '140.82.116.6', '20.26.156.210', '20.200.245.245', '20.27.177.116', '20.248.137.49', '20.201.28.148', '140.82.113.6', '20.205.243.168', '140.82.121.6']
+ }
+ if (hostname === 'codeload.github.com') {
+ log.info('域名codeload.github.com使用内置IP集')
+ // 返回预设的IP地址集
+ return ['20.27.177.114', '140.82.116.10', '140.82.114.10', '20.26.156.216', '20.87.245.7', '20.200.245.246', '20.248.137.55', '20.205.243.165', '20.201.28.149', '140.82.121.9', '140.82.113.9']
+ }
+ if (hostname.match(/.*\.githubusercontent\.com$/)) {
+ log.info('域名githubusercontent及其子域使用内置IP集')
+ // 返回预设的IP地址集
+ return ['185.199.111.133', '185.199.108.133', '185.199.109.133', '185.199.110.133']
+ }
+ if (hostname === 'github.githubassets.com') {
+ log.info('域名github.githubassets.com使用内置IP集')
+ // 返回预设的IP地址集
+ return ['185.199.110.154', '185.199.111.154', '185.199.109.154', '185.199.108.154']
+ }
+ if (hostname === 'collector.github.com') {
+ log.info('域名collector.github.com已根据AdGuard DNS filter规则拦截')
+ // 返回预设的IP地址集
+ return ['0.0.0.0']
+ }
+ if (hostname === 'github.io') {
+ log.info('域名github.io使用内置IP集')
+ // 返回预设的IP地址集
+ return ['185.199.108.153', '185.199.109.153', '185.199.111.153', '185.199.110.153']
+ }
+ if (hostname === 'hub.docker.com') {
+ log.info('域名hub.docker.com使用内置IP集')
+ // 返回预设的IP地址集
+ return ['54.156.140.159', '52.44.227.212', '44.221.37.199']
+ }
+
try {
const result = await dohQueryAsync({ url: this.dnsServer }, [{ type: 'A', name: hostname }])
if (result.answers.length === 0) {
@@ -18,7 +61,7 @@ module.exports = class DNSOverHTTPS extends BaseDNS {
log.info('该域名没有ip地址解析:', hostname)
return []
}
- const ret = result.answers.filter(item => { return item.type === 'A' }).map(item => { return item.data })
+ const ret = result.answers.filter(item => item.type === 'A').map(item => item.data)
if (ret.length === 0) {
log.info('该域名没有IPv4地址解析:', hostname)
} else {