Spaces:
Paused
Paused
Merge pull request #15 from icebear0828/fix/docker-proxy-detection
Browse files- CHANGELOG.md +1 -0
- docker-compose.yml +2 -0
- src/tls/curl-binary.ts +19 -9
CHANGELOG.md
CHANGED
|
@@ -36,6 +36,7 @@
|
|
| 36 |
- `ClaudeCodeSetup.tsx` 文件名与导出名不一致,重命名为 `AnthropicSetup.tsx`
|
| 37 |
- Dashboard 模型偏好从硬编码 `gpt-5.2-codex` 改为使用 `codex` 别名
|
| 38 |
- 构建脚本 `vite build --root web` 兼容性问题,改用 `npm run build:web`
|
|
|
|
| 39 |
|
| 40 |
## [v0.8.0](https://github.com/icebear0828/codex-proxy/releases/tag/v0.8.0) - 2026-02-24
|
| 41 |
|
|
|
|
| 36 |
- `ClaudeCodeSetup.tsx` 文件名与导出名不一致,重命名为 `AnthropicSetup.tsx`
|
| 37 |
- Dashboard 模型偏好从硬编码 `gpt-5.2-codex` 改为使用 `codex` 别名
|
| 38 |
- 构建脚本 `vite build --root web` 兼容性问题,改用 `npm run build:web`
|
| 39 |
+
- Docker 容器内代理自动检测失败:`detectLocalProxy()` 现在同时探测 `127.0.0.1`(裸机)和 `host.docker.internal`(Docker 容器→宿主机),零配置即生效
|
| 40 |
|
| 41 |
## [v0.8.0](https://github.com/icebear0828/codex-proxy/releases/tag/v0.8.0) - 2026-02-24
|
| 42 |
|
docker-compose.yml
CHANGED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
services:
|
| 2 |
codex-proxy:
|
| 3 |
build: .
|
|
|
|
|
|
|
| 4 |
ports:
|
| 5 |
- "${PORT:-8080}:8080"
|
| 6 |
volumes:
|
|
|
|
| 1 |
services:
|
| 2 |
codex-proxy:
|
| 3 |
build: .
|
| 4 |
+
extra_hosts:
|
| 5 |
+
- "host.docker.internal:host-gateway"
|
| 6 |
ports:
|
| 7 |
- "${PORT:-8080}:8080"
|
| 8 |
volumes:
|
src/tls/curl-binary.ts
CHANGED
|
@@ -187,12 +187,20 @@ const PROXY_PORTS = [
|
|
| 187 |
{ port: 10808, proto: "socks5" },// v2ray SOCKS5
|
| 188 |
];
|
| 189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
let _proxyUrl: string | null | undefined; // undefined = not yet detected
|
| 191 |
|
| 192 |
-
/** Probe a TCP port on
|
| 193 |
-
function probePort(port: number, timeoutMs = 500): Promise<boolean> {
|
| 194 |
return new Promise((resolve) => {
|
| 195 |
-
const sock = createConnection({ host
|
| 196 |
sock.destroy();
|
| 197 |
resolve(true);
|
| 198 |
});
|
|
@@ -203,15 +211,17 @@ function probePort(port: number, timeoutMs = 500): Promise<boolean> {
|
|
| 203 |
}
|
| 204 |
|
| 205 |
/**
|
| 206 |
-
* Detect a local proxy by probing common ports.
|
| 207 |
* Called once at startup, result is cached.
|
| 208 |
*/
|
| 209 |
async function detectLocalProxy(): Promise<string | null> {
|
| 210 |
-
for (const
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
|
|
|
|
|
|
| 215 |
}
|
| 216 |
}
|
| 217 |
return null;
|
|
|
|
| 187 |
{ port: 10808, proto: "socks5" },// v2ray SOCKS5
|
| 188 |
];
|
| 189 |
|
| 190 |
+
/**
|
| 191 |
+
* Hosts to probe for proxy detection.
|
| 192 |
+
* 127.0.0.1 — bare-metal / host machine.
|
| 193 |
+
* host.docker.internal — Docker container → host machine
|
| 194 |
+
* (DNS lookup fails on bare-metal → ENOTFOUND → handled by error callback, <5ms).
|
| 195 |
+
*/
|
| 196 |
+
const PROXY_HOSTS = ["127.0.0.1", "host.docker.internal"];
|
| 197 |
+
|
| 198 |
let _proxyUrl: string | null | undefined; // undefined = not yet detected
|
| 199 |
|
| 200 |
+
/** Probe a TCP port on the given host. Resolves true if a server is listening. */
|
| 201 |
+
function probePort(host: string, port: number, timeoutMs = 500): Promise<boolean> {
|
| 202 |
return new Promise((resolve) => {
|
| 203 |
+
const sock = createConnection({ host, port }, () => {
|
| 204 |
sock.destroy();
|
| 205 |
resolve(true);
|
| 206 |
});
|
|
|
|
| 211 |
}
|
| 212 |
|
| 213 |
/**
|
| 214 |
+
* Detect a local proxy by probing common ports on localhost and Docker host.
|
| 215 |
* Called once at startup, result is cached.
|
| 216 |
*/
|
| 217 |
async function detectLocalProxy(): Promise<string | null> {
|
| 218 |
+
for (const host of PROXY_HOSTS) {
|
| 219 |
+
for (const { port, proto } of PROXY_PORTS) {
|
| 220 |
+
if (await probePort(host, port)) {
|
| 221 |
+
const url = `${proto}://${host}:${port}`;
|
| 222 |
+
console.log(`[Proxy] Auto-detected local proxy: ${url}`);
|
| 223 |
+
return url;
|
| 224 |
+
}
|
| 225 |
}
|
| 226 |
}
|
| 227 |
return null;
|