diff options
author | Galen Guyer <galen@galenguyer.com> | 2022-06-11 11:28:05 -0400 |
---|---|---|
committer | Galen Guyer <galen@galenguyer.com> | 2022-06-11 11:28:05 -0400 |
commit | a66474f12175049182da1908c60bca77bf0cae6a (patch) | |
tree | b2183f17143f64fc797064e1a792795c470fc875 | |
parent | da1e4ac4461958643fe14b3da83450292cbb2ca4 (diff) |
ack
-rw-r--r-- | Cargo.lock | 31 | ||||
-rw-r--r-- | wg-conf/Cargo.toml | 1 | ||||
-rw-r--r-- | wg-conf/src/lib.rs | 33 |
3 files changed, 52 insertions, 13 deletions
@@ -82,6 +82,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] +name = "cidr" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300bccc729b1ada84523246038aad61fead689ac362bb9d44beea6f6a188c34b" + +[[package]] name = "clang-sys" version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -214,11 +220,11 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" [[package]] name = "proc-macro2" -version = "1.0.38" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9027b48e9d4c9175fa2218adf3557f91c1137021739951d4932f5f8268ac48aa" +checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] @@ -284,16 +290,16 @@ dependencies = [ ] [[package]] -name = "unicode-width" -version = "0.1.9" +name = "unicode-ident" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" +checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" [[package]] -name = "unicode-xid" -version = "0.2.3" +name = "unicode-width" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" +checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" [[package]] name = "vec_map" @@ -302,6 +308,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] +name = "wg-conf" +version = "0.0.1" +dependencies = [ + "cidr", +] + +[[package]] name = "wg-rs" version = "0.0.1" diff --git a/wg-conf/Cargo.toml b/wg-conf/Cargo.toml index b138082..13ab100 100644 --- a/wg-conf/Cargo.toml +++ b/wg-conf/Cargo.toml @@ -8,3 +8,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +cidr = "0.2.1" diff --git a/wg-conf/src/lib.rs b/wg-conf/src/lib.rs index 1b4a90c..93a5dc7 100644 --- a/wg-conf/src/lib.rs +++ b/wg-conf/src/lib.rs @@ -1,8 +1,33 @@ +use std::fmt::Display; +use cidr::IpInet; + +#[derive(Debug)] +pub struct Interface { + pub address: Vec<IpInet>, +} + +impl Display for Interface { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "[Interface]\n")?; + for address in &self.address { + write!(f, "Address = {}\n", address)? + } + Ok(()) + } +} + #[cfg(test)] -mod tests { +mod test { + use super::*; + use std::net::{IpAddr, Ipv4Addr}; + use cidr::IpInet; + #[test] - fn it_works() { - let result = 2 + 2; - assert_eq!(result, 4); + fn test_interface() { + let interface = Interface { + address: vec![IpInet::new(IpAddr::V4(Ipv4Addr::new(10, 0, 0, 1)), 24).unwrap()], + }; + + println!("{}", interface);- } } |