MCPcopy
hub / github.com/codeaashu/claude-code / getSandboxProxyConfig

Function getSandboxProxyConfig

src/utils/hooks/execHttpHook.ts:21–41  ·  view source on GitHub ↗

* Get the sandbox proxy config for routing HTTP hook requests through the * sandbox network proxy when sandboxing is enabled. * * Uses dynamic import to avoid a static import cycle * (sandbox-adapter -> settings -> ... -> hooks -> execHttpHook).

()

Source from the content-addressed store, hash-verified

19 * (sandbox-adapter -> settings -> ... -> hooks -> execHttpHook).
20 */
21async function getSandboxProxyConfig(): Promise<
22 { host: string; port: number; protocol: string } | undefined
23> {
24 const { SandboxManager } = await import('../sandbox/sandbox-adapter.js')
25
26 if (!SandboxManager.isSandboxingEnabled()) {
27 return undefined
28 }
29
30 // Wait for the sandbox network proxy to finish initializing. In REPL mode,
31 // SandboxManager.initialize() is fire-and-forget so the proxy may not be
32 // ready yet when the first hook fires.
33 await SandboxManager.waitForNetworkInitialization()
34
35 const proxyPort = SandboxManager.getProxyPort()
36 if (!proxyPort) {
37 return undefined
38 }
39
40 return { host: '127.0.0.1', port: proxyPort, protocol: 'http' }
41}
42
43/**
44 * Read HTTP hook allowlist restrictions from merged settings (all sources).

Callers 1

execHttpHookFunction · 0.85

Calls 3

isSandboxingEnabledMethod · 0.80
getProxyPortMethod · 0.80

Tested by

no test coverage detected