fix CI: gate macOS-only imports and functions behind cfg

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Razvan Dimescu
2026-03-20 11:11:32 +02:00
parent 4dc5b94c7a
commit 87ca4f095d

View File

@@ -1,6 +1,6 @@
use std::net::SocketAddr; use std::net::SocketAddr;
use log::{debug, info, warn}; use log::info;
/// A conditional forwarding rule: domains matching `suffix` are forwarded to `upstream`. /// A conditional forwarding rule: domains matching `suffix` are forwarded to `upstream`.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@@ -27,6 +27,8 @@ pub fn discover_forwarding_rules() -> Vec<ForwardingRule> {
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
fn discover_macos() -> Vec<ForwardingRule> { fn discover_macos() -> Vec<ForwardingRule> {
use log::{debug, warn};
let output = match std::process::Command::new("scutil").arg("--dns").output() { let output = match std::process::Command::new("scutil").arg("--dns").output() {
Ok(o) => o, Ok(o) => o,
Err(e) => { Err(e) => {
@@ -122,6 +124,7 @@ fn discover_macos() -> Vec<ForwardingRule> {
rules rules
} }
#[cfg(target_os = "macos")]
fn make_rule(domain: &str, nameserver: &str) -> Option<ForwardingRule> { fn make_rule(domain: &str, nameserver: &str) -> Option<ForwardingRule> {
let addr: SocketAddr = format!("{}:53", nameserver).parse().ok()?; let addr: SocketAddr = format!("{}:53", nameserver).parse().ok()?;
Some(ForwardingRule { Some(ForwardingRule {