feat: 设置界面

pull/180/head
xiaojunnuo 2020-11-07 20:50:19 +08:00
parent 032465beae
commit 8aec95ad34
20 changed files with 21088 additions and 427 deletions

View File

@ -100,30 +100,31 @@ sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keyc
### 拦截配置
没有配置域名的不会拦截,其他根据配置进行拦截处理
```js
'github.com': [
{ // 此条配置 release archive 下载链接替换,
regexp: [ //需要拦截的url
'/.*/.*/releases/download/',
'/.*/.*/archive/'
],
//拦截类型
// redirect:url, 临时重定向(url会变一些下载资源可以通过此方式配置)
// proxy:url, 代理url不会变没有跨域问题
// abort:true, 取消请求适用于被GFW封锁的资源找不到替代直接取消请求快速失败节省时间
redirect: 'https://download.fastgit.org' //跳转到加速下载链接上
},
'ajax.googleapis.com': [
{
regexp:'.*' // .* 拦截全部url路径可省略
proxy: 'https://ajax.loli.net' //代理到加速链接上url不会变没有跨域问题适用于一些静态资源比如js、css的请求
}
],
'clients*.google.com': [
{
abort: true //取消请求被GFW封锁的资源找不到替代直接取消请求快速失败节省时间
}
]
],
const intercepts = {
// 要拦截的域名
'github.com': {
//需要拦截url的正则表达式
'/.*/.*/releases/download/': {
//拦截类型
// redirect:url, 临时重定向(url会变一些下载资源可以通过此方式配置)
// proxy:url, 代理url不会变没有跨域问题
// abort:true, 取消请求适用于被GFW封锁的资源找不到替代直接取消请求快速失败节省时间
redirect: 'download.fastgit.org'
},
},
'ajax.googleapis.com': {
'.*': {
proxy: 'ajax.loli.net', //代理请求url不会变
backup: ['ajax.proxy.ustclug.org'],
test: 'ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js'
}
},
'clients*.google.com': {
'.*':{
abort: true //取消请求被GFW封锁的资源找不到替代直接取消请求快速失败节省时间
}
}
}
```
### DNS配置
@ -140,14 +141,8 @@ sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keyc
}
},
```
注意暂时只支持IPv4的解析
## 开发计划
1. 桌面端,右下角小图标
2. √ google cdn加速
## 感谢
本项目参考如下开源项目
* [node-mitmproxy](https://github.com/wuchangming/node-mitmproxy)

7078
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,5 @@
"lerna": "^3.22.1"
},
"dependencies": {
"d2-crud-x": "^2.12.0",
"sqlite3": "^5.0.0"
}
}

View File

@ -84,12 +84,12 @@ module.exports = {
providers: {
aliyun: {
type: 'https',
server: 'dns.alidns.com/dns-query',
server: 'https://dns.alidns.com/dns-query',
cacheSize: 1000
},
usa: {
type: 'https',
server: 'cloudflare-dns.com/dns-query',
server: 'https://cloudflare-dns.com/dns-query',
cacheSize: 1000
}
},

View File

@ -1,6 +1,5 @@
const systemProxy = require('./system-proxy')
const ProxyPlugin = function (context) {
const { config, event } = context
const { config, event, shell } = context
const api = {
async start () {
return api.setProxy()
@ -13,7 +12,7 @@ const ProxyPlugin = function (context) {
async setProxy () {
const ip = '127.0.0.1'
const port = config.get().server.port
await systemProxy.setProxy(ip, port)
await shell.setSystemProxy({ ip, port })
console.log(`开启系统代理成功:${ip}:${port}`)
event.fire('status', { key: 'proxy.enabled', value: true })
return { ip, port }
@ -21,7 +20,7 @@ const ProxyPlugin = function (context) {
async unsetProxy () {
try {
systemProxy.unsetProxy()
shell.setSystemProxy()
event.fire('status', { key: 'proxy.enabled', vlaue: false })
console.log('关闭系统代理成功')
return true

View File

@ -1,74 +0,0 @@
<#
.Synopsis
This function will set the proxy settings provided as input to the cmdlet.
.Description
This function will set the proxy server and (optinal) Automatic configuration script.
.Parameter ProxyServer
This parameter is set as the proxy for the system.
Data from. This parameter is Mandatory
.Example
Setting proxy information
Set-InternetProxy -proxy "proxy:7890"
.Example
Setting proxy information and (optinal) Automatic Configuration Script
Set-InternetProxy -proxy "proxy:7890" -acs "http://proxy:7892"
#>
Function Set-InternetProxy
{
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[String[]]$Proxy,
[Parameter(Mandatory=$False,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[AllowEmptyString()]
[String[]]$acs
)
Begin
{
$regKey="HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
}
Process
{
Set-ItemProperty -path $regKey ProxyEnable -value 1
Set-ItemProperty -path $regKey ProxyServer -value $proxy
if($acs)
{
Set-ItemProperty -path $regKey AutoConfigURL -Value $acs
}
}
End
{
Write-Output "Proxy is now enabled"
Write-Output "Proxy Server : $proxy"
if ($acs)
{
Write-Output "Automatic Configuration Script : $acs"
}
else
{
Write-Output "Automatic Configuration Script : Not Defined"
}
}
}

View File

@ -1,14 +0,0 @@
$signature = @'
[DllImport("wininet.dll", SetLastError = true, CharSet=CharSet.Auto)]
public static extern bool InternetSetOption(IntPtr hInternet, int
dwOption, IntPtr lpBuffer, int dwBufferLength);
'@
$interopHelper = Add-Type -MemberDefinition $signature -Name MyInteropHelper -PassThru
$INTERNET_OPTION_SETTINGS_CHANGED = 39
$INTERNET_OPTION_REFRESH = 37
$result1 = $interopHelper::InternetSetOption(0, $INTERNET_OPTION_SETTINGS_CHANGED, 0, 0)
$result2 = $interopHelper::InternetSetOption(0, $INTERNET_OPTION_REFRESH, 0, 0)
$result1 -and $result2

View File

@ -1,61 +0,0 @@
const script = `
Function Set-InternetProxy
{
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[String[]]$Proxy,
[Parameter(Mandatory=$False,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[AllowEmptyString()]
[String[]]$acs
)
Begin
{
$regKey="HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"
}
Process
{
Set-ItemProperty -path $regKey ProxyEnable -value 1
Set-ItemProperty -path $regKey ProxyServer -value $proxy
if($acs)
{
Set-ItemProperty -path $regKey AutoConfigURL -Value $acs
}
}
End
{
Write-Output "Proxy is now enabled"
Write-Output "Proxy Server : $proxy"
if ($acs)
{
Write-Output "Automatic Configuration Script : $acs"
}
else
{
Write-Output "Automatic Configuration Script : Not Defined"
}
}
}
`
module.exports = script

View File

@ -1,191 +0,0 @@
const util = require('util')
const os = require('os')
const childProcess = require('child_process')
const _exec = childProcess.exec
const Registry = require('winreg')
// const cmd = require('node-cmd')
const exec = util.promisify(_exec)
const refreshInternetPs = require('./refresh-internet')
const PowerShell = require('node-powershell')
const _lanIP = [
'localhost',
'127.*',
'10.*',
'172.16.*',
'172.17.*',
'172.18.*',
'172.19.*',
'172.20.*',
'172.21.*',
'172.22.*',
'172.23.*',
'172.24.*',
'172.25.*',
'172.26.*',
'172.27.*',
'172.28.*',
'172.29.*',
'172.30.*',
'172.31.*',
'192.168.*',
'<local>'
]
class SystemProxy {
static async setProxy (ip, port) {
throw new Error('You have to implement the method setProxy!')
}
static async unsetProxy () {
throw new Error('You have to implement the method unsetProxy!')
}
}
// TODO: Add path http_proxy and https_proxy
// TODO: Support for non-gnome
class LinuxSystemProxy extends SystemProxy {
static async setProxy (ip, port) {
await exec('gsettings set org.gnome.system.proxy mode manual')
await exec(`gsettings set org.gnome.system.proxy.http host ${ip}`)
await exec(`gsettings set org.gnome.system.proxy.http port ${port}`)
}
static async unsetProxy () {
await exec('gsettings set org.gnome.system.proxy mode none')
}
}
// TODO: Support for lan connections too
// TODO: move scripts to ../scripts/darwin
class DarwinSystemProxy extends SystemProxy {
static async setProxy (ip, port) {
const wifiAdaptor = (await exec('sh -c "networksetup -listnetworkserviceorder | grep `route -n get 0.0.0.0 | grep \'interface\' | cut -d \':\' -f2` -B 1 | head -n 1 | cut -d \' \' -f2"')).stdout.trim()
await exec(`networksetup -setwebproxy '${wifiAdaptor}' ${ip} ${port}`)
await exec(`networksetup -setsecurewebproxy '${wifiAdaptor}' ${ip} ${port}`)
}
static async unsetProxy () {
const wifiAdaptor = (await exec('sh -c "networksetup -listnetworkserviceorder | grep `route -n get 0.0.0.0 | grep \'interface\' | cut -d \':\' -f2` -B 1 | head -n 1 | cut -d \' \' -f2"')).stdout.trim()
await exec(`networksetup -setwebproxystate '${wifiAdaptor}' off`)
await exec(`networksetup -setsecurewebproxystate '${wifiAdaptor}' off`)
}
}
class WindowsSystemProxy extends SystemProxy {
static async setProxy (ip, port) {
const regKey = new Registry({
hive: Registry.HKCU,
key: '\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings'
})
let lanIpStr = ''
for (const string of _lanIP) {
lanIpStr += string + ';'
}
// console.log('lanIps:', lanIpStr, ip, port)
await Promise.all([
WindowsSystemProxy._asyncRegSet(regKey, 'MigrateProxy', Registry.REG_DWORD, 1),
WindowsSystemProxy._asyncRegSet(regKey, 'ProxyEnable', Registry.REG_DWORD, 1),
WindowsSystemProxy._asyncRegSet(regKey, 'ProxyHttp1.1', Registry.REG_DWORD, 0),
WindowsSystemProxy._asyncRegSet(regKey, 'ProxyServer', Registry.REG_SZ, `${ip}:${port}`),
WindowsSystemProxy._asyncRegSet(regKey, 'ProxyOverride', Registry.REG_SZ, lanIpStr)
])
WindowsSystemProxy._resetWininetProxySettings('echo refreshing') // 要执行一下这个才能生效
WindowsSystemProxy._resetWininetProxySettings(refreshInternetPs)
}
static async unsetProxy () {
const regKey = new Registry({
hive: Registry.HKCU,
key: '\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings'
})
await Promise.all([
WindowsSystemProxy._asyncRegSet(regKey, 'ProxyEnable', Registry.REG_DWORD, 0),
WindowsSystemProxy._asyncRegSet(regKey, 'ProxyServer', Registry.REG_SZ, '')
])
WindowsSystemProxy._resetWininetProxySettings(refreshInternetPs)
}
static _asyncRegSet (regKey, name, type, value) {
return new Promise((resolve, reject) => {
regKey.set(name, type, value, e => {
if (e) {
reject(e)
} else {
resolve()
}
})
})
}
static _resetWininetProxySettings (script) {
return new Promise((resolve, reject) => {
const ps = new PowerShell({
executionPolicy: 'Bypass',
noProfile: true
})
// ps.addCommand(setproxyPs)
// ps.addCommand(`Set-InternetProxy -Proxy "${ip}:${port}"`)
ps.addCommand(script)
ps.invoke()
.then(output => {
console.log(output)
resolve()
})
.catch(err => {
console.log(err)
reject(err)
})
// const scriptPath = path.join(__dirname, '..', 'scripts', 'windows', 'wininet-reset-settings.ps1')
// const child = spawn('powershell.exe', [scriptPath])
// child.stdout.setEncoding('utf8')
// child.stdout.on('data', (data) => {
// console.log('data', data)
// if (data.includes('True')) {
// resolve()
// } else {
// reject(data)
// }
// })
//
// child.stderr.on('data', (err) => {
// console.log('data', err)
// reject(err)
// })
//
// child.stdin.end()
})
}
}
function getSystemProxy () {
switch (os.platform()) {
case 'darwin':
return DarwinSystemProxy
case 'linux':
return LinuxSystemProxy
case 'win32':
case 'win64':
return WindowsSystemProxy
case 'unknown os':
default:
throw new Error(`UNKNOWN OS TYPE ${os.platform()}`)
}
}
module.exports = {
async setProxy (ip, port) {
const systemProxy = getSystemProxy()
await systemProxy.setProxy(ip, port)
},
async unsetProxy () {
const systemProxy = getSystemProxy()
await systemProxy.unsetProxy()
}
}

