Skip to content

Commit 474516b

Browse files
committed
Implement system proxy resolution for Windows and add support for PAC URLs
- Introduced a new module for Windows system proxy resolution, implementing the `resolve` and `resolve_pac` functions. - Added logic to handle automatic detection of proxy settings and parsing of static proxy configurations. - Implemented callback handling for asynchronous proxy resolution using WinHTTP. - Added tests for PAC options and auto-detection behavior. - Created utility functions for validating and parsing proxy directives.
1 parent 7d42e4b commit 474516b

24 files changed

Lines changed: 3544 additions & 166 deletions

File tree

i18n/locales/en.json

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,22 @@
7878
"ConfigRecovered": "Proxy settings were safely recovered to Direct",
7979
"Retry": "Retry",
8080
"EnableProxy": "Enable proxy",
81-
"EnabledDescription": "JumpServer API and background OAuth requests use the proxy configured below.",
81+
"EnabledDescription": "Choose a system proxy, PAC, or manual proxy for JumpServer API and background OAuth requests.",
8282
"DisabledDescription": "The proxy is off. Supported requests connect directly to JumpServer.",
83-
"ManualSettings": "Proxy settings",
83+
"ProxySource": "Proxy source",
84+
"SystemProxy": "System proxy",
85+
"SystemProxyDescription": "Use operating system manual proxy, PAC, or WPAD settings. The route is resolved for each target.",
86+
"PacProxy": "PAC",
87+
"PacProxyUnavailableLinux": "PAC (unavailable on Linux)",
88+
"PacProxyDescription": "Use the specified PAC file to choose a direct or proxy route for each target.",
89+
"PacProxyUnsupportedLinuxDescription": "Explicit PAC URLs are unavailable on Linux. System proxy can still inherit PAC settings from the desktop.",
90+
"ManualProxy": "Manual proxy",
91+
"ManualProxyDescription": "Use the HTTP or SOCKS5 proxy configured below.",
92+
"PacSettings": "PAC settings",
93+
"PacUrl": "PAC URL",
94+
"PacUrlDescription": "Only HTTP or HTTPS URLs without a username or password are supported.",
95+
"PacUrlPlaceholder": "https://proxy.example.com/proxy.pac",
96+
"ManualSettings": "Manual proxy settings",
8497
"ProxyType": "Proxy type",
8598
"Host": "Host",
8699
"HostPlaceholder": "proxy.example.com or IP address",
@@ -99,16 +112,30 @@
99112
"BypassDescription": "Enter one host, domain, IP, or CIDR per line or separate entries with commas. Local addresses always bypass the proxy.",
100113
"BypassPlaceholder": "localhost\n127.0.0.0/8\n.internal.example.com",
101114
"TestTitle": "Connection test",
102-
"TestDescription": "Enter a JumpServer site origin. The app requests a fixed well-known endpoint. When the proxy is enabled, a target matched by the bypass list is not treated as a successful proxy test.",
115+
"TestDescriptionDirect": "Enter a JumpServer site origin to test a direct connection to its fixed well-known endpoint.",
116+
"TestDescriptionSystem": "Enter a JumpServer site origin. The app resolves the operating system proxy or PAC route for that target before testing the fixed well-known endpoint.",
117+
"TestDescriptionPac": "Enter a JumpServer site origin. The app uses the specified PAC file to resolve that target before testing the fixed well-known endpoint.",
118+
"TestDescriptionManual": "Enter a JumpServer site origin to test the manual proxy against its fixed well-known endpoint. A target matched by the bypass list does not test the proxy.",
103119
"TargetUrl": "JumpServer site address",
104120
"TestConnection": "Test connection",
105121
"TestSucceeded": "Connection succeeded",
106122
"TestFailed": "Connection failed",
123+
"ResolverDirect": "Direct",
124+
"ResolverSystem": "System proxy",
125+
"ResolverPac": "PAC",
126+
"ResolverManual": "Manual proxy",
127+
"ResolverBypass": "Bypass list",
128+
"RouteDirect": "Direct",
129+
"RouteProxy": "Via proxy",
130+
"FallbackRoutesUsed": "Used {count} fallback route(s)",
107131
"Save": "Save",
108132
"SaveSucceeded": "Saved and confirmed by the backend",
109133
"SaveFailedWithReason": "Save failed: {reason}",
110134
"ReadbackFailedWithReason": "The settings were submitted, but backend confirmation failed: {reason}",
111135
"Errors": {
136+
"PacUrlRequired": "Enter the PAC URL.",
137+
"PacUrlTooLong": "The PAC URL cannot exceed 2048 characters.",
138+
"InvalidPacUrl": "Enter an HTTP or HTTPS URL without a username or password.",
112139
"HostRequired": "Enter the proxy host.",
113140
"HostTooLong": "The proxy host cannot exceed 255 characters.",
114141
"InvalidHost": "Enter a host name or IP address without a scheme, path, or credentials.",

i18n/locales/zh.json

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,22 @@
7878
"ConfigRecovered": "代理配置已安全恢复为直连",
7979
"Retry": "重试",
8080
"EnableProxy": "启用代理",
81-
"EnabledDescription": "JumpServer API 和 OAuth 后台请求将使用下方配置的代理",
81+
"EnabledDescription": "JumpServer API 和 OAuth 后台请求选择系统代理、PAC 或手动代理",
8282
"DisabledDescription": "代理已关闭,相关请求将直接连接 JumpServer。",
83-
"ManualSettings": "代理配置",
83+
"ProxySource": "代理来源",
84+
"SystemProxy": "系统代理",
85+
"SystemProxyDescription": "使用操作系统的手动代理、PAC 或 WPAD 设置;应用会按目标地址解析实际路径。",
86+
"PacProxy": "PAC",
87+
"PacProxyUnavailableLinux": "PAC(Linux 不可用)",
88+
"PacProxyDescription": "使用指定的 PAC 文件,按目标地址选择直连或代理。",
89+
"PacProxyUnsupportedLinuxDescription": "Linux 暂不支持应用内指定 PAC URL;系统代理仍可继承桌面环境的 PAC 设置。",
90+
"ManualProxy": "手动代理",
91+
"ManualProxyDescription": "使用下方配置的 HTTP 或 SOCKS5 代理。",
92+
"PacSettings": "PAC 配置",
93+
"PacUrl": "PAC URL",
94+
"PacUrlDescription": "仅支持不含用户名或密码的 HTTP/HTTPS 地址。",
95+
"PacUrlPlaceholder": "https://proxy.example.com/proxy.pac",
96+
"ManualSettings": "手动代理配置",
8497
"ProxyType": "代理类型",
8598
"Host": "主机",
8699
"HostPlaceholder": "proxy.example.com 或 IP 地址",
@@ -99,16 +112,30 @@
99112
"BypassDescription": "每行或逗号分隔一个主机、域名、IP 或 CIDR;本机地址始终绕过代理。",
100113
"BypassPlaceholder": "localhost\n127.0.0.0/8\n.internal.example.com",
101114
"TestTitle": "连接测试",
102-
"TestDescription": "输入 JumpServer 站点 origin,应用会请求固定的 well-known 端点。代理开启时,命中绕过列表不会被视为代理测试成功。",
115+
"TestDescriptionDirect": "输入 JumpServer 站点 origin,测试其固定 well-known 端点的直连访问。",
116+
"TestDescriptionSystem": "输入 JumpServer 站点 origin,应用会先按该目标解析操作系统代理或 PAC 路径,再测试固定的 well-known 端点。",
117+
"TestDescriptionPac": "输入 JumpServer 站点 origin,应用会先使用指定 PAC 解析该目标的路径,再测试固定的 well-known 端点。",
118+
"TestDescriptionManual": "输入 JumpServer 站点 origin,通过手动代理测试固定的 well-known 端点;命中绕过列表时不会测试代理。",
103119
"TargetUrl": "JumpServer 站点地址",
104120
"TestConnection": "测试连接",
105121
"TestSucceeded": "连接成功",
106122
"TestFailed": "连接失败",
123+
"ResolverDirect": "直连",
124+
"ResolverSystem": "系统代理",
125+
"ResolverPac": "PAC",
126+
"ResolverManual": "手动代理",
127+
"ResolverBypass": "绕过列表",
128+
"RouteDirect": "直连",
129+
"RouteProxy": "经代理",
130+
"FallbackRoutesUsed": "已进入 {count} 条后备线路",
107131
"Save": "保存",
108132
"SaveSucceeded": "已保存并从后端确认",
109133
"SaveFailedWithReason": "保存失败:{reason}",
110134
"ReadbackFailedWithReason": "设置已提交,但无法从后端读取确认:{reason}",
111135
"Errors": {
136+
"PacUrlRequired": "请输入 PAC URL。",
137+
"PacUrlTooLong": "PAC URL 不能超过 2048 个字符。",
138+
"InvalidPacUrl": "请输入不含用户名或密码的 HTTP/HTTPS URL。",
112139
"HostRequired": "请输入代理主机。",
113140
"HostTooLong": "代理主机不能超过 255 个字符。",
114141
"InvalidHost": "请输入不含协议、路径或凭据的主机名或 IP 地址。",

src-tauri/Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,20 @@ tauri-plugin-window-state = "2.4.0"
102102

103103
[target.'cfg(target_os = "macos")'.dependencies]
104104
libc = "0.2"
105+
core-foundation = "0.10"
106+
core-foundation-sys = "0.8"
105107
shiguredo_video_toolbox = { git = "https://github.com/shiguredo/video-toolbox-rs", branch = "develop" }
106108

107109
[target.'cfg(windows)'.dependencies]
108110
windows = { version = "0.58", features = [
111+
"Win32_Foundation",
109112
"Win32_Media_MediaFoundation",
113+
"Win32_Networking_WinHttp",
110114
"Win32_System_Com",
111115
] }
112116

113117
[target.'cfg(target_os = "linux")'.dependencies]
118+
gio = "0.18"
114119
openh264 = "0.7"
115120

116121
[profile.release]

0 commit comments

Comments
 (0)