Merge remote-tracking branch 'origin/master'

pull/192/head
xiaojunnuo 2021-08-20 11:21:05 +08:00
commit bcc3080912
39 changed files with 464 additions and 22290 deletions

2
.gitignore vendored
View File

@ -4,3 +4,5 @@
out
gen
node_modules/
*.lock
*.log

View File

@ -7,7 +7,7 @@
## 特性
## 一、 特性
### 1、 dns优选解决***污染问题)
* 根据网络状况智能解析最佳域名ip地址获取最佳网络速度
@ -20,6 +20,7 @@
* 具备测速机制,当访问失败或超时之后,自动切换到备用站点,使得目标服务高可用
### 3、 github加速
* github 直连加速 (通过修改sni实现感谢 [fastGithub](https://github.com/dotnetcore/FastGithub) 提供的思路)
* release、source、zip下载加速
* clone 加速
* 头像加速
@ -34,6 +35,7 @@
>
> 由于此脚本在ds中是打包在本地的更新会不及时你可以直接通过浏览器安装油猴插件使用此脚本从而获得最新更新ds本地的可以通过`加速服务->基本设置->启用脚本`进行关闭)。
### 4、 Stack Overflow 加速
* 将ajax.google.com代理到加速CDN上
* recaptcha 图片验证码加速
@ -52,7 +54,7 @@
* 本应用及服务端承诺不收集任何信息。介意者请使用安全模式。
* 建议自建服务端(增强功能页面右上角点击查看自建服务端方法)
## 快速开始
## 二、快速开始
支持windows、Mac
### DevSidecar桌面应用
@ -62,9 +64,12 @@
[Gitee Release](https://gitee.com/docmirror/dev-sidecar/releases)
[Github Release](https://github.com/docmirror/dev-sidecar/releases)
Windows: 请选择DevSidecar-x.x.x.exe
Mac: 请选择DevSidecar-x.x.x.dmg
> Windows: 请选择DevSidecar-x.x.x.exe
> Mac: 请选择DevSidecar-x.x.x.dmg
> Ubuntu: 请选择DevSidecar-x.x.x.deb
> 其他linux: 请选择DevSidecar-x.x.x.AppImage (未做测试,不保证能用)
> linux安装说明请参考 [linux安装文档](./doc/linux.md)
#### 2 安装后打开
注意mac版安装需要在“系统偏好设置->安全性与隐私->通用”中解锁并允许应用安装
@ -82,7 +87,7 @@
去试试打开github
---------
> 第一次访问会去国外的dns服务器上获取ip会比较慢一点后面就快了
> 第一次访问会去国外的dns服务器上获取ip会比较慢一点后面就快了
---------
### 开启前 vs 开启后
@ -94,7 +99,7 @@
|zip 下载 |![](./doc/download-before.png) |![](./doc/download.png)秒下的,实在截不到速度的图 |
## 模式说明
## 三、模式说明
### 安全模式
* 此模式关闭拦截、关闭增强、开启dns优选、开启测速
@ -137,7 +142,7 @@
>2. [github.com.cnpmjs.org](https://github.com.cnpmjs.org/) 这个很容易超限
## api
## 四、api
### 拦截配置
没有配置域名的不会拦截,其他根据配置进行拦截处理
@ -154,6 +159,10 @@ const intercepts = {
// success:true, 直接返回成功请求(某些请求不想发出去,可以伪装成功返回)
redirect: 'download.fastgit.org'
},
'.*':{
proxy:'github.com',
sni:'baidu.com' //修改sni规避***握手拦截
}
},
'ajax.googleapis.com': {
'.*': {
@ -187,7 +196,7 @@ const intercepts = {
```
注意暂时只支持IPv4的解析
## 问题排查
## 五、问题排查
### 1、dev-sidecar的前两个开关没有处于打开状态
1. 尝试将开关按钮手动打开
@ -235,20 +244,6 @@ sudo xcodebuild -license
7. 请确认网络代理设置处于勾选状态
正常情况下dev-sidecar在“系统代理”开关打开时会自动设置代理。
如何打开查看windows代理设置
* win10: 开始->设置->网络和Internet->最下方代理
* win7: 开始->控制面板->网络和Internet->网络和共享中心->左下角Internet选项->连接选项卡->局域网设置
windows 代理查看
![windows](./doc/proxy.png)
mac 代理查看
![](./doc/mac-proxy.png)
### 3、浏览器打开提示证书不受信任
@ -268,7 +263,7 @@ DevSidecar Warning:
Error: www.github.com:443, 代理请求超时
```
如果是安全模式,则是因为不稳定导致的,等一会再刷新试试
如果是默认模式/增强模式,则是由于访问人数过多,正常现象
如果是增强模式,则是由于访问人数过多,正常现象
### 5、查看日志是否有报错
如果还是不行,请在下方加作者好友,将服务日志发送给作者进行分析
@ -279,14 +274,20 @@ Error: www.github.com:443, 代理请求超时
### 6、某些原本可以打开的网站打不开了
1、可以尝试关闭pac
2、可以将域名加入白名单设置方式参考https://github.com/docmirror/dev-sidecar/issues/25
2、可以将域名加入白名单
### 7、 git push报错
当git push的数据大于200k时会报错目前的方案不太好解决。
临时方案切到安全模式尝试git push多试几次就可以了
### 7、应用意外关闭导致没有网络了
应用开启后会自动修改系统代理设置,正常退出会自动关闭系统代理
当应用意外关闭时,可能会因为没有将系统代理恢复,从而导致完全无法上网
对于此问题有如下几种解决方案可供选择:
1、重新打开应用即可右键应用托盘图标可完全退出将会正常关闭系统代理设置
2、如果应用被卸载了此时需要[手动关闭系统代理设置](./doc/recover.md)
## 贡献代码
## 六、在其他程序使用
* [java程序使用](./doc/other.md#Java程序使用)
## 七、贡献代码
### 开发调试模式启动
@ -315,24 +316,24 @@ npm run electron:build
如果你想将你的修改贡献出来请提交pr
## 联系作者
## 八、联系作者
欢迎bug反馈需求建议技术交流等请备注dev-sidecar或简称DS
![](./doc/contact.png)
## 求star
## 九、求star
我的其他项目求star
* [fast-crud](https://github.com/fast-crud/fast-crud) : 开发crud快如闪电
* [certd](https://github.com/certd/certd) : 让你的证书永不过期
## 广告
## 十、广告
* [腾讯云企业老用户3折服务器](https://curl.qcloud.com/MRY91neQ)
* [腾讯云新用户大礼包](https://curl.qcloud.com/VQ2ARft2)
* [阿里云618](https://www.aliyun.com/activity/618/2021?userCode=qya11txb)
## 感谢
## 十一、感谢
本项目使用lerna包管理工具
[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lerna.js.org/)

34
doc/linux.md Normal file
View File

@ -0,0 +1,34 @@
# linux 支持
`linux`使用说明,目前仅支持`ubuntu_x64GNOME`,其他`linux`未测试
## 安装
### 1. ubuntu
* 下载`DevSidecar-x.x.x.deb`
* 执行命令安装 `dpkg -i DevSidecar-x.x.x.deb`
### 2. 其他linux系统未测试
* 下载 `DevSidecar-x.x.x.AppImage`
* 设置可执行权限 `sudo chmod +X DevSidecar-x.x.x.AppImage`
* 双击运行
## 证书安装
默认模式和增强模式需要系统信任CA证书。
由于linux上火狐和chrome都不走系统证书所以除了安装系统证书之外还需要给浏览器安装证书
### 1. 系统证书安装
根据弹出的提示:
* 点击首页右上角“安装根证书”按钮
* 点击“点此去安装”
* 提示安装成功即可
### 2. 火狐浏览器安装证书
* 火狐浏览器->选项->隐私与安全->证书->查看证书
* 证书颁发机构->导入
* 选择证书文件`C:\Users\Administrator\.dev-sidecar\dev-sidecar.ca.crt`Mac为`~/.dev-sidecar`目录)
* 勾选信任由此证书颁发机构来标识网站,确定即可
### 3. chrome浏览器安装证书
![](../packages/gui/public/setup-linux.png)

16
doc/other.md Normal file
View File

@ -0,0 +1,16 @@
# 其他程序使用
## Java程序使用
> 由[Enaium](https://github.com/Enaium) 提供,未做验证,可供参考
>
需要先通过keytool安装证书
`keytool -import -alias dev-sidecar -keystore "jdk路径\security\cacerts" -file 用户目录\.dev-sidecar\dev-sidecar.ca.crt`默认密码为`changeit`
启动时还需要设置参数
`-Dhttp.proxyHost=localhost -Dhttp.proxyPort=1181 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=1181`
Gradle还需在`用户目录/.gradle/gradle.properties`创建配置文件
```properties
systemProp.http.proxyHost=localhost
systemProp.http.proxyPort=1181
systemProp.https.proxyHost=localhost
systemProp.https.proxyPort=1181
```

20
doc/recover.md Normal file
View File

@ -0,0 +1,20 @@
# 卸载与恢复网络
由于应用启动后会自动设置系统代理,正常退出时会关闭系统代理。
当应用意外关闭,或者未正常退出后被卸载,此时会因为系统代理没有恢复从而导致完全上不了网。
## 恢复代理设置
### 1、windows 代理关闭
如何打开查看windows代理设置
* win10: 开始->设置->网络和Internet->最下方代理
* win7: 开始->控制面板->网络和Internet->网络和共享中心->左下角Internet选项->连接选项卡->局域网设置
![windows](./proxy.png)
### 2、mac 代理关闭
网络->网卡->代理->去掉http和https的两个勾
![](./mac-proxy.png)
### 3、LinuxUbuntu
网络->代理->选择禁用

View File

@ -14,5 +14,5 @@
"ignore": []
}
},
"version": "1.5.1"
"version": "1.6.0"
}

View File

@ -1,6 +1,6 @@
{
"name": "@docmirror/dev-sidecar",
"version": "1.5.1",
"version": "1.6.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "@docmirror/dev-sidecar",
"version": "1.5.1",
"version": "1.6.0",
"description": "给开发者的加速代理工具",
"main": "src/index.js",
"keywords": [
@ -17,7 +17,7 @@
"test": "mocha"
},
"dependencies": {
"@docmirror/mitmproxy": "^1.5.1",
"@docmirror/mitmproxy": "^1.6.0",
"agentkeepalive": "^2.1.1",
"babel-preset-es2020": "^1.0.2",
"charset": "^1.0.0",
@ -78,5 +78,5 @@
"last 2 versions",
"not dead"
],
"gitHead": "3566cd6d33cbe782d91e408d6f174dd826b2790f"
"gitHead": "9b027af3ee7e88975a54692ed83096802764a8dc"
}

View File

@ -38,24 +38,19 @@ module.exports = {
'github.com': {
'/.*/.*/releases/download/': {
redirect: 'download.fastgit.org',
desc: 'release文件加速下载跳转地址',
sni: 'baidu.com'
desc: 'release文件加速下载跳转地址'
},
'/.*/.*/archive/': {
redirect: 'download.fastgit.org',
sni: 'baidu.com'
redirect: 'download.fastgit.org'
},
'/.*/.*/blame/': {
redirect: 'hub.fastgit.org',
sni: 'baidu.com'
redirect: 'hub.fastgit.org'
},
'^/[^/]+/[^/]+(/releases(/.*)?)?$': {
script: [
'github'
],
desc: 'clone加速复制链接脚本',
sni: 'baidu.com'
desc: 'clone加速复制链接脚本'
},
'/.*': {
proxy: 'github.com',
@ -63,6 +58,46 @@ module.exports = {
desc: '目前禁掉sni就可以直接访问如果后续github.com的ip被封锁只能再走proxy模式',
sni: 'baidu.com'
}
// '/.*/.*/raw11/': {
// replace: '(.+)\\/raw\\/(.+)',
// proxy: 'raw.fastgit.org$1/$2',
// sni: 'baidu.com'
// }
},
'github-releases.githubusercontent.com': {
'.*': {
proxy: 'github-releases.githubusercontent.com',
sni: 'baidu.com'
}
},
'github.githubassets.com': {
'.*': {
proxy: 'github.githubassets.com',
sni: 'baidu.com'
}
},
'customer-stories-feed.github.com': {
'.*': { proxy: 'customer-stories-feed.fastgit.org' }
},
'raw.githubusercontent.com': {
'.*': {
proxy: 'raw.githubusercontent.com',
sni: 'baidu.com'
}
// '.*': { proxy: 'raw.fastgit.org' }
},
'user-images.githubusercontent.com': {
'.*': {
proxy: 'user-images.githubusercontent.com',
sni: 'baidu.com'
}
},
'avatars.githubusercontent.com': {
'.*': {
proxy: 'avatars.githubusercontent.com',
sni: 'baidu.com'
}
},
'api.github.com': {
'^/_private/browser/stats$': {
@ -70,23 +105,12 @@ module.exports = {
desc: 'github的访问速度分析上传没有必要直接返回成功'
}
},
'/.*/.*/raw11/': {
replace: '(.+)\\/raw\\/(.+)',
proxy: 'raw.fastgit.org$1/$2'
},
'raw.11githubusercontent.com': {
'.*': { proxy: 'raw.fastgit.org' }
},
// 'github.githubassets.com': {
// 'v2ex.com': {
// '.*': {
// proxy: 'assets-gh.docmirror.top/_proxy',
// test: 'https://github.githubassets.com/favicons/favicon.svg',
// desc: '静态资源加速'
// proxy: 'v2ex.com',
// sni: 'baidu.com'
// }
// },
'customer-stories-feed.github.com': {
'.*': { proxy: 'customer-stories-feed.fastgit.org' }
},
// google cdn
'www.google.com': {
'/recaptcha/.*': { proxy: 'www.recaptcha.net' }
@ -97,14 +121,15 @@ module.exports = {
},
'ajax.googleapis.com': {
'.*': {
proxy: 'ajax.loli.net',
proxy: 'ajax.lug.ustc.edu.cn',
backup: ['gapis.geekzu.org'],
test: 'ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js'
}
},
'fonts.googleapis.com': {
'.*': {
proxy: 'fonts.loli.net',
backup: ['fonts.proxy.ustclug.org'],
proxy: 'fonts.geekzu.org',
backup: ['fonts.loli.net'],
test: 'https://fonts.googleapis.com/css?family=Oswald'
}
},
@ -167,11 +192,6 @@ module.exports = {
server: 'https://dns.alidns.com/dns-query',
cacheSize: 1000
},
// ipaddress: {
// type: 'ipaddress',
// server: 'ipaddress',
// cacheSize: 1000
// },
usa: {
type: 'https',
server: 'https://1.1.1.1/dns-query',
@ -187,35 +207,28 @@ module.exports = {
server: 'https://rubyfish.cn/dns-query',
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: {
// 'assets.fastgit.org': 'usa',
'*amazonaws.com': 'quad9',
'*githubusercontent.com': 'quad9',
'*yarnpkg.com': 'usa',
'*cloudfront.net': 'usa',
'*github.io': 'usa',
'img.shields.io': 'usa',
'*.githubusercontent.com': 'usa',
'*.githubassets.com': 'usa',
'*yarnpkg.com': 'quad9',
'*cloudfront.net': 'quad9',
'*cloudflare.com': 'quad9',
'*github.io': 'quad9',
'img.shields.io': 'quad9',
'*.githubusercontent.com': 'quad9',
'*.githubassets.com': 'quad9',
// "解决push的时候需要输入密码的问题",
'github.com': 'quad9',
'*github.com': 'usa',
'*.vuepress.vuejs.org': 'usa',
'gh.docmirror.top': 'aliyun'
'*github.com': 'quad9',
'*.vuepress.vuejs.org': 'quad9',
'gh.docmirror.top': 'quad9',
'*v2ex.com': 'quad9'
},
speedTest: {
enabled: true,
interval: 160000,
interval: 60000,
hostnameList: ['github.com'],
dnsProviders: ['usa', 'quad9', 'rubyfish']
}

View File

@ -10,9 +10,9 @@ module.exports = {
}
},
targets: {
'*facebook.com': true,
'github.com': true,
'*wikimedia.org': true
'*wikimedia.org': true,
'v2ex.com': true
},
pac: {
enabled: true,

View File

@ -11,7 +11,7 @@ if (JSON5.default) {
JSON5 = JSON5.default
}
let server
let server = null
function fireStatus (status) {
event.fire('status', { key: 'server.enabled', value: status })
}
@ -79,6 +79,18 @@ const serverApi = {
serverProcess.send({ type: 'action', event: { key: 'close' } })
}
}
serverProcess.on('beforeExit', (code) => {
log.warn('server process beforeExit', code)
})
serverProcess.on('SIGPIPE', (code, signal) => {
log.warn('server process SIGPIPE', code, signal)
})
serverProcess.on('exit', (code, signal) => {
log.warn('server process exit', code, signal)
})
serverProcess.on('uncaughtException', (err, origin) => {
log.error('server process uncaughtException', err)
})
serverProcess.on('message', function (msg) {
log.info('收到子进程消息', msg.type, msg.event.key)
if (msg.type === 'status') {

View File

@ -9,10 +9,11 @@ const executor = {
return true
},
async linux (exec, { port }) {
throw Error('暂未实现此功能')
await exec('kill `lsof -i:' + port + " |grep 'dev-sidecar\\|electron\\|@docmirro' |awk '{print $2}'`")
return true
},
async mac (exec, { port }) {
await exec('kill `lsof -i:' + port + " |grep 'DevSide\\|Elect' |awk '{print $2}'`")
await exec('kill `lsof -i:' + port + " |grep 'dev-side\\|Elect' |awk '{print $2}'`")
return true
}
}

View File

@ -152,10 +152,25 @@ const executor = {
if (params == null) {
await exec(`networksetup -setwebproxystate '${wifiAdaptor}' off`)
await exec(`networksetup -setsecurewebproxystate '${wifiAdaptor}' off`)
// const removeEnv = `
// sed -ie '/export http_proxy/d' ~/.zshrc
// sed -ie '/export https_proxy/d' ~/.zshrc
// source ~/.zshrc
// `
// await exec(removeEnv)
} else {
const { ip, port } = params
await exec(`networksetup -setwebproxy '${wifiAdaptor}' ${ip} ${port}`)
await exec(`networksetup -setsecurewebproxy '${wifiAdaptor}' ${ip} ${port}`)
// const setEnv = `cat <<ENDOF >> ~/.zshrc
// export http_proxy="http://${ip}:${port}"
// export https_proxy="http://${ip}:${port}"
// ENDOF
// source ~/.zshrc
// `
// await exec(setEnv)
}
}
}

View File

@ -3,7 +3,7 @@
autoStart: {
enabled: true,
},
mode: 'safe',
mode: 'default',
},
plugin: {
node: {
@ -24,8 +24,12 @@
},
},
server: {
intercept: {
enabled: false,
intercepts: {
'dev-sidecar.docmirror.cn': {
'.*': {
proxy: 'dev-sidecar-preview.docmirror.cn',
},
},
},
},
}
}

2
packages/gui/.env Normal file
View File

@ -0,0 +1,2 @@
VUE_APP_PUBLISH_URL=http://dev-sidecar.docmirror.cn/update/
VUE_APP_PUBLISH_PROVIDER=generic

View File

@ -21,7 +21,8 @@ pnpm-debug.log*
*.njsproj
*.sln
*.sw?
*.lock
*.log
#Electron-builder output
/dist_electron
/config

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 264 KiB

After

Width:  |  Height:  |  Size: 353 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -3919,9 +3919,9 @@ gigporno.ru
!--wsgzao.github.io
!--|https://wsgzao.github.io
.github.io
||github.io
||githubusercontent.com
||githubassets.com
!||github.io
!||githubusercontent.com
!||githubassets.com
.gizlen.net
||gizlen.net

View File

@ -1,8 +1,9 @@
{
"name": "@docmirror/dev-sidecar-gui",
"version": "1.5.1",
"version": "1.6.0",
"private": false,
"license": "MPL-2.0",
"main": "background.js",
"scripts": {
"serve": "vue-cli-service serve",
"lint": "vue-cli-service lint",
@ -13,11 +14,14 @@
"electron:icons": "electron-icon-builder --input=./public/logo/win.png --output=build --flatten",
"electron:icons-mac": "electron-icon-builder --input=./public/logo/mac.png --output=build --flatten"
},
"author": "Greper",
"main": "background.js",
"homepage": "https://github.com/docmirror/dev-sidecar",
"author": {
"email": "xiaojunnuo@qq.com",
"name": "Greper"
},
"dependencies": {
"@docmirror/dev-sidecar": "^1.5.1",
"@docmirror/mitmproxy": "^1.5.1",
"@docmirror/dev-sidecar": "^1.6.0",
"@docmirror/mitmproxy": "^1.6.0",
"adm-zip": "^0.5.5",
"ant-design-vue": "^1.6.5",
"compressing": "^1.5.1",
@ -40,22 +44,21 @@
"vue-router": "^3.4.8"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/eslint-config-standard": "^5.1.2",
"electron-icon-builder": "^1.0.2",
"babel-eslint": "^10.1.0",
"electron": "13.1.9",
"electron-devtools-installer": "^3.1.0",
"electron-icon-builder": "^2.0.1",
"eslint": "^6.7.2",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"json5-loader": "^4.0.1",
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"babel-eslint": "^10.1.0",
"electron": "^13.0.0",
"electron-devtools-installer": "^3.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"json5-loader": "^4.0.1",
"vue-cli-plugin-electron-builder": "~2.1.1",
"vue-template-compiler": "^2.6.11"
},
@ -79,5 +82,5 @@
"not dead"
],
"__npminstall_done": false,
"gitHead": "3566cd6d33cbe782d91e408d6f174dd826b2790f"
}
"gitHead": "9b027af3ee7e88975a54692ed83096802764a8dc"
}

View File

@ -3,19 +3,26 @@ const pkg = require('../package.json')
const fs = require('fs')
function appendIntro (context, systemType, latest) {
const partUpdateFile = `update-${systemType}-${pkg.version}.zip`
const version = pkg.version
const partUpdateFile = `update-${systemType}-${version}.zip`
const partUpdateUrl = context.configuration.publish.url + partUpdateFile
const latestFilePath = path.join(context.outDir, latest)
fs.appendFile(latestFilePath, `\npartPackage: ${partUpdateUrl}\nreleaseNotes: \n - 升级日志`, (err) => {
fs.appendFile(latestFilePath, `partPackage: ${partUpdateUrl}
releaseNotes:
- 升级日志
- https://download.fastgit.org/docmirror/dev-sidecar/releases/download/v${version}/DevSidecar-${version}.exe
`,
(err) => {
if (err) {
console.log('修改latest 失败')
}
})
}
exports.default = async function (context) {
// console.log('context222', context)
console.log('after-all-artifact-build')
appendIntro(context, 'mac', 'latest-mac.yml')
appendIntro(context, 'win', 'latest.yml')
appendIntro(context, 'linux', 'latest-linux.yml')
}

View File

@ -1,6 +1,22 @@
const path = require('path')
const AdmZip = require('adm-zip')
const pkg = require('../package.json')
const fs = require('fs')
function writeAppUpdateYmlForLinux () {
const publishUrl = process.env.VUE_APP_PUBLISH_URL
const publishProvider = process.env.VUE_APP_PUBLISH_PROVIDER
// provider: generic
// url: 'http://dev-sidecar.docmirror.cn/update/preview/'
// updaterCacheDirName: '@docmirrordev-sidecar-gui-updater'
const fileContent = `provider: ${publishProvider}
url: '${publishUrl}'
updaterCacheDirName: '@docmirrordev-sidecar-gui-updater'
`
console.log('write linux app-update.yml,updateUrl:', publishUrl)
const filePath = path.resolve('./dist_electron/linux-unpacked/resources/app-update.yml')
fs.writeFileSync(filePath, fileContent)
}
exports.default = async function (context) {
// console.log('context', context)
let targetPath
@ -8,6 +24,10 @@ exports.default = async function (context) {
if (context.packager.platform.nodeName === 'darwin') {
targetPath = path.join(context.appOutDir, `${context.packager.appInfo.productName}.app/Contents/Resources`)
systemType = 'mac'
} else if (context.packager.platform.nodeName === 'linux') {
targetPath = path.join(context.appOutDir, './resources')
systemType = 'linux'
writeAppUpdateYmlForLinux()
} else {
targetPath = path.join(context.appOutDir, './resources')
systemType = 'win'

View File

@ -34,6 +34,7 @@ function setTray (app) {
// 系统托盘图标目录
label: '退出',
click: () => {
console.log('force quit')
forceClose = true
quit(app)
}
@ -83,7 +84,7 @@ function isLinux () {
function hideWin () {
if (win) {
if (isLinux()) {
win.minimize()
quit(app)
} else {
win.hide()
}
@ -193,6 +194,7 @@ if (!isFirstInstance) {
// Quit when all windows are closed.
app.on('window-all-closed', () => {
console.log('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') {
@ -257,3 +259,9 @@ if (isDevelopment) {
})
}
}
// 系统关机和重启时的操作
process.on('exit', function () {
log.info('进程结束退出app')
quit(app)
})

View File

@ -1,3 +1,29 @@
import DevSidecar from '@docmirror/dev-sidecar'
async function setAutoStartForLinux (app, enable = true) {
const path = app.getPath('exe')
if (enable) {
const cmd = `
mkdir -p ~/.config/autostart/
cat >> ~/.config/autostart/dev-sidecar.desktop <<EOF
[Desktop Entry]
Type=Application
Exec=${path}
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=DevSidecar
Name=DevSidecar
Comment[en_US]=
Comment=
EOF
`
await DevSidecar.api.shell.exec(cmd)
} else {
const removeStart = 'sudo rm ~/.config/autostart/dev-sidecar.desktop -rf'
await DevSidecar.api.shell.exec(removeStart)
}
}
export default {
install (context) {
const { ipcMain, dialog, log, app } = context
@ -7,23 +33,34 @@ export default {
// 定义事件,渲染进程中直接使用
// 开启 开机自启动
ipcMain.on('auto-start', (event, message) => {
console.log('updateExe', ex)
ipcMain.on('auto-start', async (event, message) => {
console.log('auto start', message)
const isLinux = DevSidecar.api.shell.getSystemPlatform() === 'linux'
if (message.value) {
app.setLoginItemSettings({
openAtLogin: true,
path: ex,
args: [
'--hideWindow', '"true"'
]
})
if (isLinux) {
await setAutoStartForLinux(app, true)
} else {
app.setLoginItemSettings({
openAtLogin: true,
path: ex,
args: [
'--process-start-args', '"--hidden"'
]
})
}
event.sender.send('auto-start', { key: 'enabled', value: true })
} else {
app.setLoginItemSettings({
openAtLogin: false,
path: ex,
args: []
})
if (isLinux) {
await setAutoStartForLinux(app, false)
} else {
app.setLoginItemSettings({
openAtLogin: false,
path: ex,
args: []
})
}
event.sender.send('auto-start', { key: 'enabled', value: false })
}
})

View File

@ -10,8 +10,10 @@ import logger from '../../utils/util.log'
import appPathUtil from '../../utils/util.apppath'
// eslint-disable-next-line no-unused-vars
const isMac = process.platform === 'darwin'
const isLinux = process.platform === 'linux'
function downloadFile (uri, filePath, onProgress, onSuccess, onError) {
logger.info('download url', uri)
progress(request(uri), {
// throttle: 2000, // Throttle the progress event to 2000ms, defaults to 1000ms
// delay: 1000, // Only start to emit after 1000ms delay, defaults to 0ms
@ -47,17 +49,22 @@ function updateHandle (app, api, win, beforeQuit, quit, log) {
updateNotAva: '当前为最新版本,无需更新'
}
// 本地开发环境改变app-update.yml地址
if (process.env.NODE_ENV === 'development' && !isMac) {
autoUpdater.setFeedURL({
provider: 'generic',
url: 'http://localhost/dev-sidecar/'
})
if (process.env.NODE_ENV === 'development') {
// const publishUrl = process.env.VUE_APP_PUBLISH_URL
// autoUpdater.setFeedURL({
// provider: 'generic',
// url: publishUrl
// })
if (isMac) {
autoUpdater.updateConfigPath = path.join(__dirname, 'mac/DevSidecar.app/Contents/Resources/app-update.yml')
autoUpdater.updateConfigPath = path.join(__dirname, 'mac/dev-sidecar.app/Contents/Resources/app-update.yml')
} else if (isLinux) {
autoUpdater.updateConfigPath = path.join(__dirname, 'linux-unpacked/resources/app-update.yml')
} else {
autoUpdater.updateConfigPath = path.join(__dirname, 'win-unpacked/resources/app-update.yml')
}
}
logger.info('auto updater', autoUpdater.getFeedURL())
autoUpdater.autoDownload = false
let partPackagePath = null
@ -96,6 +103,8 @@ function updateHandle (app, api, win, beforeQuit, quit, log) {
if (platform === 'mac') {
target = path.join(appPath, 'Resources')
}
const length = fs.statSync(partPackagePath)
log.info('安装包大小:', length)
log.info('开始解压缩,安装升级包', partPackagePath, target)

View File

@ -1,4 +1,3 @@
function install (app, api) {
const updateParams = app.$global.update = { fromUser: false, autoDownload: false, progress: 0, downloading: false, newVersion: false, isFullUpdate: true }
api.ipc.on('update', (event, message) => {
@ -55,26 +54,45 @@ function install (app, api) {
updateParams.progress = value
}
function downloadNewVersion (value) {
function goManualUpdate (value) {
app.$confirm({
title: '暂不支持自动升级',
cancelText: '取消',
okText: '确定',
content: h => {
function openGithubUrl () {
api.ipc.openExternal('https://github.com/docmirror/dev-sidecar/releases')
}
function openGiteeUrl () {
api.ipc.openExternal('https://gitee.com/docmirror/dev-sidecar/releases')
}
return <div>
<div>请前往github或gitee项目release页面下载新版本手动安装</div>
<ol>
<li><a onClick={openGithubUrl}>Github release</a></li>
<li><a onClick={openGiteeUrl}>Gitee release</a></li>
</ol>
</div>
}
})
}
async function downloadNewVersion (value) {
const platform = await api.shell.getSystemPlatform()
console.log('download new version platform', platform)
if (platform === 'linux') {
goManualUpdate(app, value)
return
}
if (value.partPackage) {
// 有增量更新
api.update.downloadPart(value)
} else {
api.shell.getSystemPlatform().then((platform) => {
if (platform === 'mac') {
app.$notification.open({
duration: 15,
message: 'Mac暂不支持全量自动升级',
description:
'请前往github或gitee项目release页面下载新版本手动安装',
onClick: () => {
}
})
return
}
api.update.downloadUpdate()
})
if (platform === 'mac') {
goManualUpdate(value)
return
}
updateParams.downloading = true
api.update.downloadUpdate()
}
}
function foundNewVersion (value) {
@ -82,7 +100,7 @@ function install (app, api) {
if (updateParams.autoDownload !== false) {
app.$message.info('发现新版本,正在下载中...')
updateParams.downloading = true
downloadNewVersion(value)
return
}
@ -127,11 +145,9 @@ function install (app, api) {
}
},
onOk () {
console.log('OK')
api.update.doUpdateNow()
},
onCancel () {
console.log('Cancel')
}
})
}

View File

@ -1,11 +1,26 @@
import path from 'path'
const isDevelopment = process.env.NODE_ENV !== 'production'
export default {
getAppRootPath (app) {
if (isDevelopment) {
return app.getAppPath()
} else {
return path.join(app.getAppPath(), '../../')
}
import os from 'os'
function getSystemPlatform () {
switch (os.platform()) {
case 'darwin':
return 'mac'
case 'linux':
return 'linux'
case 'win32':
return 'windows'
case 'win64':
return 'windows'
case 'unknown os':
default:
throw new Error(`UNKNOWN OS TYPE ${os.platform()}`)
}
}
export default {
getAppRootPath (app) {
const exePath = app.getPath('exe')
if (getSystemPlatform() === 'mac') {
return path.join(exePath, '../../')
}
return path.join(exePath, '../')
}
}

View File

@ -1,6 +1,8 @@
const path = require('path')
const webpack = require('webpack')
const publishUrl = process.env.VUE_APP_PUBLISH_URL
const publishProvider = process.env.VUE_APP_PUBLISH_PROVIDER
console.log('publish url', publishUrl)
module.exports = {
pages: {
index: {
@ -8,7 +10,7 @@ module.exports = {
title: 'DevSidecar-给开发者的边车辅助工具'
}
},
configureWebpack: config => {
configureWebpack: (config) => {
const configNew = {
plugins: [
new webpack.DefinePlugin({ 'global.GENTLY': true })
@ -37,6 +39,7 @@ module.exports = {
builderOptions: {
afterPack: './pkg/after-pack.js',
afterAllArtifactBuild: './pkg/after-all-artifact-build.js',
// artifactBuildCompleted: './pkg/artifact-build-completed.js',
// builderOptions: {
// publish: ['github']// 此处写入github 就好,不用添加其他内容
// },
@ -47,7 +50,7 @@ module.exports = {
}
],
appId: 'dev-sidecar',
productName: 'DevSidecar',
productName: 'dev-sidecar',
// eslint-disable-next-line no-template-curly-in-string
artifactName: 'DevSidecar-${version}.${ext}',
copyright: 'Copyright © 2020-2021 Greper',
@ -58,14 +61,25 @@ module.exports = {
allowToChangeInstallationDirectory: true
},
mac: {
icon: 'build/mac/icon.icns'
icon: './build/mac/icon.icns',
target: [
'dmg'
]
},
win: {
icon: 'build/icons/',
requestedExecutionLevel: 'requireAdministrator'
},
linux: {
icon: 'build/mac/',
target: [
'deb',
'AppImage'
]
},
publish: {
provider: 'generic',
url: 'http://dev-sidecar.docmirror.cn/update/'
provider: publishProvider,
url: publishUrl
// url: 'http://dev-sidecar.docmirror.cn/update/preview/'
}
},

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "@docmirror/mitmproxy",
"version": "1.5.1",
"version": "1.6.0",
"description": "",
"main": "src/index.js",
"keywords": [
@ -66,5 +66,5 @@
"last 2 versions",
"not dead"
],
"gitHead": "3566cd6d33cbe782d91e408d6f174dd826b2790f"
"gitHead": "9b027af3ee7e88975a54692ed83096802764a8dc"
}

View File

@ -34,9 +34,17 @@ function registerProcessListener () {
log.info('Unhandled Rejection at: Promise', p, 'err:', err)
// application specific logging, throwing an error, or other logic here
})
process.on('exit', function (code) {
log.info('代理服务进程被关闭:', code)
process.on('uncaughtExceptionMonitor', (err, origin) => {
log.info('uncaughtExceptionMonitor:', err, origin)
})
process.on('exit', function (code, signal) {
log.info('代理服务进程被关闭:', code, signal)
})
process.on('beforeExit', (code, signal) => {
console.log('Process beforeExit event with code: ', code, signal)
})
process.on('SIGPIPE', (code, signal) => {
log.warn('sub Process SIGPIPE', code, signal)
})
}

View File

@ -28,13 +28,20 @@ module.exports = {
}
}
let proxyTarget = proxyConf + req.url
let uri = req.url
if (uri.indexOf('http') === 0) {
// eslint-disable-next-line node/no-deprecated-api
const URL = url.parse(uri)
uri = URL.path
}
let proxyTarget = proxyConf + uri
if (interceptOpt.replace) {
const regexp = new RegExp(interceptOpt.replace)
proxyTarget = req.url.replace(regexp, proxyConf)
}
// eslint-disable-next-line
// no-template-curly-in-string
// eslint-disable-next-line no-template-curly-in-string
proxyTarget = proxyTarget.replace('${host}', rOptions.hostname)
// const backup = interceptOpt.backup
@ -49,7 +56,7 @@ module.exports = {
if (URL.port == null) {
rOptions.port = rOptions.protocol === 'https:' ? 443 : 80
}
log.info('proxy:', rOptions.hostname, proxyTarget)
log.info('proxy:', rOptions.hostname, 'target', proxyTarget)
if (context.requestCount) {
log.debug('proxy choice:', JSON.stringify(context.requestCount))
}

View File

@ -0,0 +1,13 @@
module.exports = {
requestIntercept (context, interceptOpt) {
const { rOptions } = context
if (interceptOpt.sni != null) {
rOptions.servername = interceptOpt.sni
console.log('sni replace', rOptions.hostname, rOptions.servername)
}
return true
},
is (interceptOpt) {
return !!interceptOpt.sni
}
}

View File

@ -3,6 +3,7 @@ const redirect = require('./impl/redirect')
const abort = require('./impl/abort')
const success = require('./impl/success')
const script = require('./impl/script')
const modules = [proxy, redirect, abort, script, success]
const sni = require('./impl/sni')
const modules = [proxy, redirect, abort, script, success, sni]
module.exports = modules

View File

@ -6,7 +6,6 @@ const DnsUtil = require('../../dns/index')
const log = require('../../../utils/util.log')
const RequestCounter = require('../../choice/RequestCounter')
const InsertScriptMiddleware = require('../middleware/InsertScriptMiddleware')
const OverWallMiddleware = require('../middleware/overwall')
const speedTest = require('../../speed/index.js')
const defaultDns = require('dns')
const MAX_SLOW_TIME = 8000 // 超过此时间 则认为太慢了
@ -54,7 +53,7 @@ module.exports = function createRequestHandler (createIntercepts, middlewares, e
if (!reqIncpt.requestIntercept) {
continue
}
const goNext = reqIncpt.requestIntercept(context, req, res, ssl, next)
const goNext = reqIncpt.requestIntercept(context, req, res, ssl)
if (goNext) {
next()
return

View File

@ -31,7 +31,6 @@ function testCa() {
process.env.NODE_EXTRA_CA_CERTS = 'C:\\Users\\Administrator\\.dev-sidecar\\dev-sidecar.ca.crt'
process.env.GLOBAL_AGENT_HTTP_PROXY = "http://127.0.0.1:1181"
process.env.GLOBAL_AGENT_HTTPS_PROXY = "http://127.0.0.1:1181"
console.log('111', process.env.NODE_EXTRA_CA_CERTS)
const options = {
agent : new https.Agent({

File diff suppressed because it is too large Load Diff

5083
yarn.lock

File diff suppressed because it is too large Load Diff