aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2023-05-07 14:48:30 +0200
committerHimbeerserverDE <himbeerserverde@gmail.com>2023-05-07 14:48:30 +0200
commit6024d3323b90e8511a23f546d0e00aa4a5550ee4 (patch)
tree20c1beb0a0b229a39bcbbaf792c0be2af5f54c9b
parent2fcc60a163dcc66e7e96967d7b88042d945ae7b2 (diff)
import config struct instead of defining it
-rw-r--r--Cargo.lock12
-rw-r--r--Cargo.toml3
-rw-r--r--src/main.rs33
3 files changed, 12 insertions, 36 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 85bd44b..6d7db01 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -885,13 +885,12 @@ name = "rsdsl_6in4"
version = "0.1.0"
dependencies = [
"byteorder",
- "ipnet",
"libc",
"notify",
"reqwest",
+ "rsdsl_he_config",
"rsdsl_ip_config",
"rsdsl_netlinkd",
- "serde",
"serde_json",
"socket2 0.5.2",
"thiserror",
@@ -899,6 +898,15 @@ dependencies = [
]
[[package]]
+name = "rsdsl_he_config"
+version = "0.1.0"
+source = "git+https://github.com/rsdsl/he_config.git#602b64314e53db90923a32c93ebe95c12db69d4c"
+dependencies = [
+ "ipnet",
+ "serde",
+]
+
+[[package]]
name = "rsdsl_ip_config"
version = "0.1.0"
source = "git+https://github.com/rsdsl/ip_config.git#e13adb9cc9367ad93f1e947335b0d56108015999"
diff --git a/Cargo.toml b/Cargo.toml
index f6e5296..5a61c89 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,13 +7,12 @@ edition = "2021"
[dependencies]
byteorder = "1.4.3"
-ipnet = "2.7.2"
libc = "0.2.143"
notify = "5.1.0"
reqwest = { version = "0.11.17", default-features = false, features = ["blocking", "rustls-tls"] }
+rsdsl_he_config = { git = "https://github.com/rsdsl/he_config.git", version = "0.1.0" }
rsdsl_ip_config = { git = "https://github.com/rsdsl/ip_config.git", version = "0.1.0" }
rsdsl_netlinkd = { git = "https://github.com/rsdsl/netlinkd.git", version = "0.3.0" }
-serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
socket2 = { version = "0.5.2", features = ["all"] }
thiserror = "1.0"
diff --git a/src/main.rs b/src/main.rs
index d3c74ff..8267508 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -10,13 +10,12 @@ use std::thread;
use std::time::Duration;
use byteorder::{ByteOrder, NetworkEndian as NE};
-use ipnet::Ipv6Net;
use notify::event::{CreateKind, ModifyKind};
use notify::{Event, EventKind, RecursiveMode, Watcher};
+use rsdsl_he_config::{Config, UsableConfig};
use rsdsl_ip_config::IpConfig;
use rsdsl_netlinkd::error::Result;
use rsdsl_netlinkd::{addr, link, route};
-use serde::{Deserialize, Serialize};
use socket2::{Socket, Type};
use thiserror::Error;
use tun_tap::{Iface, Mode};
@@ -33,36 +32,6 @@ enum Error {
SerdeJson(#[from] serde_json::Error),
}
-#[derive(Clone, Debug, Serialize, Deserialize)]
-struct Config {
- pub serv: Ipv4Addr,
- pub tn64: Ipv6Addr,
- pub rt64: Ipv6Addr,
- pub rt48: Ipv6Addr,
- pub updt: String,
-}
-
-#[derive(Clone, Debug)]
-struct UsableConfig {
- pub serv: Ipv4Addr,
- pub tn64: Ipv6Net,
- pub rt64: Ipv6Net,
- pub rt48: Ipv6Net,
- pub updt: String,
-}
-
-impl From<Config> for UsableConfig {
- fn from(config: Config) -> Self {
- Self {
- serv: config.serv,
- tn64: Ipv6Net::new(config.tn64, 64).unwrap(),
- rt64: Ipv6Net::new(config.rt64, 64).unwrap(),
- rt48: Ipv6Net::new(config.rt48, 48).unwrap(),
- updt: config.updt,
- }
- }
-}
-
const LINK_LOCAL: Ipv6Addr = Ipv6Addr::new(0xfe80, 0, 0, 0, 0, 0, 0, 1);
fn send_to(ifi: i32, sock: &Socket, buf: &[u8]) -> io::Result<usize> {