Skip to content

Commit

Permalink
fix: system proxy setting
Browse files Browse the repository at this point in the history
  • Loading branch information
starknt committed Nov 26, 2024
1 parent 6573752 commit 448fd07
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 20 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"test": "mocha"
},
"dependencies": {
"@mihomo-party/sysproxy": "^2.0.4",
"@starknt/sysproxy": "^0.0.1",
"@vscode/sudo-prompt": "^9.3.1",
"fix-path": "^3.0.0",
"iconv-lite": "^0.6.3",
Expand Down
14 changes: 11 additions & 3 deletions packages/core/src/shell/scripts/set-system-proxy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,25 @@ function getProxyExcludeIpStr (split) {

const executor = {
async windows (exec, params = {}) {
const sysproxy = require('@mihomo-party/sysproxy')
const sysproxy = require('@starknt/sysproxy')

const { ip, port, setEnv } = params
if (ip != null) { // 设置代理
// 延迟加载config
loadConfig()
log.info('设置windows系统代理:', ip, port, setEnv)

// https
let proxyAddr = `https=http://${ip}:${port}`
// http
if (config.get().proxy.proxyHttp) {
proxyAddr = `http=http://${ip}:${port - 1};${proxyAddr}`
}

// 读取排除域名
const excludeIpStr = getProxyExcludeIpStr(';')

sysproxy.triggerManualProxy(true, ip, port, excludeIpStr)
// 设置代理,同时设置排除域名
sysproxy.triggerManualProxyByUrl(true, proxyAddr, excludeIpStr)

if (setEnv) {
// 设置全局代理所需的环境变量
Expand Down
2 changes: 1 addition & 1 deletion packages/gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"dependencies": {
"@docmirror/dev-sidecar": "workspace:*",
"@docmirror/mitmproxy": "workspace:*",
"@mihomo-party/sysproxy": "^2.0.4",
"@natmri/platform-napi": "^0.0.7",
"@starknt/sysproxy": "^0.0.1",
"@vscode/sudo-prompt": "^9.3.1",
"adm-zip": "^0.5.16",
"ant-design-vue": "^1.7.8",
Expand Down
16 changes: 8 additions & 8 deletions packages/gui/vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ module.exports = defineConfig({
// Ref: https://github.com/nklayman/vue-cli-plugin-electron-builder/issues/1891
customFileProtocol: './',
externals: [
'@mihomo-party/sysproxy',
'@mihomo-party/sysproxy-win32-ia32-msvc',
'@mihomo-party/sysproxy-win32-x64-msvc',
'@mihomo-party/sysproxy-win32-arm64-msvc',
'@mihomo-party/sysproxy-linux-x64-gnu',
'@mihomo-party/sysproxy-linux-arm64-gnu',
'@mihomo-party/sysproxy-darwin-x64',
'@mihomo-party/sysproxy-darwin-arm64',
'@starknt/sysproxy',
'@starknt/sysproxy-win32-ia32-msvc',
'@starknt/sysproxy-win32-x64-msvc',
'@starknt/sysproxy-win32-arm64-msvc',
'@starknt/sysproxy-linux-x64-gnu',
'@starknt/sysproxy-linux-arm64-gnu',
'@starknt/sysproxy-darwin-x64',
'@starknt/sysproxy-darwin-arm64',
'@natmri/platform-napi',
'@natmri/platform-napi-win32-ia32-msvc',
'@natmri/platform-napi-win32-x64-msvc',
Expand Down
81 changes: 74 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 448fd07

Please sign in to comment.