From d21c7534eb1ac0a568148eaee46ad64de9c55735 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 28 May 2026 12:25:42 +0000 Subject: [PATCH 1/2] Initial plan From c36ec8e3486a1c9b23dda3d873c2ba4bfb6325d6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 28 May 2026 12:29:46 +0000 Subject: [PATCH 2/2] fix(windows): initialize winsock before proxy hostname validation --- Windows/src/ProxyBridge.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Windows/src/ProxyBridge.c b/Windows/src/ProxyBridge.c index 7a21d5d..e955455 100644 --- a/Windows/src/ProxyBridge.c +++ b/Windows/src/ProxyBridge.c @@ -2566,12 +2566,29 @@ PROXYBRIDGE_API BOOL ProxyBridge_MoveRuleToPosition(UINT32 rule_id, UINT32 new_p PROXYBRIDGE_API BOOL ProxyBridge_SetProxyConfig(ProxyType type, const char* proxy_ip, UINT16 proxy_port, const char* username, const char* password) { + WSADATA wsa_data; + BOOL winsock_initialized = FALSE; + if (proxy_ip == NULL || proxy_ip[0] == '\0' || proxy_port == 0) return FALSE; + // Hostname validation may happen before ProxyBridge_Start initializes Winsock. + // Initialize Winsock here so hostnames like "localhost" resolve reliably. + if (WSAStartup(MAKEWORD(2, 2), &wsa_data) == 0) + { + winsock_initialized = TRUE; + } + else + { + return FALSE; + } + // Validate that the hostname/IP can be resolved if (resolve_hostname(proxy_ip) == 0) + { + WSACleanup(); return FALSE; + } strncpy_s(g_proxy_host, sizeof(g_proxy_host), proxy_ip, _TRUNCATE); g_proxy_port = proxy_port; @@ -2596,6 +2613,11 @@ PROXYBRIDGE_API BOOL ProxyBridge_SetProxyConfig(ProxyType type, const char* prox g_proxy_password[0] = '\0'; } + if (winsock_initialized) + { + WSACleanup(); + } + return TRUE; }