| 91 | } |
| 92 | |
| 93 | async function parseWindowsProxySettings() { |
| 94 | try { |
| 95 | const regedit = require('regedit'); |
| 96 | const path = require('path'); |
| 97 | const isProduction = (process as any).mainModule?.filename?.includes('app.asar'); |
| 98 | if (isProduction) { |
| 99 | const scriptPath = path.join((process as any).resourcesPath, 'assets', 'vbs'); |
| 100 | regedit.setExternalVBSLocation(scriptPath); |
| 101 | } |
| 102 | const key = "HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings" |
| 103 | const proxySettings = (await regedit.promisified.list(key))[key].values; |
| 104 | |
| 105 | const ret = { |
| 106 | enabled: proxySettings.ProxyEnable.value, |
| 107 | server: proxySettings.ProxyServer.value, |
| 108 | override: proxySettings.ProxyOverride.value |
| 109 | }; |
| 110 | |
| 111 | if (ret.enabled && ret.server) { |
| 112 | const server = "http://" + ret.server; |
| 113 | systemProxy.all_proxy = server; |
| 114 | systemProxy.http_proxy = server; |
| 115 | systemProxy.https_proxy = server; |
| 116 | } |
| 117 | |
| 118 | } catch (err: any) { |
| 119 | logger.error("get system proxy error" + err.message + err.stack) |
| 120 | console.log("read error", err); |
| 121 | } |
| 122 | } |