summaryrefslogtreecommitdiffstats
path: root/src/platform/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/platform/mod.rs')
-rw-r--r--src/platform/mod.rs23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/platform/mod.rs b/src/platform/mod.rs
index de33714..a0bbc13 100644
--- a/src/platform/mod.rs
+++ b/src/platform/mod.rs
@@ -2,21 +2,32 @@ use std::error::Error;
use super::wireguard::bind::Bind;
use super::wireguard::tun::Tun;
+use super::wireguard::Endpoint;
+
+#[cfg(test)]
+mod dummy;
#[cfg(target_os = "linux")]
mod linux;
#[cfg(target_os = "linux")]
-pub use linux::PlatformTun;
+pub use linux::LinuxTun as TunInstance;
+
+pub trait BindOwner: Send {
+ type Error: Error;
+
+ fn set_fwmark(&self, value: Option<u32>) -> Option<Self::Error>;
+}
-pub trait UDPBind: Bind {
- type Closer;
+pub trait PlatformBind: Bind {
+ type Owner: BindOwner;
/// Bind to a new port, returning the reader/writer and
- /// an associated instance of the Closer type, which closes the UDP socket upon "drop".
- fn bind(port: u16) -> Result<(Self::Reader, Self::Writer, Self::Closer), Self::Error>;
+ /// an associated instance of the owner type, which closes the UDP socket upon "drop"
+ /// and enables configuration of the fwmark value.
+ fn bind(port: u16) -> Result<(Vec<Self::Reader>, Self::Writer, Self::Owner), Self::Error>;
}
-pub trait TunBind: Tun {
+pub trait PlatformTun: Tun {
fn create(name: &str) -> Result<(Vec<Self::Reader>, Self::Writer, Self::MTU), Self::Error>;
}