(exec, params = {})
| 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 |
nothing calls this directly
no test coverage detected