chore(debug): add proxyman proxy debugging tools
This commit is contained in:
1 parent
87c17a1ed0
commit
e9c4f72883
3 files changed
+178
No files matched your search
Vendored
+24
@@ -12,6 +12,30 @@
|
||||
"outFiles": ["${workspaceFolder}/.vite/build/**/*.js"],
|
||||
"console": "integratedTerminal",
|
||||
"autoAttachChildProcesses": true
|
||||
},
|
||||
{
|
||||
"name": "Debug Main Process (Proxyman)",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"runtimeExecutable": "cmd.exe",
|
||||
"runtimeArgs": ["/c", "npm", "run", "start"],
|
||||
"sourceMaps": true,
|
||||
"outFiles": ["${workspaceFolder}/.vite/build/**/*.js"],
|
||||
"console": "integratedTerminal",
|
||||
"autoAttachChildProcesses": true,
|
||||
"env": {
|
||||
"NODE_USE_ENV_PROXY": "1",
|
||||
"HTTP_PROXY": "http://127.0.0.1:9090",
|
||||
"HTTPS_PROXY": "http://127.0.0.1:9090",
|
||||
"ALL_PROXY": "http://127.0.0.1:9090",
|
||||
"NO_PROXY": "localhost,127.0.0.1,::1",
|
||||
"ELECTRON_PROXY_SERVER": "http://127.0.0.1:9090",
|
||||
"ELECTRON_PROXY_BYPASS_LIST": "<local>;localhost;127.0.0.1;::1",
|
||||
"DEBUG_PROXY_TRACE": "1",
|
||||
"NODE_EXTRA_CA_CERTS": "C:\\Users\\Administrator\\AppData\\Roaming\\Proxyman\\certificate\\certs\\ca.pem",
|
||||
"NODE_TLS_REJECT_UNAUTHORIZED": "0"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
# Starts the installed Antigravity app with Proxyman proxy settings for local debugging.
|
||||
#
|
||||
# Usage:
|
||||
# powershell -ExecutionPolicy Bypass -File .\scripts\start-antigravity-with-proxyman.ps1
|
||||
# powershell -ExecutionPolicy Bypass -File .\scripts\start-antigravity-with-proxyman.ps1 -Port 9090 -AllowInsecureTls
|
||||
#
|
||||
# Notes:
|
||||
# - This script is intended for local debugging only.
|
||||
# - It terminates existing Antigravity processes first so the new environment variables take effect.
|
||||
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[int]$Port = 9090,
|
||||
[string]$ProxyHost = '127.0.0.1',
|
||||
[string]$AppPath = 'C:\Users\Administrator\AppData\Local\Programs\Antigravity\Antigravity.exe',
|
||||
[string]$CaPath = 'C:\Users\Administrator\AppData\Roaming\Proxyman\certificate\certs\ca.pem',
|
||||
[string]$NoProxy = 'localhost,127.0.0.1,::1',
|
||||
[switch]$AllowInsecureTls,
|
||||
[switch]$KeepExisting
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
function Write-ColorLine {
|
||||
param(
|
||||
[string]$Color,
|
||||
[string]$Message
|
||||
)
|
||||
|
||||
Write-Host $Message -ForegroundColor $Color
|
||||
}
|
||||
|
||||
function Info {
|
||||
param([string]$Message)
|
||||
|
||||
Write-ColorLine -Color 'Cyan' -Message "[INFO] $Message"
|
||||
}
|
||||
|
||||
function Success {
|
||||
param([string]$Message)
|
||||
|
||||
Write-ColorLine -Color 'Green' -Message "[OK] $Message"
|
||||
}
|
||||
|
||||
function Warn {
|
||||
param([string]$Message)
|
||||
|
||||
Write-ColorLine -Color 'Yellow' -Message "[WARN] $Message"
|
||||
}
|
||||
|
||||
function Fail {
|
||||
param([string]$Message)
|
||||
|
||||
Write-ColorLine -Color 'Red' -Message "[ERROR] $Message"
|
||||
exit 1
|
||||
}
|
||||
|
||||
$proxyUrl = "http://${ProxyHost}:${Port}"
|
||||
$proxyBypassList = '<local>;localhost;127.0.0.1;::1'
|
||||
|
||||
if (-not (Test-Path -LiteralPath $AppPath)) {
|
||||
Fail "Antigravity executable not found: $AppPath"
|
||||
}
|
||||
|
||||
if (-not (Test-Path -LiteralPath $CaPath)) {
|
||||
Fail "Proxyman CA file not found: $CaPath"
|
||||
}
|
||||
|
||||
Info "Proxy URL: $proxyUrl"
|
||||
Info "Antigravity path: $AppPath"
|
||||
Info "CA path: $CaPath"
|
||||
|
||||
if (-not $KeepExisting) {
|
||||
$existingProcesses = Get-Process -Name 'Antigravity' -ErrorAction SilentlyContinue
|
||||
if ($existingProcesses) {
|
||||
Warn "Stopping existing Antigravity processes so the new proxy environment takes effect..."
|
||||
$existingProcesses | Stop-Process -Force
|
||||
Start-Sleep -Milliseconds 800
|
||||
} else {
|
||||
Info 'No running Antigravity process found.'
|
||||
}
|
||||
} else {
|
||||
Warn 'KeepExisting enabled; existing Antigravity processes were not terminated.'
|
||||
}
|
||||
|
||||
$env:HTTP_PROXY = $proxyUrl
|
||||
$env:HTTPS_PROXY = $proxyUrl
|
||||
$env:ALL_PROXY = $proxyUrl
|
||||
$env:NO_PROXY = $NoProxy
|
||||
$env:ELECTRON_PROXY_SERVER = $proxyUrl
|
||||
$env:ELECTRON_PROXY_BYPASS_LIST = $proxyBypassList
|
||||
$env:NODE_EXTRA_CA_CERTS = $CaPath
|
||||
|
||||
if ($AllowInsecureTls) {
|
||||
$env:NODE_TLS_REJECT_UNAUTHORIZED = '0'
|
||||
Warn 'NODE_TLS_REJECT_UNAUTHORIZED=0 is enabled for this launch. Use for debugging only.'
|
||||
} else {
|
||||
Remove-Item Env:NODE_TLS_REJECT_UNAUTHORIZED -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
Info 'Starting Antigravity with Proxyman proxy settings...'
|
||||
$process = Start-Process -FilePath $AppPath -ArgumentList @(
|
||||
"--proxy-server=$proxyUrl",
|
||||
"--proxy-bypass-list=$proxyBypassList"
|
||||
) -WorkingDirectory (Split-Path -Parent $AppPath) -PassThru
|
||||
|
||||
Success "Antigravity started. PID: $($process.Id)"
|
||||
Write-Host ''
|
||||
Write-Host 'Environment used for this launch:' -ForegroundColor Gray
|
||||
Write-Host " HTTP_PROXY=$($env:HTTP_PROXY)" -ForegroundColor Gray
|
||||
Write-Host " HTTPS_PROXY=$($env:HTTPS_PROXY)" -ForegroundColor Gray
|
||||
Write-Host " NO_PROXY=$($env:NO_PROXY)" -ForegroundColor Gray
|
||||
Write-Host " NODE_EXTRA_CA_CERTS=$($env:NODE_EXTRA_CA_CERTS)" -ForegroundColor Gray
|
||||
if ($AllowInsecureTls) {
|
||||
Write-Host ' NODE_TLS_REJECT_UNAUTHORIZED=0' -ForegroundColor Gray
|
||||
}
|
||||
Write-Host ''
|
||||
Write-Host 'If Proxyman still does not show traffic, verify that no older Antigravity instance is still alive.' -ForegroundColor Gray
|
||||
+36
@@ -4,6 +4,7 @@ import type { MessageBoxOptions } from 'electron';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import squirrelStartup from 'electron-squirrel-startup';
|
||||
import { EnvHttpProxyAgent, setGlobalDispatcher } from 'undici';
|
||||
|
||||
import { ipcMain } from 'electron/main';
|
||||
import { ipcContext } from '@/ipc/context';
|
||||
@@ -57,6 +58,41 @@ if (squirrelStartup) {
|
||||
}
|
||||
|
||||
const inDevelopment = process.env.NODE_ENV === 'development';
|
||||
const debugHttpProxy = process.env.http_proxy?.trim() || process.env.HTTP_PROXY?.trim();
|
||||
const debugHttpsProxy = process.env.https_proxy?.trim() || process.env.HTTPS_PROXY?.trim();
|
||||
const debugNoProxy = process.env.no_proxy?.trim() || process.env.NO_PROXY?.trim();
|
||||
const debugProxyServer =
|
||||
process.env.ELECTRON_PROXY_SERVER?.trim() || debugHttpsProxy || debugHttpProxy;
|
||||
const debugProxyBypassList =
|
||||
process.env.ELECTRON_PROXY_BYPASS_LIST?.trim() || '<local>;localhost;127.0.0.1;::1';
|
||||
|
||||
function configureDebugProxy() {
|
||||
if (debugHttpProxy || debugHttpsProxy) {
|
||||
setGlobalDispatcher(
|
||||
new EnvHttpProxyAgent({
|
||||
httpProxy: debugHttpProxy,
|
||||
httpsProxy: debugHttpsProxy,
|
||||
noProxy: debugNoProxy,
|
||||
}),
|
||||
);
|
||||
logger.info(
|
||||
`[Debug Proxy] Node fetch proxy enabled (http: ${debugHttpProxy ?? 'none'}, https: ${debugHttpsProxy ?? 'none'}, no_proxy: ${debugNoProxy ?? 'none'})`,
|
||||
);
|
||||
}
|
||||
|
||||
if (!debugProxyServer) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Route Chromium traffic through the local debug proxy while keeping local dev servers direct.
|
||||
app.commandLine.appendSwitch('proxy-server', debugProxyServer);
|
||||
app.commandLine.appendSwitch('proxy-bypass-list', debugProxyBypassList);
|
||||
logger.info(
|
||||
`[Debug Proxy] Electron proxy enabled: ${debugProxyServer} (bypass: ${debugProxyBypassList})`,
|
||||
);
|
||||
}
|
||||
|
||||
configureDebugProxy();
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
|
||||
Reference in new issue
Block a user