Skip to content
This repository has been archived by the owner on Oct 27, 2024. It is now read-only.

Support set wintun dns servers #74

Merged
merged 2 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions src/platform/windows/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ impl Device {
.unwrap_or(IpAddr::V4(Ipv4Addr::new(255, 255, 255, 0)));
let gateway = config.destination.map(IpAddr::from);
adapter.set_network_addresses_tuple(address, mask, gateway)?;
if let Some(dns_servers) = &config.platform_config.dns_servers {
adapter.set_dns_servers(dns_servers)?;
}
let mtu = config.mtu.unwrap_or(crate::DEFAULT_MTU);

let session = adapter.start_session(wintun::MAX_RING_CAPACITY)?;
Expand Down
7 changes: 7 additions & 0 deletions src/platform/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

mod device;

use std::net::IpAddr;

pub use device::{Device, Tun};

use crate::configuration::Configuration;
Expand All @@ -26,6 +28,7 @@ use crate::error::Result;
pub struct PlatformConfig {
pub(crate) device_guid: Option<u128>,
pub(crate) wintun_path: Option<String>,
pub(crate) dns_servers: Option<Vec<IpAddr>>,
}

impl PlatformConfig {
Expand All @@ -40,6 +43,10 @@ impl PlatformConfig {
pub fn custom_wintun_path(&mut self, wintun_path: Option<String>) {
self.wintun_path = wintun_path;
}

pub fn dns_servers(&mut self, dns_servers: Option<Vec<IpAddr>>) {
self.dns_servers = dns_servers;
}
}

/// Create a TUN device with the given name.
Expand Down