MCPcopy Index your code
hub / github.com/coder/coder / Server

Struct Server

enterprise/aibridgeproxyd/aibridgeproxyd.go:122–150  ·  view source on GitHub ↗

Server is the AI MITM (Man-in-the-Middle) proxy server. It is responsible for: - intercepting HTTPS requests to AI providers - decrypting requests using the configured MITM CA certificate - forwarding requests to aibridged for processing

Source from the content-addressed store, hash-verified

120// - decrypting requests using the configured MITM CA certificate
121// - forwarding requests to aibridged for processing
122type Server struct {
123 ctx context.Context
124 logger slog.Logger
125 proxy *goproxy.ProxyHttpServer
126 httpServer *http.Server
127 listener net.Listener
128 tlsEnabled bool
129 coderAccessURL *url.URL
130 // coderAccessPort is the resolved port for the Coder access URL.
131 coderAccessPort string
132 // refreshProviders fetches the live provider snapshot on Reload.
133 // Nil disables hot-reload.
134 refreshProviders RefreshProvidersFunc
135 // providerRouter holds the live (mitmHosts, nameByHost) pair.
136 providerRouter atomic.Pointer[providerRouter]
137 // allowedPorts is the port allowlist for CONNECT requests. Fixed at
138 // construction; not reloadable.
139 allowedPorts []string
140 // caCert is the PEM-encoded MITM CA certificate loaded during initialization.
141 // This is served to clients who need to trust the proxy's generated certificates.
142 caCert []byte
143 // allowedPrivateRanges are CIDR ranges exempt from the blocked IP denylist.
144 allowedPrivateRanges []net.IPNet
145 // newDumper creates a RoundTripDumper for a given provider and request
146 // ID. Nil when dumping is disabled.
147 newDumper func(provider, requestID string) RoundTripDumper
148 // Metrics is the Prometheus metrics for the proxy. If nil, metrics are disabled.
149 metrics *Metrics
150}
151
152// providerRouter keeps CONNECT matching and provider lookup in sync.
153type providerRouter struct {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected