diff --git a/launch/core/platforms/windows.py b/launch/core/platforms/windows.py index 28c146e..745126e 100644 --- a/launch/core/platforms/windows.py +++ b/launch/core/platforms/windows.py @@ -21,6 +21,20 @@ import queue import uuid + +# Go integration tests use ``fakerepo`` as a deliberately unreachable local +# registry. Keep it off the evaluator's outbound proxy so the test observes +# the expected direct socket error instead of a proxy-generated EOF. +DEFAULT_WINDOWS_CONTAINER_NO_PROXY = "localhost,127.0.0.1,::1,fakerepo" + + +def get_windows_container_no_proxy() -> str: + """Return the container proxy bypass list, honoring an explicit override.""" + return os.environ.get( + "SWE_WINDOWS_CONTAINER_NO_PROXY", DEFAULT_WINDOWS_CONTAINER_NO_PROXY + ) + + import docker from docker.models.containers import Container @@ -159,6 +173,14 @@ def _start_container( detach=True, environment={ "TERM": "xterm-mono", + # The proxy is optional. When enabled, ensure local test + # endpoints still use direct networking semantics. + **({ + "HTTP_PROXY": os.environ.get("SWE_WINDOWS_CONTAINER_PROXY"), + "HTTPS_PROXY": os.environ.get("SWE_WINDOWS_CONTAINER_PROXY"), + "ALL_PROXY": os.environ.get("SWE_WINDOWS_CONTAINER_PROXY"), + "NO_PROXY": get_windows_container_no_proxy(), + } if os.environ.get("SWE_WINDOWS_CONTAINER_PROXY") else {}), }, working_dir=working_dir, extra_hosts=extra_hosts, diff --git a/tests/runtime_test.py b/tests/runtime_test.py index 809ec3d..b50cd41 100644 --- a/tests/runtime_test.py +++ b/tests/runtime_test.py @@ -49,7 +49,11 @@ from launch.core.runtime import SetupRuntime from launch.core.platforms.linux import LinuxRuntime -from launch.core.platforms.windows import WindowsRuntime +from launch.core.platforms.windows import ( + DEFAULT_WINDOWS_CONTAINER_NO_PROXY, + WindowsRuntime, + get_windows_container_no_proxy, +) from launch.core.platforms.android import AndroidRuntime #from launch.core.platforms.macos import MacosRuntime @@ -66,6 +70,15 @@ class FakeSocket: pass +def test_windows_container_no_proxy_default_and_override(monkeypatch): + monkeypatch.delenv("SWE_WINDOWS_CONTAINER_NO_PROXY", raising=False) + assert get_windows_container_no_proxy() == DEFAULT_WINDOWS_CONTAINER_NO_PROXY + assert "fakerepo" in DEFAULT_WINDOWS_CONTAINER_NO_PROXY.split(",") + + monkeypatch.setenv("SWE_WINDOWS_CONTAINER_NO_PROXY", "custom.local") + assert get_windows_container_no_proxy() == "custom.local" + + class FakeContainer: def __init__(self, sock: FakeSocket): self.sock = sock