- Зачем:
- домашний Gitea стал рабочим репозиторием и трекером вместо
заблокированного GitHub, а через прокси соединение с ним рвётся на TLS.
- Что:
- в DEFAULT_NO_PROXY_EXTRA добавлены dementev.space и .dementev.space
(две формы, так как программы читают список по-разному).
- тот же домен внесён в копии списка: profile.ps1, запускалки
claude/codex, .codex/.env и server-env-setup для VS Code.
- Проверка:
- proxy-client env | grep -i no_proxy — домен виден в обеих переменных.
- python3 tests/test_proxy_client.py (54 OK), bash tests/test_proxy_launchers.sh (8 PASS).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
125 lines
3.7 KiB
PowerShell
125 lines
3.7 KiB
PowerShell
$ErrorActionPreference = 'Stop'
|
|
|
|
$ProxyHostName = 'hproxy.local'
|
|
$ProxyPort = 12334
|
|
$HttpProxy = "http://${ProxyHostName}:${ProxyPort}"
|
|
$ProxyBypassList = "${ProxyHostName};localhost;127.0.0.1;[::1];*.concept-software.ru;dementev.space;*.dementev.space"
|
|
|
|
function Get-CodexApplication {
|
|
$Package = Get-AppxPackage -Name 'OpenAI.Codex' -ErrorAction SilentlyContinue |
|
|
Select-Object -First 1
|
|
|
|
if ($null -eq $Package) {
|
|
throw 'Codex Windows App is not installed. Expected AppX package: OpenAI.Codex.'
|
|
}
|
|
|
|
$Manifest = Get-AppxPackageManifest $Package
|
|
$Application = @($Manifest.Package.Applications.Application) | Select-Object -First 1
|
|
if ($null -eq $Application -or [string]::IsNullOrWhiteSpace($Application.Executable)) {
|
|
throw 'Codex Windows App manifest does not contain an executable entry.'
|
|
}
|
|
|
|
$Executable = Join-Path $Package.InstallLocation ([string]$Application.Executable)
|
|
if (-not (Test-Path -LiteralPath $Executable)) {
|
|
throw "Codex Windows App executable was not found: $Executable"
|
|
}
|
|
|
|
[PSCustomObject]@{
|
|
AppUserModelId = "$($Package.PackageFamilyName)!$([string]$Application.Id)"
|
|
Executable = $Executable
|
|
}
|
|
}
|
|
|
|
function Assert-CodexNotRunning {
|
|
param(
|
|
[Parameter(Mandatory)]
|
|
[string]$Executable
|
|
)
|
|
|
|
$RunningProcess = Get-CimInstance Win32_Process -ErrorAction SilentlyContinue |
|
|
Where-Object { $_.ExecutablePath -eq $Executable } |
|
|
Select-Object -First 1
|
|
|
|
if ($null -ne $RunningProcess) {
|
|
throw 'Codex уже запущен. Полностью закройте приложение и повторно откройте ярлык Codex Proxy.'
|
|
}
|
|
}
|
|
|
|
function Start-CodexApplication {
|
|
param(
|
|
[Parameter(Mandatory)]
|
|
[string]$AppUserModelId,
|
|
|
|
[Parameter(Mandatory)]
|
|
[string]$Arguments
|
|
)
|
|
|
|
if (-not ('CodexProxyLauncher.ApplicationActivationManager' -as [type])) {
|
|
Add-Type -TypeDefinition @'
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace CodexProxyLauncher
|
|
{
|
|
[Flags]
|
|
public enum ActivateOptions : uint
|
|
{
|
|
None = 0
|
|
}
|
|
|
|
[ComImport]
|
|
[Guid("2e941141-7f97-4756-ba1d-9decde894a3d")]
|
|
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
|
public interface IApplicationActivationManager
|
|
{
|
|
[PreserveSig]
|
|
int ActivateApplication(
|
|
[MarshalAs(UnmanagedType.LPWStr)] string appUserModelId,
|
|
[MarshalAs(UnmanagedType.LPWStr)] string arguments,
|
|
ActivateOptions options,
|
|
out uint processId);
|
|
}
|
|
|
|
[ComImport]
|
|
[Guid("45BA127D-10A8-46EA-8AB7-56EA9078943C")]
|
|
public class ApplicationActivationManager
|
|
{
|
|
}
|
|
|
|
public static class ApplicationActivator
|
|
{
|
|
public static uint Activate(string appUserModelId, string arguments)
|
|
{
|
|
IApplicationActivationManager manager =
|
|
(IApplicationActivationManager)new ApplicationActivationManager();
|
|
|
|
uint processId;
|
|
int hResult = manager.ActivateApplication(
|
|
appUserModelId,
|
|
arguments,
|
|
ActivateOptions.None,
|
|
out processId);
|
|
|
|
Marshal.ThrowExceptionForHR(hResult);
|
|
return processId;
|
|
}
|
|
}
|
|
}
|
|
'@
|
|
}
|
|
|
|
[CodexProxyLauncher.ApplicationActivator]::Activate(
|
|
$AppUserModelId,
|
|
$Arguments
|
|
)
|
|
}
|
|
|
|
$CodexApplication = Get-CodexApplication
|
|
Assert-CodexNotRunning -Executable $CodexApplication.Executable
|
|
|
|
$CodexArguments = "--proxy-server=${HttpProxy} --proxy-bypass-list=${ProxyBypassList}"
|
|
Start-CodexApplication `
|
|
-AppUserModelId $CodexApplication.AppUserModelId `
|
|
-Arguments $CodexArguments |
|
|
Out-Null
|