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: Dns configuration #93

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src-tauri/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 src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ anyhow = "1.0"
base64 = "0.21"
clap = { version = "4.4", features = ["derive", "env"] }
chrono = { version = "0.4", features = ["serde"] }
defguard_wireguard_rs = { git = "https://github.com/DefGuard/wireguard-rs.git", tag = "v0.3.0" }
defguard_wireguard_rs = { git = "https://github.com/DefGuard/wireguard-rs.git", branch = "main" }
dirs = "5.0"
local-ip-address = "0.5"
log = "0.4"
Expand Down
14 changes: 14 additions & 0 deletions src-tauri/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,20 @@ impl DesktopDaemonService for DaemonService {
Status::new(Code::Internal, msg)
})?;

// Configure dns
debug!("Configuring DNS for interface {ifname}");
let dns: Vec<IpAddr> = request
.dns
.into_iter()
.filter_map(|s| s.parse().ok())
.collect();

wgapi.configure_dns(&dns).map_err(|err| {
let msg = format!("Failed to configure DNS for WireGuard interface {ifname}: {err}");
error!("{msg}");
Status::new(Code::Internal, msg)
})?;

Ok(Response::new(()))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export const LocationUsageChart = ({
}, [padding]);

if (!data.length) return null;

return (
<div className="location-usage">
<div className="summary">
Expand Down Expand Up @@ -153,6 +152,7 @@ export const LocationUsageChart = ({
tickLine={{ stroke: colors.surfaceDefaultModal }}
hide={hideX}
padding={getPadding}
dx={3}
tick={{
fontSize: 12,
color: '#222',
Expand Down Expand Up @@ -188,4 +188,6 @@ export const LocationUsageChart = ({
);
};

const formatXTick = (tickData: number) => dayjs.utc(tickData).local().format('HH:mm');
// FIXME: hack with spaces to avoid tick overlapping
const formatXTick = (tickData: number) =>
dayjs.utc(tickData).local().format('HH:mm:ss ');