Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/services/agent-environment/proxy-environment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,34 @@ describe('buildProxyEnvironment', () => {
expect(env.NO_PROXY.split(',')).toContain('awmg-cli-proxy');
});

it('strips port suffix from difcProxyHost', () => {
const env = run({
...baseConfig,
networkIsolation: true,
difcProxyHost: 'awmg-cli-proxy:8443',
});
expect(env.NO_PROXY.split(',')).toContain('awmg-cli-proxy');
expect(env.NO_PROXY.split(',')).not.toContain('awmg-cli-proxy:8443');
});

it('strips scheme and port from a scheme-prefixed difcProxyHost', () => {
const env = run({
...baseConfig,
networkIsolation: true,
difcProxyHost: 'https://proxy.internal:443',
});
expect(env.NO_PROXY.split(',')).toContain('proxy.internal');
});

it('strips brackets and port from a bracketed IPv6 difcProxyHost', () => {
const env = run({
...baseConfig,
networkIsolation: true,
difcProxyHost: '[::1]:18443',
});
expect(env.NO_PROXY.split(',')).toContain('::1');
});

it('does NOT exempt topology peers outside network-isolation mode', () => {
const env = run({
...baseConfig,
Expand Down
9 changes: 9 additions & 0 deletions src/services/agent-environment/proxy-environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { WrapperConfig } from '../../types';
import { NetworkConfig } from '../squid-service';
import { buildNoProxyValue } from '../no-proxy-utils';
import { runtimeUsesIptables, runtimeUsesComposeAgent } from '../../container-runtime';
import { parseDifcProxyHost } from '../../host-env';

interface ProxyEnvironmentParams {
config: WrapperConfig;
Expand Down Expand Up @@ -35,6 +36,14 @@ export function buildProxyEnvironment(params: ProxyEnvironmentParams): void {
if (config.topologyAttach) {
noProxyHosts.push(...config.topologyAttach);
}
// The DIFC/cli-proxy host is addressed by proxy-aware clients directly and
// must bypass Squid even when it isn't listed in topologyAttach.
// Use parseDifcProxyHost to correctly strip scheme prefixes and handle
// bracketed IPv6 (e.g. https://proxy.internal:443, [::1]:18443), since
// undici matches NO_PROXY against the hostname only.
if (config.difcProxyHost) {
noProxyHosts.push(parseDifcProxyHost(config.difcProxyHost).host);
}
}

// The MCP gateway is served on the network gateway (e.g. 172.30.0.1). In
Expand Down
Loading