perf: loopback
parent
2d4a257ddc
commit
fc841b792e
|
@ -236,7 +236,9 @@ module.exports = {
|
||||||
'*github.com': 'quad9',
|
'*github.com': 'quad9',
|
||||||
'*.vuepress.vuejs.org': 'quad9',
|
'*.vuepress.vuejs.org': 'quad9',
|
||||||
'gh.docmirror.top': 'quad9',
|
'gh.docmirror.top': 'quad9',
|
||||||
'*v2ex.com': 'quad9'
|
'*v2ex.com': 'quad9',
|
||||||
|
'*pypi.org':'quad9',
|
||||||
|
'*jetbrains.com':'quad9'
|
||||||
},
|
},
|
||||||
speedTest: {
|
speedTest: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
|
|
@ -28,6 +28,12 @@ const ProxyPlugin = function (context) {
|
||||||
log.error('关闭系统代理失败', err)
|
log.error('关闭系统代理失败', err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async setEnableLoopback () {
|
||||||
|
await shell.enableLoopback()
|
||||||
|
log.info('打开EnableLoopback成功')
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return api
|
return api
|
||||||
|
|
|
@ -6,6 +6,8 @@ const setSystemEnv = require('./scripts/set-system-env')
|
||||||
const getNpmEnv = require('./scripts/get-npm-env')
|
const getNpmEnv = require('./scripts/get-npm-env')
|
||||||
const setNpmEnv = require('./scripts/set-npm-env')
|
const setNpmEnv = require('./scripts/set-npm-env')
|
||||||
const setSystemProxy = require('./scripts/set-system-proxy/index')
|
const setSystemProxy = require('./scripts/set-system-proxy/index')
|
||||||
|
const enableLoopback = require('./scripts/enable-loopback')
|
||||||
|
const extraPath = require('./scripts/extra-path')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
killByPort,
|
killByPort,
|
||||||
setupCa,
|
setupCa,
|
||||||
|
@ -14,6 +16,8 @@ module.exports = {
|
||||||
getNpmEnv,
|
getNpmEnv,
|
||||||
setNpmEnv,
|
setNpmEnv,
|
||||||
setSystemProxy,
|
setSystemProxy,
|
||||||
|
enableLoopback,
|
||||||
|
extraPath,
|
||||||
async exec (cmds, args) {
|
async exec (cmds, args) {
|
||||||
return shell.getSystemShell().exec(cmds, args)
|
return shell.getSystemShell().exec(cmds, args)
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
const Shell = require('../shell')
|
||||||
|
const extraPath = require('./extra-path')
|
||||||
|
const execute = Shell.execute
|
||||||
|
const executor = {
|
||||||
|
async windows (exec) {
|
||||||
|
const loopbackPath = extraPath.getEnableLoopbackPath()
|
||||||
|
const execFile = Shell.execFile
|
||||||
|
await execFile(loopbackPath)
|
||||||
|
},
|
||||||
|
async linux (exec, { port }) {
|
||||||
|
throw Error('不支持此操作')
|
||||||
|
},
|
||||||
|
async mac (exec, { port }) {
|
||||||
|
throw Error('不支持此操作')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = async function (args) {
|
||||||
|
return execute(executor, args)
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,31 @@
|
||||||
|
const log = require('../../../utils/util.log')
|
||||||
|
const path = require('path')
|
||||||
|
|
||||||
|
function getExtraPath () {
|
||||||
|
let extraPath = process.env.DS_EXTRA_PATH
|
||||||
|
log.info('extraPath', extraPath)
|
||||||
|
if (!extraPath) {
|
||||||
|
extraPath = __dirname
|
||||||
|
}
|
||||||
|
return extraPath
|
||||||
|
}
|
||||||
|
|
||||||
|
function getProxyExePath () {
|
||||||
|
const extraPath = getExtraPath()
|
||||||
|
return path.join(extraPath, 'sysproxy.exe')
|
||||||
|
}
|
||||||
|
|
||||||
|
function getClearBatPath () {
|
||||||
|
const extraPath = getExtraPath()
|
||||||
|
return path.join(extraPath, 'clear.bat')
|
||||||
|
}
|
||||||
|
|
||||||
|
function getEnableLoopbackPath () {
|
||||||
|
const extraPath = getExtraPath()
|
||||||
|
return path.join(extraPath, 'EnableLoopback.exe')
|
||||||
|
}
|
||||||
|
module.exports = {
|
||||||
|
getProxyExePath,
|
||||||
|
getEnableLoopbackPath,
|
||||||
|
getClearBatPath
|
||||||
|
}
|
|
@ -13,6 +13,7 @@ const childProcess = require('child_process')
|
||||||
const util = require('util')
|
const util = require('util')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const _exec = util.promisify(childProcess.exec)
|
const _exec = util.promisify(childProcess.exec)
|
||||||
|
const extraPath = require('../extra-path/index')
|
||||||
const _lanIP = [
|
const _lanIP = [
|
||||||
'localhost',
|
'localhost',
|
||||||
'127.*',
|
'127.*',
|
||||||
|
@ -33,95 +34,13 @@ const _lanIP = [
|
||||||
'172.29.*',
|
'172.29.*',
|
||||||
'172.30.*',
|
'172.30.*',
|
||||||
'172.31.*',
|
'172.31.*',
|
||||||
'192.168.*'
|
'192.168.*',
|
||||||
|
'<-loopback>'
|
||||||
]
|
]
|
||||||
|
|
||||||
const logoffScriptPath = 'C:\\WINDOWS\\System32\\GroupPolicy\\User\\Scripts\\scripts.ini'
|
|
||||||
|
|
||||||
function buildScriptBody (addHeader = true, index = 0) {
|
|
||||||
const batPath = getClearBatPath()
|
|
||||||
const header = addHeader ? '[Logoff]\r\n' : ''
|
|
||||||
return `${header}${index}CmdLine=${batPath}
|
|
||||||
${index}Parameters=`
|
|
||||||
}
|
|
||||||
|
|
||||||
async function addClearScriptIni () {
|
|
||||||
const batPath = getClearBatPath()
|
|
||||||
let body
|
|
||||||
if (fs.existsSync(logoffScriptPath)) {
|
|
||||||
body = fs.readFileSync(logoffScriptPath)
|
|
||||||
if (body.indexOf(batPath) >= 0) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
let index = 0
|
|
||||||
// 要加新的
|
|
||||||
if (body.indexOf('[Logoff]') >= 0) {
|
|
||||||
// 如果有logoff了
|
|
||||||
const list = body.trim().split('\n')
|
|
||||||
let lastParameters = -1
|
|
||||||
for (const string of list) {
|
|
||||||
if (string.indexOf('Parameters') >= 0) {
|
|
||||||
lastParameters = parseInt(string.trim().charAt(0))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
index = lastParameters + 1
|
|
||||||
body += '\r\n' + buildScriptBody(false, index)
|
|
||||||
} else {
|
|
||||||
body += '\r\n' + buildScriptBody(true, 0)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
body = buildScriptBody(true, 0)
|
|
||||||
}
|
|
||||||
fs.writeFileSync(logoffScriptPath, body)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function removeClearScriptIni () {
|
|
||||||
if (!fs.existsSync(logoffScriptPath)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const batPath = getClearBatPath()
|
|
||||||
let body = fs.readFileSync(logoffScriptPath)
|
|
||||||
if (body.indexOf(batPath) === -1) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 有就要删除
|
|
||||||
body = body.trim()
|
|
||||||
const list = body.split('\n')
|
|
||||||
let lastParameters = -1
|
|
||||||
for (const string of list) {
|
|
||||||
if (string.indexOf(batPath) >= 0) {
|
|
||||||
lastParameters = parseInt(string.trim().charAt(0))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
body = body.replace(`${lastParameters}CmdLine=${batPath}`, '')
|
|
||||||
body = body.replace(`${lastParameters}Parameters=`, '')
|
|
||||||
body = body.trim()
|
|
||||||
fs.writeFileSync(logoffScriptPath, body)
|
|
||||||
}
|
|
||||||
|
|
||||||
function getExtraPath () {
|
|
||||||
let extraPath = process.env.DS_EXTRA_PATH
|
|
||||||
log.info('extraPath', extraPath)
|
|
||||||
if (!extraPath) {
|
|
||||||
extraPath = __dirname
|
|
||||||
}
|
|
||||||
return extraPath
|
|
||||||
}
|
|
||||||
|
|
||||||
function getProxyExePath () {
|
|
||||||
const extraPath = getExtraPath()
|
|
||||||
return path.join(extraPath, 'sysproxy.exe')
|
|
||||||
}
|
|
||||||
|
|
||||||
function getClearBatPath () {
|
|
||||||
const extraPath = getExtraPath()
|
|
||||||
return path.join(extraPath, 'clear.bat')
|
|
||||||
}
|
|
||||||
|
|
||||||
async function _winUnsetProxy (exec) {
|
async function _winUnsetProxy (exec) {
|
||||||
// eslint-disable-next-line no-constant-condition
|
// eslint-disable-next-line no-constant-condition
|
||||||
const proxyPath = getProxyExePath()
|
const proxyPath = extraPath.getProxyExePath()
|
||||||
await execFile(proxyPath, ['set', '1'])
|
await execFile(proxyPath, ['set', '1'])
|
||||||
try {
|
try {
|
||||||
// await removeClearScriptIni()
|
// await removeClearScriptIni()
|
||||||
|
@ -135,7 +54,7 @@ async function _winSetProxy (exec, ip, port) {
|
||||||
for (const string of _lanIP) {
|
for (const string of _lanIP) {
|
||||||
lanIpStr += string + ';'
|
lanIpStr += string + ';'
|
||||||
}
|
}
|
||||||
const proxyPath = getProxyExePath()
|
const proxyPath = extraPath.getProxyExePath()
|
||||||
await execFile(proxyPath, ['global', `${ip}:${port}`, lanIpStr])
|
await execFile(proxyPath, ['global', `${ip}:${port}`, lanIpStr])
|
||||||
try {
|
try {
|
||||||
// await addClearScriptIni()
|
// await addClearScriptIni()
|
||||||
|
|
|
@ -93,10 +93,10 @@
|
||||||
lodash "^4.17.19"
|
lodash "^4.17.19"
|
||||||
to-fast-properties "^2.0.0"
|
to-fast-properties "^2.0.0"
|
||||||
|
|
||||||
"@docmirror/mitmproxy@^1.5.1":
|
"@docmirror/mitmproxy@^1.6.2":
|
||||||
version "1.5.1"
|
version "1.6.2"
|
||||||
resolved "https://registry.nlark.com/@docmirror/mitmproxy/download/@docmirror/mitmproxy-1.5.1.tgz#357142a41b89266491c3519a7528b9b83dc30c85"
|
resolved "https://registry.yarnpkg.com/@docmirror/mitmproxy/-/mitmproxy-1.6.2.tgz#51c7792d7d172820250822abbaacf148e629666c"
|
||||||
integrity sha1-NXFCpBuJJmSRw1GadSi5uD3DDIU=
|
integrity sha512-JF/cJzHuV23TTN1oS+r32Qole/u37H8H36ycO06IjxmOfXx5pu0nqeOTMe3bWTXLI1YlnlktVNOH72xH73C1Fg==
|
||||||
dependencies:
|
dependencies:
|
||||||
agentkeepalive "^2.1.1"
|
agentkeepalive "^2.1.1"
|
||||||
axios "^0.21.1"
|
axios "^0.21.1"
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
"electron-baidu-tongji": "^1.0.5",
|
"electron-baidu-tongji": "^1.0.5",
|
||||||
"electron-reload": "^1.5.0",
|
"electron-reload": "^1.5.0",
|
||||||
"electron-store": "^6.0.1",
|
"electron-store": "^6.0.1",
|
||||||
|
"electron-sudo": "^4.0.12",
|
||||||
"electron-updater": "^4.3.5",
|
"electron-updater": "^4.3.5",
|
||||||
"es-abstract": "^1.17.7",
|
"es-abstract": "^1.17.7",
|
||||||
"extract-zip": "^2.0.1",
|
"extract-zip": "^2.0.1",
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 97 KiB |
|
@ -0,0 +1,12 @@
|
||||||
|
import Sudoer from 'electron-sudo'
|
||||||
|
import DevSidecar from '@docmirror/dev-sidecar'
|
||||||
|
export default {
|
||||||
|
async open () {
|
||||||
|
const options = { name: '设置loopback' }
|
||||||
|
const sudoer = new Sudoer(options)
|
||||||
|
const exeFile = DevSidecar.api.shell.extraPath.getEnableLoopbackPath()
|
||||||
|
await sudoer.exec(
|
||||||
|
exeFile, { env: { PARAM: 'VALUE' } }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
|
@ -86,8 +86,8 @@
|
||||||
捐赠
|
捐赠
|
||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<div>如果它解决了你的问题,请不要吝啬你的star哟!
|
<div>如果它解决了你的问题,请不要吝啬你的star哟!点这里
|
||||||
<a-icon style="margin-right:10px;" type="smile" theme="outlined"/>
|
<a-icon style="margin-right:10px;" type="arrow-right" theme="outlined"/>
|
||||||
</div>
|
</div>
|
||||||
<a @click="openExternal('https://gitee.com/docmirror/dev-sidecar')"><img
|
<a @click="openExternal('https://gitee.com/docmirror/dev-sidecar')"><img
|
||||||
src='https://gitee.com/docmirror/dev-sidecar/badge/star.svg?theme=dark' alt='star'/></a>
|
src='https://gitee.com/docmirror/dev-sidecar/badge/star.svg?theme=dark' alt='star'/></a>
|
||||||
|
|
|
@ -18,6 +18,10 @@
|
||||||
当前未启动
|
当前未启动
|
||||||
</a-tag>
|
</a-tag>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
<a-form-item label="设置loopback" :label-col="labelCol" :wrapper-col="wrapperCol">
|
||||||
|
<a-button @click="loopbackVisible=true">去设置</a-button>
|
||||||
|
<div class="form-help">解决OneNote、微软应用商店、微软邮箱等大部分系统自带应用无法访问网络问题。点击去设置,然后按下图所示操作即可</div>
|
||||||
|
</a-form-item>
|
||||||
</div>
|
</div>
|
||||||
<template slot="footer">
|
<template slot="footer">
|
||||||
<div class="footer-bar">
|
<div class="footer-bar">
|
||||||
|
@ -25,6 +29,27 @@
|
||||||
<a-button :loading="applyLoading" icon="check" type="primary" @click="apply()">应用</a-button>
|
<a-button :loading="applyLoading" icon="check" type="primary" @click="apply()">应用</a-button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<a-drawer
|
||||||
|
placement="right"
|
||||||
|
:closable="false"
|
||||||
|
:visible.sync="loopbackVisible"
|
||||||
|
width="660px"
|
||||||
|
height="100%"
|
||||||
|
@close="loopbackVisible=false"
|
||||||
|
:slots="{ title: 'title' }"
|
||||||
|
wrapClassName="json-wrapper"
|
||||||
|
>
|
||||||
|
<template slot="title">
|
||||||
|
设置Loopback <a-button style="float:right;margin-right:10px;" @click="openEnableLoopback()">打开EnableLoopback</a-button>
|
||||||
|
</template>
|
||||||
|
<div>
|
||||||
|
<div>解决OneNote、微软应用商店、微软邮箱等大部分系统自带应用无法访问网络问题。点击右上方按钮,然后按下图所示操作即可</div>
|
||||||
|
<div >注意:此操作需要DevSidecar以<b>管理员身份启动</b>,才能打开下面的EnableLoopback设置界面</div>
|
||||||
|
<img style="margin-top:10px;" width="80%" src="loopback.png" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</a-drawer>
|
||||||
</ds-container>
|
</ds-container>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
@ -36,7 +61,8 @@ export default {
|
||||||
mixins: [Plugin],
|
mixins: [Plugin],
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
key: 'proxy'
|
key: 'proxy',
|
||||||
|
loopbackVisible: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
|
@ -45,7 +71,17 @@ export default {
|
||||||
mounted () {
|
mounted () {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
async openEnableLoopback () {
|
||||||
|
try {
|
||||||
|
await this.$api.proxy.setEnableLoopback()
|
||||||
|
} catch (e) {
|
||||||
|
if (e.message.indexOf('EACCES') !== -1) {
|
||||||
|
this.$message.error('请将DevSidecar关闭后,以管理员身份重新打开,再尝试此操作')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.$message.error('打开失败:' + e.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
Arguments:
|
Arguments:
|
||||||
/usr/bin/node /usr/local/bin/yarn install
|
D:\Soft\Development\nodejs\node.exe C:\Users\xiaojunnuo\AppData\Roaming\npm\node_modules\yarn\bin\yarn.js install
|
||||||
|
|
||||||
PATH:
|
PATH:
|
||||||
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
|
D:\Codes\open\dev-sidecar\node_modules\.bin;D:\Soft\Development\python\Scripts\;D:\Soft\Development\python\;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;D:\Soft\Development\Git\cmd;D:\Soft\Development\nodejs\;C:\ProgramData\chocolatey\bin;C:\Users\xiaojunnuo\AppData\Local\Microsoft\WindowsApps;;D:\Soft\Development\IntelliJ IDEA 2021.2.3\bin;;C:\Users\xiaojunnuo\AppData\Roaming\npm;D:\Soft\Development\PyCharm 2021.2.3\bin;
|
||||||
|
|
||||||
Yarn version:
|
Yarn version:
|
||||||
1.22.11
|
1.22.17
|
||||||
|
|
||||||
Node version:
|
Node version:
|
||||||
14.17.5
|
16.13.0
|
||||||
|
|
||||||
Platform:
|
Platform:
|
||||||
linux x64
|
win32 x64
|
||||||
|
|
||||||
Trace:
|
Trace:
|
||||||
Error: ENOENT: no such file or directory, copyfile '/home/xiaojunnuo/.cache/yarn/v6/npm-webpack-4.44.2-6bfe2b0af055c8b2d1e90ed2cd9363f841266b72-integrity/node_modules/webpack/declarations/plugins/BannerPlugin.d.ts' -> '/home/xiaojunnuo/Codes/dev-sidecar/packages/mitmproxy/node_modules/webpack/declarations/plugins/BannerPlugin.d.ts'
|
Error: ENOENT: no such file or directory, copyfile 'C:\Users\xiaojunnuo\AppData\Local\Yarn\Cache\v6\npm-ms-2.0.0-5608aeadfc00be6c2901df5f9861788de0d597c8-integrity\node_modules\ms\index.js' -> 'D:\Codes\open\dev-sidecar\packages\mitmproxy\node_modules\eslint-plugin-import\node_modules\ms\index.js'
|
||||||
|
|
||||||
npm manifest:
|
npm manifest:
|
||||||
{
|
{
|
||||||
"name": "@docmirror/mitmproxy",
|
"name": "@docmirror/mitmproxy",
|
||||||
"version": "1.5.1",
|
"version": "1.6.2",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
@ -85,7 +85,7 @@ npm manifest:
|
||||||
"last 2 versions",
|
"last 2 versions",
|
||||||
"not dead"
|
"not dead"
|
||||||
],
|
],
|
||||||
"gitHead": "3566cd6d33cbe782d91e408d6f174dd826b2790f"
|
"gitHead": "9b027af3ee7e88975a54692ed83096802764a8dc"
|
||||||
}
|
}
|
||||||
|
|
||||||
yarn manifest:
|
yarn manifest:
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
packages:
|
||||||
|
# all packages in subdirs of packages/ and components/
|
||||||
|
- 'packages/**'
|
||||||
|
# exclude packages that are inside test directories
|
||||||
|
- '!**/test/**'
|
Loading…
Reference in New Issue