refactor: shutdown 事件

pull/88/head
xiaojunnuo 2021-08-11 23:23:09 +08:00
parent 0a534bc89d
commit 473e2fea97
4 changed files with 31 additions and 18 deletions

View File

@ -74,8 +74,30 @@ module.exports = {
replace: '(.+)\\/raw\\/(.+)', replace: '(.+)\\/raw\\/(.+)',
proxy: 'raw.fastgit.org$1/$2' proxy: 'raw.fastgit.org$1/$2'
}, },
'raw.11githubusercontent.com': { 'raw.githubusercontent.com': {
'.*': { proxy: 'raw.fastgit.org' } '.*': {
proxy: 'raw.githubusercontent.com',
sni: 'baidu.com'
}
// '.*': { proxy: 'raw.fastgit.org' }
},
'user-images.githubusercontent.com': {
'.*': {
proxy: 'user-images.githubusercontent.com',
sni: 'baidu.com'
}
},
'github.githubassets.com': {
'.*': {
proxy: 'github.githubassets.com',
sni: 'baidu.com'
}
},
'avatars.githubusercontent.com': {
'.*': {
proxy: 'avatars.githubusercontent.com',
sni: 'baidu.com'
}
}, },
// 'github.githubassets.com': { // 'github.githubassets.com': {
// '.*': { // '.*': {
@ -164,11 +186,6 @@ module.exports = {
server: 'https://dns.alidns.com/dns-query', server: 'https://dns.alidns.com/dns-query',
cacheSize: 1000 cacheSize: 1000
}, },
// ipaddress: {
// type: 'ipaddress',
// server: 'ipaddress',
// cacheSize: 1000
// },
usa: { usa: {
type: 'https', type: 'https',
server: 'https://1.1.1.1/dns-query', server: 'https://1.1.1.1/dns-query',
@ -184,16 +201,6 @@ module.exports = {
server: 'https://rubyfish.cn/dns-query', server: 'https://rubyfish.cn/dns-query',
cacheSize: 1000 cacheSize: 1000
} }
// google: {
// type: 'https',
// server: 'https://8.8.8.8/dns-query',
// cacheSize: 1000
// },
// dnsSB: {
// type: 'https',
// server: 'https://doh.dns.sb/dns-query',
// cacheSize: 1000
// }
}, },
mapping: { mapping: {
// 'assets.fastgit.org': 'usa', // 'assets.fastgit.org': 'usa',

View File

@ -241,3 +241,9 @@ if (isDevelopment) {
}) })
} }
} }
// 系统关机和重启时的操作
process.on('exit', function () {
log.info('系统关机退出app')
quit(app)
})

View File

@ -35,6 +35,7 @@ module.exports = {
} }
// eslint-disable-next-line // eslint-disable-next-line
// no-template-curly-in-string // no-template-curly-in-string
// eslint-disable-next-line no-template-curly-in-string
proxyTarget = proxyTarget.replace('${host}', rOptions.hostname) proxyTarget = proxyTarget.replace('${host}', rOptions.hostname)
// const backup = interceptOpt.backup // const backup = interceptOpt.backup

View File

@ -6,7 +6,6 @@ const DnsUtil = require('../../dns/index')
const log = require('../../../utils/util.log') const log = require('../../../utils/util.log')
const RequestCounter = require('../../choice/RequestCounter') const RequestCounter = require('../../choice/RequestCounter')
const InsertScriptMiddleware = require('../middleware/InsertScriptMiddleware') const InsertScriptMiddleware = require('../middleware/InsertScriptMiddleware')
const OverWallMiddleware = require('../middleware/overwall')
const speedTest = require('../../speed/index.js') const speedTest = require('../../speed/index.js')
const defaultDns = require('dns') const defaultDns = require('dns')
const MAX_SLOW_TIME = 8000 // 超过此时间 则认为太慢了 const MAX_SLOW_TIME = 8000 // 超过此时间 则认为太慢了