| 107 | } |
| 108 | |
| 109 | export async function setSystemProxy(port: number) { |
| 110 | logger.info('try to set system proxy', PROXY_CONF_HELPER_PATH); |
| 111 | if (port === 0) { |
| 112 | if (SYSTEM_IS_MACOS) { |
| 113 | execSync(`'${PROXY_CONF_HELPER_PATH}' -m off`); |
| 114 | } else { |
| 115 | return globalProxy |
| 116 | .disable() |
| 117 | .then(stdout => { |
| 118 | console.log(stdout); |
| 119 | execSync(PROXY_REFRESH_WINDOWS_HELPER_PATH); |
| 120 | }) |
| 121 | .catch(error => { |
| 122 | console.log(error); |
| 123 | }); |
| 124 | } |
| 125 | return; |
| 126 | } |
| 127 | if (SYSTEM_IS_MACOS) { |
| 128 | const output = execSync( |
| 129 | `'${PROXY_CONF_HELPER_PATH}' -m global -p ${port} -r ${port} -s 127.0.0.1 -x "*.lan, *.ali.com, *.hz.ali.com, *.symantacliveupdate.com, *.symantac.com, irmaagent.effirst.com:8080"`, |
| 130 | ); |
| 131 | logger.info('stdout', output.toString()); |
| 132 | } else { |
| 133 | return globalProxy |
| 134 | .enable('127.0.0.1', port, 'http') |
| 135 | .then(stdout => { |
| 136 | console.log(stdout); |
| 137 | execSync(PROXY_REFRESH_WINDOWS_HELPER_PATH); |
| 138 | }) |
| 139 | .catch(error => { |
| 140 | console.log(error); |
| 141 | }); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | export async function hideOrQuit() { |
| 146 | if (SYSTEM_IS_MACOS) { |