MCPcopy
hub / github.com/docmirror/dev-sidecar / linux

Function linux

packages/core/src/shell/scripts/set-system-proxy/index.js:454–486  ·  view source on GitHub ↗
(exec, params = {})

Source from the content-addressed store, hash-verified

452 }
453 },
454 async linux (exec, params = {}) {
455 const { ip, port } = params
456 if (ip != null) { // 设置代理
457 // 延迟加载config
458 loadConfig()
459
460 // https
461 const setProxyCmd = [
462 'gsettings set org.gnome.system.proxy mode manual',
463 `gsettings set org.gnome.system.proxy.https host ${ip}`,
464 `gsettings set org.gnome.system.proxy.https port ${port}`,
465 ]
466 // http
467 if (config.get().proxy.proxyHttp) {
468 setProxyCmd.push(`gsettings set org.gnome.system.proxy.http host ${ip}`)
469 setProxyCmd.push(`gsettings set org.gnome.system.proxy.http port ${port - 1}`)
470 } else {
471 setProxyCmd.push('gsettings set org.gnome.system.proxy.http host \'\'')
472 setProxyCmd.push('gsettings set org.gnome.system.proxy.http port 0')
473 }
474
475 // 设置排除域名(ignore-hosts)
476 const excludeIpStr = getProxyExcludeIpStr('\', \'')
477 setProxyCmd.push(`gsettings set org.gnome.system.proxy ignore-hosts "['${excludeIpStr}']"`)
478
479 await exec(setProxyCmd)
480 } else { // 关闭代理
481 const setProxyCmd = [
482 'gsettings set org.gnome.system.proxy mode none',
483 ]
484 await exec(setProxyCmd)
485 }
486 },
487 async mac (exec, params = {}) {
488 const wifiAdaptor = await getMacNetworkService(exec)
489 const { ip, port } = params

Callers

nothing calls this directly

Calls 4

loadConfigFunction · 0.85
getProxyExcludeIpStrFunction · 0.85
execFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected