()
| 185 | * Get the current proxy configuration based on VS Code settings and extension mode. |
| 186 | */ |
| 187 | export function getProxyConfig(): ProxyConfig { |
| 188 | const defaultServerUrl = "http://127.0.0.1:8888" |
| 189 | |
| 190 | if (!extensionContext) { |
| 191 | // Fallback if called before initialization |
| 192 | return { |
| 193 | enabled: false, |
| 194 | serverUrl: defaultServerUrl, |
| 195 | tlsInsecure: false, |
| 196 | isDebugMode: false, |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | const config = vscode.workspace.getConfiguration(Package.name) |
| 201 | const enabled = Boolean(config.get<unknown>("debugProxy.enabled")) |
| 202 | const rawServerUrl = config.get<unknown>("debugProxy.serverUrl") |
| 203 | const serverUrl = typeof rawServerUrl === "string" && rawServerUrl.trim() ? rawServerUrl.trim() : defaultServerUrl |
| 204 | const tlsInsecure = Boolean(config.get<unknown>("debugProxy.tlsInsecure")) |
| 205 | |
| 206 | // Debug mode only. |
| 207 | const isDebugMode = extensionContext.extensionMode === vscode.ExtensionMode.Development |
| 208 | |
| 209 | return { |
| 210 | enabled, |
| 211 | serverUrl, |
| 212 | tlsInsecure, |
| 213 | isDebugMode, |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | /** |
| 218 | * Configure global-agent to route all HTTP/HTTPS traffic through the proxy. |
no test coverage detected