mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-30 17:56:13 -05:00
fix(windows): set adapter resolvers when the VPN supplies no split DNS domains
This commit is contained in:
2 files changed
+111
-3
No files matched your search
@@ -275,6 +275,47 @@ fn global_search_list() -> Vec<u8> {
|
||||
output.stdout
|
||||
}
|
||||
|
||||
/// Check what DNS clients see for this adapter independently of the NRPT rule.
|
||||
fn adapter_servers(index: u32) -> Vec<String> {
|
||||
let command = format!("(Get-DnsClientServerAddress -InterfaceIndex {index} -ErrorAction Stop).ServerAddresses");
|
||||
let output = std::process::Command::new("powershell.exe")
|
||||
.args(["-NoProfile", "-NonInteractive", "-Command", &command])
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(output.status.success(), "{}", String::from_utf8_lossy(&output.stderr));
|
||||
String::from_utf8(output.stdout)
|
||||
.unwrap()
|
||||
.lines()
|
||||
.map(str::to_owned)
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn check_adapter_resolvers(index: u32, key: &str) -> io::Result<()> {
|
||||
let split = environment(index);
|
||||
let mut full = split.clone();
|
||||
full.retain(|(key, _)| key != "CISCO_SPLIT_DNS");
|
||||
let initial = adapter_servers(index);
|
||||
let mut network = NetworkConfigurator::new(key)?;
|
||||
network.configure("connect", &full)?;
|
||||
let servers = adapter_servers(index);
|
||||
assert!(servers.iter().any(|address| address == "198.18.0.53"));
|
||||
assert!(servers.iter().any(|address| address == "fd42:1235::53"));
|
||||
network.configure("reconnect", &split)?;
|
||||
assert_eq!(
|
||||
adapter_servers(index),
|
||||
initial,
|
||||
"split DNS must be scoped to its namespaces"
|
||||
);
|
||||
network.configure("reconnect", &full)?;
|
||||
network.configure("disconnect", &[])?;
|
||||
assert_eq!(
|
||||
adapter_servers(index),
|
||||
initial,
|
||||
"disconnect must restore the adapter DNS settings"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "requires administrator privileges and GP_TEST_WINTUN_DLL"]
|
||||
fn installs_and_restores_native_network_configuration() -> Result<(), Box<dyn std::error::Error>> {
|
||||
@@ -355,6 +396,7 @@ fn installs_and_restores_native_network_configuration() -> Result<(), Box<dyn st
|
||||
);
|
||||
assert_eq!(before, state(index), "Failed connection left a physical gateway route");
|
||||
println!("PASS: partial setup failure rolled back its physical gateway route");
|
||||
check_adapter_resolvers(index, &recovery_key)?;
|
||||
drop(adapter);
|
||||
assert_crash_recovery(&recovery_key)?;
|
||||
assert_eq!(global_search_list(), original_search_list);
|
||||
|
||||
Reference in new issue
Block a user