View File

@ -5,6 +5,7 @@ const getSystemEnv = require('./scripts/get-system-env')
const setSystemEnv = require('./scripts/set-system-env')
const getNpmEnv = require('./scripts/get-npm-env')
const setNpmEnv = require('./scripts/set-npm-env')
const setSystemProxy = require('./scripts/set-system-proxy/index')
module.exports = {
killByPort,
setupCa,
@ -12,6 +13,7 @@ module.exports = {
setSystemEnv,
getNpmEnv,
setNpmEnv,
setSystemProxy,
async exec (cmds, args) {
return shell.getSystemShell().exec(cmds, args)
}

View File

@ -0,0 +1,124 @@
/**
* 获取环境变量
*/
const Shell = require('../../shell')
const execute = Shell.execute
const Registry = require('winreg')
// const cmd = require('node-cmd')
const refreshInternetPs = require('./refresh-internet')
const PowerShell = require('node-powershell')
const _lanIP = [
'localhost',
'127.*',
'10.*',
'172.16.*',
'172.17.*',
'172.18.*',
'172.19.*',
'172.20.*',
'172.21.*',
'172.22.*',
'172.23.*',
'172.24.*',
'172.25.*',
'172.26.*',
'172.27.*',
'172.28.*',
'172.29.*',
'172.30.*',
'172.31.*',
'192.168.*',
'<local>'
]
async function _winUnsetProxy (exec) {
const regKey = new Registry({
hive: Registry.HKCU,
key: '\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings'
})
await Promise.all([
_winAsyncRegSet(regKey, 'ProxyEnable', Registry.REG_DWORD, 0),
_winAsyncRegSet(regKey, 'ProxyServer', Registry.REG_SZ, '')
])
await exec([refreshInternetPs], { type: 'ps' })
return true
}
async function _winSetProxy (exec, ip, port) {
const regKey = new Registry({
hive: Registry.HKCU,
key: '\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings'
})
let lanIpStr = ''
for (const string of _lanIP) {
lanIpStr += string + ';'
}
// console.log('lanIps:', lanIpStr, ip, port)
await Promise.all([
_winAsyncRegSet(regKey, 'MigrateProxy', Registry.REG_DWORD, 1),
_winAsyncRegSet(regKey, 'ProxyEnable', Registry.REG_DWORD, 1),
_winAsyncRegSet(regKey, 'ProxyHttp1.1', Registry.REG_DWORD, 0),
_winAsyncRegSet(regKey, 'ProxyServer', Registry.REG_SZ, `${ip}:${port}`),
_winAsyncRegSet(regKey, 'ProxyOverride', Registry.REG_SZ, lanIpStr)
])
console.log('---代理设置成功等待refresh------')
await exec([refreshInternetPs])
return true
}
function _winAsyncRegSet (regKey, name, type, value) {
return new Promise((resolve, reject) => {
regKey.set(name, type, value, e => {
if (e) {
reject(e)
} else {
resolve()
}
})
})
}
async function _winResetWininetProxySettings (script) {
const ps = new PowerShell({
executionPolicy: 'Bypass',
noProfile: true
})
ps.addCommand(script)
try {
const ret = await ps.invoke()
console.log('ps complete', script)
return ret
} finally {
ps.dispose()
}
}
const executor = {
async windows (exec, params) {
if (params == null) {
// 清空代理
console.log('关闭代理')
return _winUnsetProxy(exec)
} else {
// 设置代理
const { ip, port } = params
console.log('设置代理', ip, port)
return _winSetProxy(exec, ip, port)
}
},
async linux (exec, { port }) {
throw Error('暂未实现此功能')
},
async mac (exec, { port }) {
throw Error('暂未实现此功能')
}
}
module.exports = async function (args) {
return execute(executor, args)
}

View File

@ -3,7 +3,7 @@ const os = require('os')
const childProcess = require('child_process')
const _exec = childProcess.exec
const exec = util.promisify(_exec)
const Shell = require('node-powershell')
const PowerShell = require('node-powershell')
class SystemShell {
static async exec (cmds, args) {
@ -41,7 +41,7 @@ class WindowsSystemShell extends SystemShell {
cmds = [cmds]
}
if (type === 'ps') {
const ps = new Shell({
const ps = new PowerShell({
executionPolicy: 'Bypass',
noProfile: true
})
@ -50,16 +50,21 @@ class WindowsSystemShell extends SystemShell {
ps.addCommand(cmd)
}
const ret = await ps.invoke()
// console.log('ps complete:', cmds, ret)
return ret
try {
const ret = await ps.invoke()
// console.log('ps complete', cmds)
return ret
} finally {
ps.dispose()
}
} else {
let compose = 'chcp 65001 '
for (const cmd of cmds) {
compose += ' && ' + cmd
}
// compose += '&& exit'
const ret = await childExec(compose)
// console.log('cmd complete:', cmds)
// console.log('cmd complete:', compose)
return ret
}
}
@ -67,13 +72,17 @@ class WindowsSystemShell extends SystemShell {
function childExec (composeCmds) {
return new Promise((resolve, reject) => {
const childProcess = require('child_process')
childProcess.exec(composeCmds, function (error, stdout, stderr) {
if (error) {
console.error('cmd 命令执行错误:', composeCmds, error, stderr)
reject(error)
} else {
console.log('cmd 命令完成:', stdout)
resolve(stdout)
}
// console.log('关闭 cmd')
// ps.kill('SIGINT')
})
})
}

View File

@ -863,6 +863,50 @@
lodash "^4.17.19"
to-fast-properties "^2.0.0"
"@coolaj86/urequest@^1.3.6":
version "1.3.7"
resolved "https://registry.yarnpkg.com/@coolaj86/urequest/-/urequest-1.3.7.tgz#66a1d66378dd6534e9c8e68948bf09acf32bab77"
integrity sha512-PPrVYra9aWvZjSCKl/x1pJ9ZpXda1652oJrPBYy5rQumJJMkmTBN3ux+sK2xAUwVvv2wnewDlaQaHLxLwSHnIA==
"@docmirror/mitmproxy@1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@docmirror/mitmproxy/-/mitmproxy-1.0.0.tgz#5d97aa04a187271949e21be10305ec5487eab1d1"
integrity sha512-gtrMtqSbUtVhhEnvsccGl7DfiUAQ1WS76mwQcqc5oCWfCa5Aw1sZVtCIwyfdljb2F1fyaLWm2xtC24gFOkBJfw==
dependencies:
agentkeepalive "^2.1.1"
babel-core "^6.8.0"
babel-plugin-transform-async-to-generator "^6.7.4"
babel-polyfill "^6.8.0"
babel-preset-es2015 "^6.6.0"
babel-register "^6.8.0"
charset "^1.0.0"
child_process "^1.0.2"
colors "^1.1.2"
commander "^2.9.0"
core-js "^3.6.5"
debug "^4.1.1"
dns-over-http "^0.2.0"
dns-over-tls "^0.0.8"
iconv-lite "^0.4.13"
is-browser "^2.1.0"
jschardet "^1.4.1"
json5 "^2.1.3"
lodash "^4.7.0"
lru-cache "^6.0.0"
mkdirp "^0.5.1"
node-cmd "^3.0.0"
node-forge "^0.8.2"
node-mitmproxy "^3.1.1"
node-powershell "^4.0.0"
require-context "^1.1.0"
ssl-root-cas "^1.3.1"
through2 "^2.0.1"
tunnel-agent "^0.4.3"
util "^0.12.3"
validator "^13.1.17"
vue "^2.6.11"
winreg "^1.2.4"
"@hapi/address@2.x.x":
version "2.1.4"
resolved "https://registry.npm.taobao.org/@hapi/address/download/@hapi/address-2.1.4.tgz?cache=0&sync_timestamp=1593993895205&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40hapi%2Faddress%2Fdownload%2F%40hapi%2Faddress-2.1.4.tgz#5d67ed43f3fd41a69d4b9ff7b56e7c0d1d0a81e5"
@ -8459,6 +8503,13 @@ sshpk@^1.7.0:
safer-buffer "^2.0.2"
tweetnacl "~0.14.0"
ssl-root-cas@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/ssl-root-cas/-/ssl-root-cas-1.3.1.tgz#6b0566f7de4f0e6be99fbd93dbfbe5c7ab33b949"
integrity sha512-KR8J210Wfvjh+iNE9jcQEgbG0VG2713PHreItx6aNCPnkFO8XChz1cJ4iuCGeBj0+8wukLmgHgJqX+O5kRjPkQ==
dependencies:
"@coolaj86/urequest" "^1.3.6"
ssri@^6.0.1:
version "6.0.1"
resolved "https://registry.npm.taobao.org/ssri/download/ssri-6.0.1.tgz#2a3c41b28dd45b62b63676ecb74001265ae9edd8"

View File

@ -94,50 +94,71 @@ function createWindow () {
})
}
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
quit(app)
}
})
app.on('activate', () => {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (win === null) {
createWindow()
}
})
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', async () => {
if (isDevelopment && !process.env.IS_TEST) {
// Install Vue Devtools
// try {
// await installExtension(VUEJS_DEVTOOLS)
// } catch (e) {
// console.error('Vue Devtools failed to install:', e.toString())
// }
}
createWindow()
bridge.init(win)
try {
// 最小化到托盘
tray = setTray(app)
} catch (err) {
console.log('err', err)
}
})
function quit (app) {
bridge.devSidecar.api.shutdown().then(() => {
app.quit()
})
if (tray) {
tray.displayBalloon({ title: '正在关闭,请稍候...', content: '正在关闭中,请稍候。。。' })
}
}
const isFirstInstance = app.requestSingleInstanceLock()
if (!isFirstInstance) {
console.log('is second instance')
setTimeout(() => {
app.quit()
}, 1000)
} else {
app.on('second-instance', (event, commandLine, workingDirectory) => {
console.log('new app started', commandLine)
if (win) {
win.show()
win.focus()
}
})
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
quit(app)
}
})
app.on('activate', () => {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (win === null) {
createWindow()
}
})
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', async () => {
if (isDevelopment && !process.env.IS_TEST) {
// Install Vue Devtools
// try {
// await installExtension(VUEJS_DEVTOOLS)
// } catch (e) {
// console.error('Vue Devtools failed to install:', e.toString())
// }
}
createWindow()
bridge.init(win)
try {
// 最小化到托盘
tray = setTray(app)
} catch (err) {
console.log('err', err)
}
})
}
// Exit cleanly on request from parent process in development mode.
if (isDevelopment) {
if (process.platform === 'win32') {
@ -147,7 +168,7 @@ if (isDevelopment) {
}
})
} else {
process.on('SIGTERM', () => {
process.on('SIGINT', () => {
quit(app)
})
}

13725
packages/mitmproxy/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,7 @@ module.exports = class BaseDNS {
ip = hostname
for (let depth = 0; !_isIP(ip) && depth < 5; depth++) {
ip = await this._lookup(ip).catch(error => {
logger.debug(error)
logger.debug(ip, error)
return ip
})
}
@ -38,8 +38,8 @@ module.exports = class BaseDNS {
this.cache.set(hostname, ip)
return ip
} catch (error) {
console.error(error)
logger.debug(`[DNS] cannot resolve hostname ${hostname} (${error})`)
return hostname
}
}
}

View File

@ -23,7 +23,6 @@ module.exports = function createConnectHandler (sslConnectInterceptor, fakeServe
dns.lookup(hostname).then(ip => {
connect(req, cltSocket, head, ip, srvUrl.port)
})
return
}
}
connect(req, cltSocket, head, hostname, srvUrl.port)

View File

0
test/testDns.js Normal file
View File