Visual Studio Code, rebuilt in Rust
Rust
feat(windows): send requests through the system proxy
rokarturd94385a277ec
diff --git a/native/crates/exthost/Cargo.toml b/native/crates/exthost/Cargo.tomlindex 523452ce77e..4e332da29e9 100644--- a/native/crates/exthost/Cargo.toml+++ b/native/crates/exthost/Cargo.toml@@ -35,7 +35,7 @@ futures = "0.3"oo7 = { version = "0.6", default-features = false, features = ["async-std", "native_crypto"] }[target.'cfg(target_os = "windows")'.dependencies]-windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_Security", "Win32_Security_Credentials", "Win32_Storage_FileSystem", "Win32_System_IO", "Win32_System_Pipes", "Win32_System_Threading"] }+windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_Networking_WinHttp", "Win32_Security", "Win32_Security_Credentials", "Win32_Storage_FileSystem", "Win32_System_IO", "Win32_System_Pipes", "Win32_System_Threading"] }[target.'cfg(target_os = "linux")'.dev-dependencies]async-lock = "3"diff --git a/native/crates/exthost/src/request.rs b/native/crates/exthost/src/request.rsindex 60305580a62..de63ec4a839 100644--- a/native/crates/exthost/src/request.rs+++ b/native/crates/exthost/src/request.rs@@ -1,5 +1,5 @@//! platform/request (request.ts, requestService.ts): HTTP requests of the workbench, sent by `send` of-//! request/macos.rs (NSURLSession) or request/linux.rs (curl).+//! request/macos.rs (NSURLSession), request/linux.rs (curl) or request/windows.rs (curl with the Windows proxy).use std::sync::Mutex;use std::time::Duration;@@ -10,14 +10,14 @@ use anyhow::bail;mod linux;#[cfg(target_os = "macos")]mod macos;+#[cfg(any(target_os = "windows", test))]+mod proxy_rules;#[cfg(target_os = "windows")]mod windows;#[cfg(target_os = "linux")]use linux::{lookup_kerberos_authorization, resolve_proxy_with, send};#[cfg(target_os = "windows")]-use linux::send;-#[cfg(target_os = "windows")]-use windows::{lookup_kerberos_authorization, resolve_proxy_with};+use windows::{lookup_kerberos_authorization, resolve_proxy_with, send};#[cfg(target_os = "macos")]use macos::{lookup_kerberos_authorization, resolve_proxy_with, send};diff --git a/native/crates/exthost/src/request/proxy_rules.rs b/native/crates/exthost/src/request/proxy_rules.rsnew file mode 100644index 00000000000..7d3e206b3c9--- /dev/null+++ b/native/crates/exthost/src/request/proxy_rules.rs@@ -0,0 +1,245 @@+//! Chromium's ProxyConfig::ProxyRules (proxy_config.cc `ParseFromString`, `Apply`) and ProxyBypassRules+//! (proxy_bypass_rules.cc, scheme_host_port_matcher_rule.cc) for one URL, as `ProxyList::ToPacString` gives it.+//! request/windows.rs resolves the session proxy and the IE proxy settings through it, as ProxyConfigServiceWin.++use std::net::IpAddr;++/// `ProxyRules::Apply` of `rules` (`host:port`, `scheme://host:port`, or `http=...;https=...;socks=...`) with the+/// bypass list (`,`, `;` or whitespace separated, as ProxyConfigServiceWin tokenizes `lpszProxyBypass`).+pub fn pac_for_rules(url: &str, rules: &str, bypass: &str) -> String {+ let target = Target::parse(url);+ let proxies = proxies_for_scheme(rules, &target.scheme);+ if proxies.is_empty() || bypassed(&target, bypass) {+ return "DIRECT".to_owned();+ }+ proxies.join(";")+}++/// `ProxyList::Set` of a WinHTTP proxy list (`host:port;host:port`), as ProxyResolverWinHttp's `UseNamedProxy`.+pub fn pac_for_list(list: &str) -> String {+ let proxies: Vec<String> = list.split([';', ' ', '\t']).filter_map(|uri| pac_element(uri, "http")).collect();+ if proxies.is_empty() { "DIRECT".to_owned() } else { proxies.join(";") }+}++/// The curl `--proxy` of a PAC element; `DIRECT` is the empty proxy, which turns the proxy variables off.+/// Chromium's SOCKS5 resolves host names at the proxy, curl's `socks5h`.+pub fn curl_proxy(element: &str) -> String {+ let Some((keyword, address)) = element.trim().split_once(' ') else { return String::new() };+ let scheme = match keyword {+ "PROXY" => "http",+ "HTTPS" => "https",+ "SOCKS" | "SOCKS4" => "socks4",+ "SOCKS5" => "socks5h",+ _ => return String::new(),+ };+ format!("{scheme}://{}", address.trim())+}++struct Target {+ scheme: String,+ host: String,+ port: u16,+}++impl Target {+ fn parse(url: &str) -> Target {+ let (scheme, rest) = url.split_once("://").unwrap_or(("http", url));+ let scheme = scheme.to_ascii_lowercase();+ let authority = rest.split(['/', '?', '#']).next().unwrap_or_default();+ let authority = authority.rsplit_once('@').map_or(authority, |(_, host)| host);+ let default_port = match scheme.as_str() {+ "https" | "wss" => 443,+ "ftp" => 21,+ _ => 80,+ };+ let (host, port) = host_port(authority, default_port).unwrap_or((authority.to_ascii_lowercase(), default_port));+ Target { scheme, host, port }+ }++ fn ip(&self) -> Option<IpAddr> {+ unbracket(&self.host).parse().ok()+ }+}++/// ParseFromString: an entry without `=` before any `scheme=` entry is the list for every scheme; `socks=` is the+/// fallback of the schemes without their own list, SOCKS4 when its proxies name no scheme.+fn proxies_for_scheme(rules: &str, scheme: &str) -> Vec<String> {+ let mut per_scheme = false;+ let mut own = Vec::new();+ let mut fallback = Vec::new();+ for entry in rules.split(';').filter(|entry| !entry.is_empty()) {+ let Some((name, list)) = entry.split_once('=') else {+ if per_scheme {+ continue;+ }+ return pac_elements(entry, "http");+ };+ per_scheme = true;+ match name.trim() {+ "socks" => fallback.extend(pac_elements(list, "socks4")),+ name if name == scheme && matches!(name, "http" | "https" | "ftp") => own.extend(pac_elements(list, "http")),+ _ => {}+ }+ }+ if own.is_empty() { fallback } else { own }+}++fn pac_elements(list: &str, default_scheme: &str) -> Vec<String> {+ list.split(',').filter_map(|uri| pac_element(uri, default_scheme)).collect()+}++/// proxy_string_util.cc `ProxyUriToProxyServer`: `socks://` is SOCKS5 in a URI, `direct://` takes no host.+fn pac_element(uri: &str, default_scheme: &str) -> Option<String> {+ let uri = uri.trim();+ let (scheme, address) = match uri.split_once("://") {+ Some((scheme, address)) => (scheme.to_ascii_lowercase(), address),+ None => (default_scheme.to_owned(), uri),+ };+ let (keyword, default_port) = match scheme.as_str() {+ "http" => ("PROXY", 80),+ "https" => ("HTTPS", 443),+ "socks4" => ("SOCKS", 1080),+ "socks" | "socks5" => ("SOCKS5", 1080),+ "direct" => return address.is_empty().then(|| "DIRECT".to_owned()),+ _ => return None,+ };+ let (host, port) = host_port(address, default_port)?;+ Some(format!("{keyword} {host}:{port}"))+}++/// `host`, `host:port`, `[v6]` or `[v6]:port`, the host lowercased; None for an empty host or a bad port.+fn host_port(address: &str, default_port: u16) -> Option<(String, u16)> {+ let (host, port) = match address.rsplit_once(':') {+ Some((host, port)) if !host.contains(':') || host.ends_with(']') => (host, port.parse().ok()?),+ _ => (address, default_port),+ };+ if host.is_empty() {+ return None;+ }+ Some((host.to_ascii_lowercase(), port))+}++fn unbracket(host: &str) -> &str {+ host.strip_prefix('[').and_then(|host| host.strip_suffix(']')).unwrap_or(host)+}++/// `ProxyBypassRules::Matches`: the rules in order, `<-loopback>` excluding the implicit rules where it stands, then+/// the implicit rules (localhost, loopback and link-local addresses).+fn bypassed(target: &Target, bypass: &str) -> bool {+ for rule in bypass.split([',', ';', ' ', '\t', '\n', '\r']).filter(|rule| !rule.is_empty()) {+ match rule.to_ascii_lowercase().as_str() {+ "<local>" if !target.host.contains('.') && target.ip().is_none() => return true,+ "<local>" => {}+ "<-loopback>" if implicitly_bypassed(target) => return false,+ "<-loopback>" => {}+ rule if rule_matches(rule, target) => return true,+ _ => {}+ }+ }+ implicitly_bypassed(target)+}++fn implicitly_bypassed(target: &Target) -> bool {+ let host = target.host.strip_suffix('.').unwrap_or(&target.host);+ match target.ip() {+ Some(IpAddr::V4(ip)) => ip.is_loopback() || ip.is_link_local(),+ Some(IpAddr::V6(ip)) => ip.is_loopback() || ip.segments()[0] & 0xffc0 == 0xfe80,+ None => host == "localhost" || host.ends_with(".localhost"),+ }+}++/// SchemeHostPortMatcherRule::FromUntrimmedRawString: an optional `scheme://`, then a CIDR block (`10.0.0.0/8`), an+/// IP literal, or a host pattern with `*` and `?` (a leading `.` is `*.`) and an optional port.+fn rule_matches(rule: &str, target: &Target) -> bool {+ let rule = match rule.split_once("://") {+ Some((scheme, _)) if scheme != target.scheme => return false,+ Some((_, rest)) => rest,+ None => rule,+ };+ if let Some((ip, prefix)) = rule.split_once('/') {+ let (Ok(ip), Ok(prefix), Some(host)) = (unbracket(ip).parse::<IpAddr>(), prefix.parse::<u32>(), target.ip()) else { return false };+ return in_block(host, ip, prefix);+ }+ let Some((host, port)) = host_port(rule, 0) else { return false };+ if port != 0 && port != target.port {+ return false;+ }+ if let Ok(ip) = unbracket(&host).parse::<IpAddr>() {+ return target.ip() == Some(ip);+ }+ let pattern = if host.starts_with('.') { format!("*{host}") } else { host };+ glob(pattern.as_bytes(), target.host.as_bytes())+}++fn in_block(host: IpAddr, block: IpAddr, prefix: u32) -> bool {+ match (host, block) {+ (IpAddr::V4(host), IpAddr::V4(block)) if prefix <= 32 => u32::from(host).checked_shr(32 - prefix).unwrap_or(0) == u32::from(block).checked_shr(32 - prefix).unwrap_or(0),+ (IpAddr::V6(host), IpAddr::V6(block)) if prefix <= 128 => u128::from(host).checked_shr(128 - prefix).unwrap_or(0) == u128::from(block).checked_shr(128 - prefix).unwrap_or(0),+ _ => false,+ }+}++/// base/strings/pattern.cc `MatchPattern`: `*` any run, `?` one character.+fn glob(pattern: &[u8], text: &[u8]) -> bool {+ match pattern.split_first() {+ None => text.is_empty(),+ Some((b'*', rest)) => (0..=text.len()).any(|skip| glob(rest, &text[skip..])),+ Some((b'?', rest)) => !text.is_empty() && glob(rest, &text[1..]),+ Some((first, rest)) => text.first() == Some(first) && glob(rest, &text[1..]),+ }+}++#[cfg(test)]+mod tests {+ use super::{curl_proxy, pac_for_list, pac_for_rules};++ /// proxy_config_unittest.cc `ParseProxyRules`.+ #[test]+ fn rules_pick_the_list_of_the_scheme_or_the_socks_fallback() {+ let pac = |url, rules| pac_for_rules(url, rules, "");+ assert_eq!(pac("http://a.test/", "myproxy:80"), "PROXY myproxy:80");+ assert_eq!(pac("https://a.test/", "myproxy"), "PROXY myproxy:80");+ assert_eq!(pac("https://a.test/", "https://Secure.Proxy"), "HTTPS secure.proxy:443");+ assert_eq!(pac("http://a.test/", "socks://s:1080"), "SOCKS5 s:1080");+ assert_eq!(pac("http://a.test/", "a:1,socks4://b,direct://"), "PROXY a:1;SOCKS b:1080;DIRECT");+ let per_scheme = "http=h1:80;https=h2:443;socks=s1";+ assert_eq!(pac("http://a.test/", per_scheme), "PROXY h1:80");+ assert_eq!(pac("https://a.test/", per_scheme), "PROXY h2:443");+ assert_eq!(pac("ftp://a.test/", per_scheme), "SOCKS s1:1080");+ assert_eq!(pac("https://a.test/", "http=h1:80"), "DIRECT");+ assert_eq!(pac("http://a.test/", "http=h1:80;bare:3"), "PROXY h1:80");+ assert_eq!(pac("http://a.test/", ""), "DIRECT");+ assert_eq!(pac("http://a.test/", "myproxy:port"), "DIRECT");+ }++ /// proxy_bypass_rules_unittest.cc: `<local>`, wildcards, ports, schemes, CIDR blocks and the implicit rules.+ #[test]+ fn bypass_rules_match_as_chromium() {+ let direct = |url: &str, bypass: &str| pac_for_rules(url, "p:8080", bypass) == "DIRECT";+ assert!(direct("http://intranet/", "<local>"));+ assert!(!direct("http://intranet.corp/", "<local>"));+ assert!(!direct("http://[::5]/", "<local>"));+ assert!(direct("http://www.Example.com/", "*.example.com"));+ assert!(direct("http://www.example.com/", ".example.com"));+ assert!(!direct("http://example.com/", "*.example.com"));+ assert!(direct("http://example.com/", "example.com"));+ assert!(direct("http://10.1.2.3/", "10.*"));+ assert!(direct("http://a.test:81/", "a.test:81") && !direct("http://a.test/", "a.test:81"));+ assert!(direct("https://a.test/", "https://a.test") && !direct("http://a.test/", "https://a.test"));+ assert!(direct("http://192.168.4.5/", "192.168.0.0/16") && !direct("http://192.169.0.1/", "192.168.0.0/16"));+ assert!(direct("http://[fe80::1]/", "<local>"));+ assert!(direct("http://localhost:3000/", "") && direct("http://127.0.0.2/", "") && direct("http://a.localhost/", ""));+ assert!(!direct("http://localhost/", "<-loopback>"));+ assert!(direct("http://a.test/", "a.test;b.test") && direct("http://b.test/", "a.test b.test"));+ }++ #[test]+ fn winhttp_lists_and_curl_proxies() {+ assert_eq!(pac_for_list("p1:8080;p2"), "PROXY p1:8080;PROXY p2:80");+ assert_eq!(pac_for_list(""), "DIRECT");+ assert_eq!(curl_proxy("PROXY p1:8080"), "http://p1:8080");+ assert_eq!(curl_proxy("SOCKS5 s:1080"), "socks5h://s:1080");+ assert_eq!(curl_proxy("SOCKS s:1080"), "socks4://s:1080");+ assert_eq!(curl_proxy("DIRECT"), "");+ }+}diff --git a/native/crates/exthost/src/request/windows.rs b/native/crates/exthost/src/request/windows.rsindex fb69975ef2e..ba5a2f30c77 100644--- a/native/crates/exthost/src/request/windows.rs+++ b/native/crates/exthost/src/request/windows.rs@@ -1,10 +1,101 @@-//! request.rs on Windows: `send` is linux.rs's curl, the curl.exe Windows 10 1803 and later ship in System32.+//! request.rs on Windows: `send` is linux.rs's curl (the curl.exe Windows 10 1803 and later ship in System32) with+//! the proxy Chromium's ProxyConfigServiceWin would pick: the session proxy, else the IE settings of WinHTTP.-use super::SessionProxy;+use std::sync::OnceLock;-// shortcut: no system proxy, curl reads only the proxy variables; read WinHTTP's IE proxy settings (port/ledger.md M24 row exthost/src/request.rs:9).-pub(super) fn resolve_proxy_with(_url: &str, _proxy: Option<&SessionProxy>) -> Option<String> {- Some("DIRECT".to_owned())+use windows_sys::Win32::Foundation::GlobalFree;+use windows_sys::Win32::Networking::WinHttp::{+ WINHTTP_ACCESS_TYPE_NAMED_PROXY, WINHTTP_ACCESS_TYPE_NO_PROXY, WINHTTP_AUTO_DETECT_TYPE_DHCP, WINHTTP_AUTO_DETECT_TYPE_DNS_A, WINHTTP_AUTOPROXY_AUTO_DETECT,+ WINHTTP_AUTOPROXY_CONFIG_URL, WINHTTP_AUTOPROXY_OPTIONS, WINHTTP_CURRENT_USER_IE_PROXY_CONFIG, WINHTTP_PROXY_INFO, WinHttpGetIEProxyConfigForCurrentUser,+ WinHttpGetProxyForUrl, WinHttpOpen,+};+use windows_sys::core::PWSTR;++use super::proxy_rules::{curl_proxy, pac_for_list, pac_for_rules};+use super::{Request, Response, SessionProxy};++// shortcut: curl takes one proxy, so the first of the list is used without Chromium's fallback to the next on a+// connection failure; send through WinHTTP when a proxy list with fallbacks is needed.+pub(super) fn send(options: &Request, proxy: Option<&SessionProxy>, proxy_authorization: Option<&str>) -> anyhow::Result<Response> {+ let resolved = resolve_proxy_with(options.url, proxy).unwrap_or_default();+ let rules = curl_proxy(resolved.split(';').next().unwrap_or_default());+ super::linux::send(options, Some(&SessionProxy { rules, bypass_rules: String::new() }), proxy_authorization)+}++/// ProxyConfigServiceWin `SetFromIEConfig`: auto-detect and the PAC URL first; when they give nothing, the manual+/// proxy and its bypass list.+pub(super) fn resolve_proxy_with(url: &str, proxy: Option<&SessionProxy>) -> Option<String> {+ if let Some(proxy) = proxy {+ return Some(pac_for_rules(url, &proxy.rules, &proxy.bypass_rules));+ }+ let mut config = WINHTTP_CURRENT_USER_IE_PROXY_CONFIG::default();+ // SAFETY: WinHTTP fills the struct; each string it allocates is taken and freed once below.+ let read = unsafe { WinHttpGetIEProxyConfigForCurrentUser(&mut config) } != 0;+ let (auto_detect, pac_url, manual, bypass) = if read {+ // SAFETY: as above.+ unsafe { (config.fAutoDetect != 0, take_wide(config.lpszAutoConfigUrl), take_wide(config.lpszProxy), take_wide(config.lpszProxyBypass)) }+ } else {+ (false, None, None, None)+ };+ if (auto_detect || pac_url.is_some())+ && let Some(list) = automatic_proxy(url, auto_detect, pac_url.as_deref())+ {+ return Some(list);+ }+ Some(pac_for_rules(url, manual.as_deref().unwrap_or_default(), bypass.as_deref().unwrap_or_default()))+}++/// WPAD and the PAC script through `WinHttpGetProxyForUrl`, on one session so WinHTTP keeps the script cached.+fn automatic_proxy(url: &str, auto_detect: bool, pac_url: Option<&str>) -> Option<String> {+ static SESSION: OnceLock<usize> = OnceLock::new();+ let agent = wide("VSRustium");+ // SAFETY: a session without a proxy of its own; the handle lives for the process.+ let session = *SESSION.get_or_init(|| unsafe { WinHttpOpen(agent.as_ptr(), WINHTTP_ACCESS_TYPE_NO_PROXY, std::ptr::null(), std::ptr::null(), 0) } as usize);+ if session == 0 {+ return None;+ }+ let pac_url = pac_url.map(wide);+ let mut options = WINHTTP_AUTOPROXY_OPTIONS { fAutoLogonIfChallenged: 1, ..Default::default() };+ if auto_detect {+ options.dwFlags |= WINHTTP_AUTOPROXY_AUTO_DETECT;+ options.dwAutoDetectFlags = WINHTTP_AUTO_DETECT_TYPE_DHCP | WINHTTP_AUTO_DETECT_TYPE_DNS_A;+ }+ if let Some(pac_url) = &pac_url {+ options.dwFlags |= WINHTTP_AUTOPROXY_CONFIG_URL;+ options.lpszAutoConfigUrl = pac_url.as_ptr();+ }+ let url = wide(url);+ let mut info = WINHTTP_PROXY_INFO::default();+ // SAFETY: the strings outlive the call; WinHTTP allocates the info strings, freed by take_wide.+ let found = unsafe { WinHttpGetProxyForUrl(session as *mut _, url.as_ptr(), &mut options, &mut info) } != 0;+ if !found {+ return None;+ }+ // SAFETY: as above.+ let (list, _) = unsafe { (take_wide(info.lpszProxy), take_wide(info.lpszProxyBypass)) };+ match info.dwAccessType {+ WINHTTP_ACCESS_TYPE_NAMED_PROXY => Some(pac_for_list(list.as_deref().unwrap_or_default())),+ _ => Some("DIRECT".to_owned()),+ }+}++fn wide(text: &str) -> Vec<u16> {+ text.encode_utf16().chain([0]).collect()+}++/// A NUL-terminated string WinHTTP allocated with GlobalAlloc, read and freed.+unsafe fn take_wide(text: PWSTR) -> Option<String> {+ if text.is_null() {+ return None;+ }+ // SAFETY: WinHTTP's strings end with NUL.+ let value = unsafe {+ let length = (0..).take_while(|&index| *text.add(index) != 0).count();+ String::from_utf16_lossy(std::slice::from_raw_parts(text, length))+ };+ // SAFETY: allocated by WinHTTP with GlobalAlloc, freed once.+ unsafe { GlobalFree(text.cast()) };+ Some(value)}// shortcut: no SSPI binding, so proxies that need Kerberos fail; call InitializeSecurityContextW as macos.rs calls GSS.diff --git a/port/ledger.md b/port/ledger.mdindex fe615ef6ae6..4ed2eb3064d 100644--- a/port/ledger.md+++ b/port/ledger.md@@ -77,7 +77,7 @@ Status: `open`, `in progress`, `waiting on Artur`, `later` (postponed), `done`,| M24 Windows | app/src/launch.rs:5 | in progress | [windows M] single instance and second-instance arguments over a named pipe (main.ts `mainIPCHandle` on Windows). Done and cross-built, never run: the pipe `\\.\pipe\<sha256(user data)[..8]>-<version>-main-sock` (`createStaticIPCHandle`, host test `the_windows_pipe_is_named_from_the_user_data_hash_as_create_static_ipc_handle`), exthost/src/pipe.rs as the transport, `windowsAllowSetForegroundWindow` with the pipe server's pid. | `cargo gc test -p app launch` on the host for the pipe name; `cargo gc test -p app launch` on the windows runner || M24 Windows | app/src/cli.rs:7 | in progress | [windows M] the command line on Windows: `bin\<applicationName>.cmd` from resources/win32/bin/code.cmd (written by port/tools/package-windows, its row). Done and cross-built, never run: stdin read and terminal width through the console API; a GUI-subsystem binary as Electron's that attaches to the starting console (electron_main_win.cc `RouteStdioToConsole` unless `ELECTRON_NO_ATTACH_CONSOLE`). | `cargo gc test -p app cli` on the windows runner || M24 Windows | exthost/src/main_thread_secret_state.rs:19 | in progress | [windows S] secrets in Credential Manager (keyring), with keytar's target name `<service>/<account>` so VS Code's stored secrets keep their keys. Done and cross-built, never run: main_thread_secret_state/windows.rs (generic credentials, user name the account, blob the UTF-8 secret, `CRED_PERSIST_ENTERPRISE`, keys from `CredEnumerateW` on `<service>/*`); the runner test `secrets_in_credential_manager` uses a service of its own. Difference: a secret over 2560 bytes (`CRED_MAX_CREDENTIAL_BLOB_SIZE`) fails to store, as with keytar, where upstream's safeStorage has no limit. | `cargo gc test -p exthost secret` on the windows runner |-| M24 Windows | exthost/src/request.rs:9 | open | [windows M] extension and gallery HTTP with the system proxy (WinHTTP's IE proxy settings, Chromium's ProxyConfigServiceWin), `http.proxy` and the `<local>` bypass. | `cargo gc test -p exthost request` on the windows runner |+| M24 Windows | exthost/src/request.rs:9 | in progress | [windows M] extension and gallery HTTP with the system proxy (request/windows.rs): the session proxy (`http.proxy`, `http.noProxy`, the proxy variables) else the IE settings of `WinHttpGetIEProxyConfigForCurrentUser`, WPAD and the PAC URL through `WinHttpGetProxyForUrl` first, then the manual proxy, as Chromium's ProxyConfigServiceWin `SetFromIEConfig`; rules and bypass lists (`<local>`, `<-loopback>`, wildcards, ports, schemes, CIDR blocks, the implicit localhost and link-local bypass) as proxy_config.cc and proxy_bypass_rules.cc (request/proxy_rules.rs); curl gets the first proxy of the list, without Chromium's fallback to the next; no Kerberos (SSPI). Built, not yet run on Windows. | `cargo gc test -p exthost proxy_rules` on the host; [windows] `cargo gc test -p exthost request` and a request through a PAC and a manual proxy on the windows runner || M24 Windows | app/src/workbench/menubar.rs:173 | open | [windows L] menu bar in the custom title bar (menubarControl.ts `CustomMenubarControl`, `window.titleBarStyle: custom`, `window.menuBarVisibility`) and the window controls (minimize, maximize, close) titlebarPart.ts draws on Windows. The shared mechanism is M24's (decision "Menu bar and keybinding tables"); it unblocks the M23 Linux row app/src/workbench/menubar.rs:173. Windows shows now: no menu bar. | `cargo gc test -p app menubar` on the host; a ui-pair against the reference not possible (macOS reference) || M24 Windows | app/src/keybindings.rs:86 | open | [windows L] Windows keybindings: `default-win` table, the `win` key of extension and user rules, Windows labels (keybindingLabels.ts for `OperatingSystem.Windows`: `Ctrl+Shift+P`, `Windows`, `win`), and windowsKeyboardMapper.ts for layouts. The per-platform mechanism is M24's (decision "Menu bar and keybinding tables"), with a Linux table hook; it unblocks the M23 Linux row app/src/keybindings.rs:86. Windows shows now: the macOS table on GPUI's platform modifier (Ctrl). | `cargo gc test -p app keybindings` on the host with the Windows table || M24 Windows | app/src/keyboard_layout.rs:7 | open | [windows M] keyboard layout info and raw mapping (native-keymap's Windows `GetKeyboardLayout`, `MapVirtualKeyEx`, `ToUnicodeEx`). | `cargo gc test -p app keyboard` on the windows runner |diff --git a/port/notes.md b/port/notes.mdindex 8adf9fbaa97..6c6c81fa4c1 100644--- a/port/notes.md+++ b/port/notes.md@@ -1021,6 +1021,7 @@ What to do (milestone 21, in order):- Webview: `webview/windows.rs` is a WebView2 (webview2-com 0.38, the last on `windows` 0.61) in a child window of GPUI's HWND, loading the same host page as macOS and Linux. A WebResourceRequested filter on `https://*.vscode-webview.vscode-cdn.net/*` and `https://*.vscode-resource.vscode-cdn.net/*` (with `COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS_ALL` where `ICoreWebView2_22` exists, so the content iframe's loads reach it) answers what the service worker answers upstream; `file` resources are read in place, the rest through the workbench with a deferral. A `file` resource's path is the URI path (`/c:/proj/a.png`), which matches no root and reads nothing until the drive-letter row (app/src/editor_history.rs:59) gives one conversion to a disk path. The bridge script runs in the top frame only, with `window.webkit.messageHandlers.vscodeWebviewHost` mapped onto `chrome.webview.postMessage`; messages from any other origin are dropped. `window.open` is handled with no window, as WebKit without a UI delegate does. No HTTP_LOOPBACK_ONLY_RULES: WebView2 is Chromium, which blocks non-loopback http in the https page as Electron does. Profile in `%LOCALAPPDATA%\<nameShort>\WebView2`. GPUI's DirectComposition target was topmost (`CreateTargetForHwnd(hwnd, true)`), drawing over every child window; `native/vendor/wu/crates/gpui_windows` vendors the crate with that one argument `false`. The notebook back layer clip is one window region (hit rects minus the hole), where Linux has an input shape beside the drawn one. URL splitting (`https_url_parts`) is a host test in webview.rs; the rest needs the windows runner.- Named pipes: `exthost/src/pipe.rs` carries both the extension host connection (`\\.\pipe\vscode-ipc-<uuid>-sock`) and the single instance (`\\.\pipe\<sha256(user data)[..8]>-<version>-main-sock`, launch.rs), as ipc.net.ts names them. Instances are made as libuv's `uv_pipe_bind` makes them (duplex, byte mode, 64 KiB buffers, default security descriptor) plus `PIPE_REJECT_REMOTE_CLIENTS` and `FILE_FLAG_FIRST_PIPE_INSTANCE`, so a second listener fails as Node's `listen` does with EADDRINUSE. The handles are overlapped: synchronous I/O on one pipe handle is serialized by Windows, and the extension host reader thread blocks in a read while the main thread writes. Clients connect with `SECURITY_IDENTIFICATION`, so a pipe server cannot act as the client. The single instance name is fixed per user data folder in the machine-wide pipe namespace, as upstream's: another local user who creates it first receives a later start's arguments and working directory. A second instance calls `AllowSetForegroundWindow` with the pipe server's pid (`GetNamedPipeServerProcessId`) where main.ts asks the first instance for its pid over IPC. `generateUuid` and the profile ids read the OS random source (getrandom), not `/dev/urandom`.- Console: the app is a GUI-subsystem binary, as Electron's, so a start from Explorer or the Start menu opens no console window; at start it attaches to the console of the process that started it unless the output is redirected or the CLI set `ELECTRON_NO_ATTACH_CONSOLE` (electron_main_win.cc, Chromium's `RouteStdioToConsole`), so `bin\<applicationName>.cmd --help` prints in the terminal.+- Proxy: `request/windows.rs` sends through curl.exe as Linux does, with the proxy picked first: the session proxy, else the IE settings, auto-detect and the PAC URL through WinHTTP's resolver where Chromium runs the script in its own V8 (same answer, other engine), then the manual proxy. The rule and bypass parsing is Chromium's (`request/proxy_rules.rs`, built on every platform for its host tests). Difference: curl takes one proxy, so a PAC list's later entries are no fallback.## Accepted platform differences