Browse Source

feature: 1)增加 `safe360` DNS,并将 `usa` 重命名为 `cloudflare`;2)为部分域名预设IP;3)PIP加速中,新增两个镜像。 (#312)

pull/321/head
璀璨梦星 5 months ago committed by GitHub
parent
commit
d1555d3238
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 9
      packages/core/src/config/index.js
  2. 6
      packages/gui/src/view/pages/plugin/pip.vue
  3. 45
      packages/mitmproxy/src/lib/dns/https.js

9
packages/core/src/config/index.js

@ -281,7 +281,7 @@ module.exports = {
server: 'https://dns.alidns.com/dns-query', server: 'https://dns.alidns.com/dns-query',
cacheSize: 1000 cacheSize: 1000
}, },
usa: { cloudflare: {
type: 'https', type: 'https',
server: 'https://1.1.1.1/dns-query', server: 'https://1.1.1.1/dns-query',
cacheSize: 1000 cacheSize: 1000
@ -291,6 +291,11 @@ module.exports = {
server: 'https://9.9.9.9/dns-query', server: 'https://9.9.9.9/dns-query',
cacheSize: 1000 cacheSize: 1000
}, },
safe360: {
type: 'https',
server: 'https://doh.360.cn/dns-query',
cacheSize: 1000
},
rubyfish: { rubyfish: {
type: 'https', type: 'https',
server: 'https://rubyfish.cn/dns-query', server: 'https://rubyfish.cn/dns-query',
@ -320,7 +325,7 @@ module.exports = {
enabled: true, enabled: true,
interval: 300000, interval: 300000,
hostnameList: ['github.com'], hostnameList: ['github.com'],
dnsProviders: ['usa', 'quad9', 'rubyfish'] dnsProviders: ['safe360', 'cloudflare', 'rubyfish']
} }
} }
}, },

6
packages/gui/src/view/pages/plugin/pip.vue

@ -32,6 +32,12 @@
<a-radio-button value="https://mirrors.aliyun.com/pypi/simple/"> <a-radio-button value="https://mirrors.aliyun.com/pypi/simple/">
aliyun镜像 aliyun镜像
</a-radio-button> </a-radio-button>
<a-radio-button value="https://mirrors.bfsu.edu.cn/pypi/web/simple">
北京外国语大学镜像
</a-radio-button>
<a-radio-button value="https://mirror.nju.edu.cn/pypi/web/simple">
南京大学镜像
</a-radio-button>
</a-radio-group> </a-radio-group>
<div class="form-help">设置后立即生效即使关闭ds也会继续保持</div> <div class="form-help">设置后立即生效即使关闭ds也会继续保持</div>
</a-form-item> </a-form-item>

45
packages/mitmproxy/src/lib/dns/https.js

@ -11,6 +11,49 @@ module.exports = class DNSOverHTTPS extends BaseDNS {
} }
async _lookup (hostname) { 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 { try {
const result = await dohQueryAsync({ url: this.dnsServer }, [{ type: 'A', name: hostname }]) const result = await dohQueryAsync({ url: this.dnsServer }, [{ type: 'A', name: hostname }])
if (result.answers.length === 0) { if (result.answers.length === 0) {
@ -18,7 +61,7 @@ module.exports = class DNSOverHTTPS extends BaseDNS {
log.info('该域名没有ip地址解析:', hostname) log.info('该域名没有ip地址解析:', hostname)
return [] 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) { if (ret.length === 0) {
log.info('该域名没有IPv4地址解析:', hostname) log.info('该域名没有IPv4地址解析:', hostname)
} else { } else {

Loading…
Cancel
Save