Skip to content
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

Merged
merged 94 commits into from
Jan 11, 2024
Merged

Conversation

blazej-teonite
Copy link
Contributor

No description provided.

let file_path = path.join(&file_name).display().to_string();

debug!(
"Creating WireGuard configuration file {} in: {}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Creating WireGuard configuration file {} in: {}",
"Creating WireGuard configuration file {file_name} in: {file_path}",

// 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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let file_path = path.join(&file_name).display().to_string();
let file_path = path.join(&file_name).to_str().unwrap_or_default();

config.prvkey, config.address
);

if !dns_addresses.is_empty() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if !dns_addresses.is_empty() {
if !dns.is_empty() {
let dns_addresses = // from above

}

info!(
"Prepared WireGuard configuration: {}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Prepared WireGuard configuration: {}",
"Prepared WireGuard configuration: {wireguard_configuration}",

})?;

info!(
"Service installation output: {:?}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Service installation output: {:?}",
"Service installation output: {service_installation_output:?}",

}
}

debug!("Read interface data: {:?}", host);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
env_logger = "0.10.1"
env_logger = "0.10"

wgapi.configure_interface(&interface_config)?;
#[cfg(windows)]
wgapi.configure_interface(&interface_config, &Vec::new())?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
wgapi.configure_interface(&interface_config, &Vec::new())?;
wgapi.configure_interface(&interface_config, &[])?;

wgapi.configure_interface(&interface_config)?;
#[cfg(windows)]
wgapi.configure_interface(&interface_config, &Vec::new())?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
wgapi.configure_interface(&interface_config, &Vec::new())?;
wgapi.configure_interface(&interface_config, &[])?;

api.configure_interface(&interface_config)?;
#[cfg(windows)]
api.configure_interface(&interface_config, &Vec::new())?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return Err(WireguardInterfaceError::UserspaceNotSupported);
Err(WireguardInterfaceError::UserspaceNotSupported)


if !dns.is_empty() {
let dns_addresses = format!(
"{}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"{}",
"\nDNS ={}",

.collect::<Vec<String>>()
.join(",")
);
wireguard_configuration.push_str(format!("\nDNS = {}", dns_addresses).as_str());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
wireguard_configuration.push_str(format!("\nDNS = {}", dns_addresses).as_str());
wireguard_configuration.push_str(dns_addresses.as_str());

}

for peer in &config.peers {
wireguard_configuration.push_str("\n[Peer]");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
wireguard_configuration.push_str("\n[Peer]");
// wireguard_configuration.push_str("\n[Peer]");

for peer in &config.peers {
wireguard_configuration.push_str("\n[Peer]");
wireguard_configuration
.push_str(format!("\nPublicKey = {}", peer.public_key.to_string()).as_str());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.push_str(format!("\nPublicKey = {}", peer.public_key.to_string()).as_str());
.push_str(format!("\n[Peer]\nPublicKey = {}", peer.public_key.to_string()).as_str());

}

let allowed_ips = format!(
"{}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"{}",
"\nAllowedIPs = {}",

.collect::<Vec<String>>()
.join(",")
);
wireguard_configuration.push_str(format!("\nAllowedIPs = {}", allowed_ips).as_str());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
wireguard_configuration.push_str(format!("\nAllowedIPs = {}", allowed_ips).as_str());
wireguard_configuration.push_str(allowed_ips.as_str());

@blazej-teonite blazej-teonite marked this pull request as ready for review January 11, 2024 11:28
@blazej-teonite blazej-teonite merged commit a5b21a5 into main Jan 11, 2024
1 check passed
@blazej-teonite blazej-teonite deleted the 8-add-windows-support-for-defguard-client branch January 11, 2024 11:31
@wojcik91 wojcik91 added the enhancement New feature or request label Jan 23, 2024
@wojcik91 wojcik91 changed the title 8 add windows support for defguard client feat: Windows support Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Windows support for defguard client
4 participants