@askalf/dario 4.8.34 → 4.8.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/proxy.js +25 -0
  2. package/package.json +1 -1
package/dist/proxy.js CHANGED
@@ -4,6 +4,7 @@ import { execSync } from 'node:child_process';
4
4
  import { readFileSync, readdirSync, createWriteStream } from 'node:fs';
5
5
  import { join } from 'node:path';
6
6
  import { homedir } from 'node:os';
7
+ import { setDefaultResultOrder } from 'node:dns';
7
8
  import { arch, platform } from 'node:process';
8
9
  import { getAccessToken, getStatus } from './oauth.js';
9
10
  import { buildCCRequest, parseEffortSuffix, reverseMapResponse, createStreamingReverseMapper, orderHeadersForOutbound, CC_TEMPLATE } from './cc-template.js';
@@ -452,6 +453,30 @@ export async function startProxy(opts = {}) {
452
453
  const host = opts.host ?? process.env.DARIO_HOST ?? DEFAULT_HOST;
453
454
  const verbose = opts.verbose ?? false;
454
455
  const passthrough = opts.passthrough ?? false;
456
+ // DNS result order — prefer IPv4 for the Anthropic upstream by default.
457
+ // api.anthropic.com publishes both A and AAAA records. In a container with
458
+ // no IPv6 egress (e.g. a default Docker bridge network), Node's `verbatim`
459
+ // order tries the AAAA address first → ENETUNREACH/hang → every upstream
460
+ // fetch times out ("Proxy error: The operation timed out") and the proxy is
461
+ // effectively dead while /health still returns 200. Defaulting to ipv4first
462
+ // makes Node resolve to the reachable A record (IPv4 to api.anthropic.com is
463
+ // universally routable). Override with DARIO_DNS_RESULT_ORDER=verbatim or
464
+ // ipv6first on IPv6-only / dual-stack hosts. (Node built-in fetch/undici
465
+ // honors dns.setDefaultResultOrder.)
466
+ const dnsOrder = (process.env.DARIO_DNS_RESULT_ORDER ?? 'ipv4first').trim();
467
+ if (dnsOrder === 'ipv4first' || dnsOrder === 'ipv6first' || dnsOrder === 'verbatim') {
468
+ try {
469
+ setDefaultResultOrder(dnsOrder);
470
+ if (verbose)
471
+ console.error(`[dario] dns result order: ${dnsOrder}`);
472
+ }
473
+ catch (e) {
474
+ console.error(`[dario] could not set dns result order (${dnsOrder}): ${e instanceof Error ? e.message : String(e)}`);
475
+ }
476
+ }
477
+ else {
478
+ console.error(`[dario] ignoring invalid DARIO_DNS_RESULT_ORDER='${dnsOrder}' (use ipv4first | ipv6first | verbatim)`);
479
+ }
455
480
  // TLS-fingerprint axis (v3.23, direction #3). Proxy mode terminates TLS
456
481
  // to api.anthropic.com from this process; if we're not on Bun, the
457
482
  // ClientHello that reaches Anthropic is Node's OpenSSL shape, not CC's
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askalf/dario",
3
- "version": "4.8.34",
3
+ "version": "4.8.35",
4
4
  "description": "Use your Claude Pro/Max subscription in any tool — Cursor, Cline, Aider, the Agent SDK, your scripts — at subscription pricing, not per-token API bills. One local Anthropic + OpenAI-compatible endpoint.",
5
5
  "type": "module",
6
6
  "bin": {