Skip to content

Commit

Permalink
change some logs under linux (#79)
Browse files Browse the repository at this point in the history
* change some logs under linux

* fmt
  • Loading branch information
t-aleksander authored Oct 17, 2024
1 parent 996fd55 commit fbb88ee
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "defguard_wireguard_rs"
version = "0.5.4"
version = "0.5.5"
edition = "2021"
description = "A unified multi-platform high-level API for managing WireGuard interfaces"
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ pub(crate) fn clear_dns(ifname: &str) -> Result<(), WireguardInterfaceError> {
let mut cmd = Command::new("resolvconf");
let output = cmd.args(args).output()?;
check_command_output_status(output)?;
info!("DNS configuration removed successfully for interface {ifname}");
debug!("DNS configuration removed successfully for interface {ifname}");
Ok(())
}

Expand Down
12 changes: 9 additions & 3 deletions src/wgapi_freebsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,17 @@ impl WireguardInterfaceApi for WGApi<Kernel> {
);
self.assign_address(&address)?;
// configure interface
debug!("Setting host configuration for interface {}", self.ifname);
debug!(
"Applying the WireGuard host configuration for interface {}",
self.ifname
);
let host = config.try_into()?;
bsd::set_host(&self.ifname, &host)?;
debug!("Host configuration set for interface {}.", self.ifname);
trace!("Host configuration: {host:?}");
debug!(
"WireGuard host configuration set for interface {}.",
self.ifname
);
trace!("WireGuard host configuration: {host:?}");

// Set maximum transfer unit (MTU).
if let Some(mtu) = config.mtu {
Expand Down
31 changes: 23 additions & 8 deletions src/wgapi_linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,15 @@ impl WireguardInterfaceApi for WGApi<Kernel> {
);

// flush all IP addresses
debug!("Flushing all IP addresses from interface {}", self.ifname);
debug!(
"Flushing all existing IP addresses from interface {} before assigning a new one",
self.ifname
);
netlink::flush_interface(&self.ifname)?;
debug!("All IP addresses flushed from interface {}", self.ifname);
debug!(
"All existing IP addresses flushed from interface {}",
self.ifname
);

// assign IP address to interface
debug!(
Expand All @@ -57,11 +63,17 @@ impl WireguardInterfaceApi for WGApi<Kernel> {
);

// configure interface
debug!("Setting host configuration for interface {}", self.ifname);
debug!(
"Applying the WireGuard host configuration for interface {}",
self.ifname
);
let host = config.try_into()?;
netlink::set_host(&self.ifname, &host)?;
debug!("Host configuration set for interface {}.", self.ifname);
trace!("Host configuration: {host:?}");
debug!(
"WireGuard host configuration set for interface {}.",
self.ifname
);
trace!("WireGuard host configuration: {host:?}");

// set maximum transfer unit
if let Some(mtu) = config.mtu {
Expand Down Expand Up @@ -102,12 +114,15 @@ impl WireguardInterfaceApi for WGApi<Kernel> {

fn remove_interface(&self) -> Result<(), WireguardInterfaceError> {
debug!(
"Removing interface {}. Getting its host configuration first...",
"Removing interface {}. Getting its WireGuard host configuration first...",
self.ifname
);
let host = netlink::get_host(&self.ifname)?;
debug!("Host configuration read for interface {}", self.ifname);
trace!("Host configuration: {host:?}");
debug!(
"WireGuard host configuration read for interface {}",
self.ifname
);
trace!("WireGuard host configuration: {host:?}");
if let Some(fwmark) = host.fwmark {
if fwmark != 0 {
debug!("Cleaning fwmark rules for interface {}", self.ifname);
Expand Down
9 changes: 6 additions & 3 deletions src/wgapi_userspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,16 @@ impl WireguardInterfaceApi for WGApi<Userspace> {

// configure interface
debug!(
"Applying the interface configuration to interface {}",
"Applying the WireGuard host configuration for interface {}",
self.ifname
);
let host = config.try_into()?;
self.write_host(&host)?;
debug!("Interface configuration set for interface {}.", self.ifname);
trace!("Interface configuration: {host:?}");
debug!(
"WireGuard host configuration set for interface {}.",
self.ifname
);
trace!("WireGuard host configuration: {host:?}");

// Set maximum transfer unit (MTU).
if let Some(mtu) = config.mtu {
Expand Down

0 comments on commit fbb88ee

Please sign in to comment.