-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Windows support #44
feat: Windows support #44
Conversation
src/wgapi_windows.rs
Outdated
let file_path = path.join(&file_name).display().to_string(); | ||
|
||
debug!( | ||
"Creating WireGuard configuration file {} in: {}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Creating WireGuard configuration file {} in: {}", | |
"Creating WireGuard configuration file {file_name} in: {file_path}", |
src/wgapi_windows.rs
Outdated
// Interface is created here so that there is no need to pass private key only for Windows | ||
let file_name = format!("{}.conf", &self.ifname); | ||
let path = env::current_dir()?; | ||
let file_path = path.join(&file_name).display().to_string(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let file_path = path.join(&file_name).display().to_string(); | |
let file_path = path.join(&file_name).to_str().unwrap_or_default(); |
src/wgapi_windows.rs
Outdated
config.prvkey, config.address | ||
); | ||
|
||
if !dns_addresses.is_empty() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if !dns_addresses.is_empty() { | |
if !dns.is_empty() { | |
let dns_addresses = // from above |
src/wgapi_windows.rs
Outdated
} | ||
|
||
info!( | ||
"Prepared WireGuard configuration: {}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Prepared WireGuard configuration: {}", | |
"Prepared WireGuard configuration: {wireguard_configuration}", |
src/wgapi_windows.rs
Outdated
})?; | ||
|
||
info!( | ||
"Service installation output: {:?}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Service installation output: {:?}", | |
"Service installation output: {service_installation_output:?}", |
src/wgapi_windows.rs
Outdated
} | ||
} | ||
|
||
debug!("Read interface data: {:?}", host); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debug!("Read interface data: {:?}", host); | |
debug!("Read interface data: {host:?}"); |
Cargo.toml
Outdated
@@ -17,6 +17,7 @@ serde = { version = "1.0", features = ["derive"] } | |||
thiserror = "1.0" | |||
|
|||
[dev-dependencies] | |||
env_logger = "0.10.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
env_logger = "0.10.1" | |
env_logger = "0.10" |
examples/client.rs
Outdated
wgapi.configure_interface(&interface_config)?; | ||
#[cfg(windows)] | ||
wgapi.configure_interface(&interface_config, &Vec::new())?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wgapi.configure_interface(&interface_config, &Vec::new())?; | |
wgapi.configure_interface(&interface_config, &[])?; |
examples/server.rs
Outdated
wgapi.configure_interface(&interface_config)?; | ||
#[cfg(windows)] | ||
wgapi.configure_interface(&interface_config, &Vec::new())?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wgapi.configure_interface(&interface_config, &Vec::new())?; | |
wgapi.configure_interface(&interface_config, &[])?; |
examples/userspace.rs
Outdated
api.configure_interface(&interface_config)?; | ||
#[cfg(windows)] | ||
api.configure_interface(&interface_config, &Vec::new())?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
api.configure_interface(&interface_config, &Vec::new())?; | |
api.configure_interface(&interface_config, &[])?; |
return Ok(Self(Box::new(WireguardApiUserspace::new(ifname)?))); | ||
|
||
#[cfg(not(target_family = "unix"))] | ||
return Err(WireguardInterfaceError::UserspaceNotSupported); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return Err(WireguardInterfaceError::UserspaceNotSupported); | |
Err(WireguardInterfaceError::UserspaceNotSupported) |
src/wgapi_windows.rs
Outdated
|
||
if !dns.is_empty() { | ||
let dns_addresses = format!( | ||
"{}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"{}", | |
"\nDNS ={}", |
src/wgapi_windows.rs
Outdated
.collect::<Vec<String>>() | ||
.join(",") | ||
); | ||
wireguard_configuration.push_str(format!("\nDNS = {}", dns_addresses).as_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wireguard_configuration.push_str(format!("\nDNS = {}", dns_addresses).as_str()); | |
wireguard_configuration.push_str(dns_addresses.as_str()); |
src/wgapi_windows.rs
Outdated
} | ||
|
||
for peer in &config.peers { | ||
wireguard_configuration.push_str("\n[Peer]"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wireguard_configuration.push_str("\n[Peer]"); | |
// wireguard_configuration.push_str("\n[Peer]"); |
src/wgapi_windows.rs
Outdated
for peer in &config.peers { | ||
wireguard_configuration.push_str("\n[Peer]"); | ||
wireguard_configuration | ||
.push_str(format!("\nPublicKey = {}", peer.public_key.to_string()).as_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.push_str(format!("\nPublicKey = {}", peer.public_key.to_string()).as_str()); | |
.push_str(format!("\n[Peer]\nPublicKey = {}", peer.public_key.to_string()).as_str()); |
src/wgapi_windows.rs
Outdated
} | ||
|
||
let allowed_ips = format!( | ||
"{}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"{}", | |
"\nAllowedIPs = {}", |
src/wgapi_windows.rs
Outdated
.collect::<Vec<String>>() | ||
.join(",") | ||
); | ||
wireguard_configuration.push_str(format!("\nAllowedIPs = {}", allowed_ips).as_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wireguard_configuration.push_str(format!("\nAllowedIPs = {}", allowed_ips).as_str()); | |
wireguard_configuration.push_str(allowed_ips.as_str()); |
No description provided.