From 68ed0da96028acb3a80caec9b654de6f1000e634 Mon Sep 17 00:00:00 2001 From: Max Niederman Date: Sun, 29 Sep 2024 22:30:01 -0700 Subject: [PATCH] feat(api): create centipede_api package --- Cargo.lock | 432 +----------------- packages/centipede/src/config.rs | 49 -- packages/centipede_api/Cargo.toml | 10 + packages/centipede_api/src/lib.rs | 72 +++ packages/{centipede => centipeded}/Cargo.toml | 8 +- .../{centipede => centipeded}/src/main.rs | 6 +- 6 files changed, 110 insertions(+), 467 deletions(-) delete mode 100644 packages/centipede/src/config.rs create mode 100644 packages/centipede_api/Cargo.toml create mode 100644 packages/centipede_api/src/lib.rs rename packages/{centipede => centipeded}/Cargo.toml (67%) rename packages/{centipede => centipeded}/src/main.rs (98%) diff --git a/Cargo.lock b/Cargo.lock index ca3f433..fefc86b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -36,21 +36,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - [[package]] name = "anstream" version = "0.6.13" @@ -105,12 +90,6 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - [[package]] name = "backtrace" version = "0.3.71" @@ -168,12 +147,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "bumpalo" -version = "3.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" - [[package]] name = "cc" version = "1.0.90" @@ -181,28 +154,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" [[package]] -name = "centipede" +name = "centipede_api" version = "0.1.0" dependencies = [ - "base64 0.21.7", - "centipede_control", - "centipede_router", - "centipede_worker", "cidr", - "clap", - "ctrlc", "ed25519-dalek", - "hypertube", - "log", - "miette", - "mio", "num_cpus", - "pretty_env_logger", - "rand", "serde", - "serde_with", - "thiserror", - "toml", ] [[package]] @@ -257,6 +215,25 @@ dependencies = [ "thiserror", ] +[[package]] +name = "centipeded" +version = "0.1.0" +dependencies = [ + "base64 0.21.7", + "centipede_control", + "centipede_router", + "centipede_worker", + "clap", + "ctrlc", + "hypertube", + "log", + "miette", + "mio", + "pretty_env_logger", + "rand", + "thiserror", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -293,19 +270,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "chrono" -version = "0.4.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb" -dependencies = [ - "android-tzdata", - "iana-time-zone", - "num-traits", - "serde", - "windows-targets 0.52.0", -] - [[package]] name = "cidr" version = "0.2.2" @@ -345,7 +309,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.0", + "strsim", ] [[package]] @@ -378,12 +342,6 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" -[[package]] -name = "core-foundation-sys" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -443,41 +401,6 @@ dependencies = [ "syn", ] -[[package]] -name = "darling" -version = "0.20.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc5d6b04b3fd0ba9926f945895de7d806260a2d7431ba82e7edaecb043c4c6b8" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.20.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04e48a959bcd5c761246f5d090ebc2fbf7b9cd527a492b07a67510c108f1e7e3" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim 0.10.0", - "syn", -] - -[[package]] -name = "darling_macro" -version = "0.20.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d1545d67a2149e1d93b7e5c7752dce5a7426eb5d1357ddcfd89336b94444f77" -dependencies = [ - "darling_core", - "quote", - "syn", -] - [[package]] name = "der" version = "0.7.8" @@ -488,16 +411,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "deranged" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" -dependencies = [ - "powerfmt", - "serde", -] - [[package]] name = "digest" version = "0.10.7" @@ -547,12 +460,6 @@ dependencies = [ "termcolor", ] -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - [[package]] name = "errno" version = "0.3.8" @@ -569,12 +476,6 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1676f435fc1dadde4d03e43f5d62b259e1ce5f40bd4ffb21db2b42ebe59c1382" -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - [[package]] name = "generic-array" version = "0.14.7" @@ -602,18 +503,6 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - [[package]] name = "heck" version = "0.5.0" @@ -626,12 +515,6 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3" -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - [[package]] name = "humantime" version = "2.1.0" @@ -649,57 +532,6 @@ dependencies = [ "libc", ] -[[package]] -name = "iana-time-zone" -version = "0.1.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", - "serde", -] - -[[package]] -name = "indexmap" -version = "2.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520" -dependencies = [ - "equivalent", - "hashbrown 0.14.3", - "serde", -] - [[package]] name = "inout" version = "0.1.3" @@ -738,15 +570,6 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" -[[package]] -name = "js-sys" -version = "0.3.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" -dependencies = [ - "wasm-bindgen", -] - [[package]] name = "libc" version = "0.2.153" @@ -835,21 +658,6 @@ dependencies = [ "libc", ] -[[package]] -name = "num-conv" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" - -[[package]] -name = "num-traits" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" -dependencies = [ - "autocfg", -] - [[package]] name = "num_cpus" version = "1.16.0" @@ -869,12 +677,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - [[package]] name = "opaque-debug" version = "0.3.0" @@ -914,12 +716,6 @@ dependencies = [ "universal-hash", ] -[[package]] -name = "powerfmt" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" - [[package]] name = "ppv-lite86" version = "0.2.17" @@ -1084,45 +880,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_spanned" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" -dependencies = [ - "serde", -] - -[[package]] -name = "serde_with" -version = "3.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15d167997bd841ec232f5b2b8e0e26606df2e7caa4c31b95ea9ca52b200bd270" -dependencies = [ - "base64 0.21.7", - "chrono", - "hex", - "indexmap 1.9.3", - "indexmap 2.2.2", - "serde", - "serde_derive", - "serde_json", - "serde_with_macros", - "time", -] - -[[package]] -name = "serde_with_macros" -version = "3.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "865f9743393e638991566a8b7a479043c2c8da94a33e0a31f18214c9cae0a64d" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "sha2" version = "0.10.8" @@ -1171,15 +928,9 @@ dependencies = [ [[package]] name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - -[[package]] -name = "strsim" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "subtle" @@ -1269,71 +1020,6 @@ dependencies = [ "syn", ] -[[package]] -name = "time" -version = "0.3.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" -dependencies = [ - "deranged", - "itoa", - "num-conv", - "powerfmt", - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" - -[[package]] -name = "time-macros" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" -dependencies = [ - "num-conv", - "time-core", -] - -[[package]] -name = "toml" -version = "0.8.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit", -] - -[[package]] -name = "toml_datetime" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" -dependencies = [ - "serde", -] - -[[package]] -name = "toml_edit" -version = "0.22.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9ffdf896f8daaabf9b66ba8e77ea1ed5ed0f72821b398aba62352e95062951" -dependencies = [ - "indexmap 2.2.2", - "serde", - "serde_spanned", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -1386,60 +1072,6 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "wasm-bindgen" -version = "0.2.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" - [[package]] name = "winapi" version = "0.3.9" @@ -1471,15 +1103,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-core" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" -dependencies = [ - "windows-targets 0.52.0", -] - [[package]] name = "windows-sys" version = "0.48.0" @@ -1612,15 +1235,6 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" -[[package]] -name = "winnow" -version = "0.5.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5389a154b01683d28c77f8f68f49dea75f0a4da32557a58f68ee51ebba472d29" -dependencies = [ - "memchr", -] - [[package]] name = "x25519-dalek" version = "2.0.1" diff --git a/packages/centipede/src/config.rs b/packages/centipede/src/config.rs deleted file mode 100644 index 94a4b14..0000000 --- a/packages/centipede/src/config.rs +++ /dev/null @@ -1,49 +0,0 @@ -use std::{ffi::CString, net::SocketAddr, time::Duration}; - -use cidr::IpInet; -use serde::{Deserialize, Serialize}; -use serde_with::{base64::Base64, serde_as}; - -/// Centipede configuration. -#[serde_as] -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct Centipede { - /// Address of the host on the Centipede network. - pub address: IpInet, - - /// Private key of the daemon. - #[serde_as(as = "Base64")] - pub private_key: ed25519_dalek::SecretKey, - - /// Name of the Centipede network interface. - pub interface_name: CString, - - /// Addresses on which the daemon should listen for incoming packets. - pub recv_addrs: Vec, - - /// List of peers. - pub peers: Vec, -} - -#[serde_as] -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct Peer { - /// Public key of the peer. - #[serde_as(as = "Base64")] - pub public_key: [u8; ed25519_dalek::PUBLIC_KEY_LENGTH], - - // TODO: rename to make it clear that these are only for sending messages. - /// Local addresses from which to send messages to the peer. - pub local_addrs: Vec, - - /// Known remote addresses of the peer. - pub remote_addrs: Vec, - - /// Maximum time to wait for heartbeats from the peer before disconnecting. - #[serde(default = "default_max_heartbeat_interval")] - pub max_heartbeat_interval: Duration, -} - -fn default_max_heartbeat_interval() -> Duration { - Duration::from_secs(60) -} diff --git a/packages/centipede_api/Cargo.toml b/packages/centipede_api/Cargo.toml new file mode 100644 index 0000000..189b5c7 --- /dev/null +++ b/packages/centipede_api/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "centipede_api" +version = "0.1.0" +edition = "2021" + +[dependencies] +cidr = { version = "0.2.2", features = ["serde"] } +ed25519-dalek = { version = "2.1.0", features = ["serde"] } +num_cpus = "1.16.0" +serde = { version = "1.0.195", features = ["derive"] } \ No newline at end of file diff --git a/packages/centipede_api/src/lib.rs b/packages/centipede_api/src/lib.rs new file mode 100644 index 0000000..535ceee --- /dev/null +++ b/packages/centipede_api/src/lib.rs @@ -0,0 +1,72 @@ +use std::{ffi::CString, net::SocketAddr, time::Duration}; + +use serde::{Deserialize, Serialize}; + +/// Instance of the Centipede API. +pub trait CentipedeApi { + type Error; + + /// Update or create a new interface. + fn upsert_interface(&self, id: String, interface: Interface) -> Result<(), Self::Error>; + + /// Destroy an interface. + fn destroy_interface(&self, id: String) -> Result<(), Self::Error>; + + /// Update or create a new peer. + fn upsert_peer(&self, interface: String, id: String, peer: Peer) -> Result<(), Self::Error>; + + /// Destroy a peer. + fn destroy_peer(&self, interface: String, id: String) -> Result<(), Self::Error>; + + /// Update or create a new routing policy. + fn upsert_routing_policy( + &self, + id: String, + routing_policy: ClearnetRoutingPolicy, + ) -> Result<(), Self::Error>; + + /// Destroy a routing policy. + fn destroy_routing_policy(&self, id: String) -> Result<(), Self::Error>; +} + +/// Configuration for a Centipede virtual interface. +#[derive(Serialize, Deserialize)] +pub struct Interface { + /// Private key of the interface. + pub private_key: ed25519_dalek::SecretKey, + + /// Name of the OS network interface. + pub os_name: CString, + + /// Number of workers to spawn. + #[serde(default = "num_cpus::get")] + pub workers: usize, + + /// Address of the host on the Centipede network. + pub address: Vec, +} + +/// A peer in the Centipede network. +#[derive(Serialize, Deserialize)] +pub struct Peer { + /// Public key of the peer. + pub public_key: ed25519_dalek::VerifyingKey, + + /// Name of the routing policy with which to send messages to the peer. + pub clearnet_routing_policy: String, + + /// Maximum time to wait for heartbeats from the peer before disconnecting. + #[serde(default = "default_max_heartbeat_interval")] + pub max_heartbeat_interval: Duration, +} + +/// A routing policy, specifying how to send and receive messages from a peer on the clearnet. +#[derive(Serialize, Deserialize)] +pub struct ClearnetRoutingPolicy { + /// Addresses on which to listen for incoming packets. + pub recv_addrs: Vec, +} + +fn default_max_heartbeat_interval() -> Duration { + Duration::from_secs(60) +} diff --git a/packages/centipede/Cargo.toml b/packages/centipeded/Cargo.toml similarity index 67% rename from packages/centipede/Cargo.toml rename to packages/centipeded/Cargo.toml index 726f5f5..f9517e5 100644 --- a/packages/centipede/Cargo.toml +++ b/packages/centipeded/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "centipede" +name = "centipeded" version = "0.1.0" edition = "2021" @@ -8,15 +8,9 @@ base64 = "0.21.7" centipede_router = { version = "0.1.0", path = "../centipede_router" } centipede_worker = { version = "0.1.0", path = "../centipede_worker" } centipede_control = { version = "0.1.0", path = "../centipede_control" } -cidr = { version = "0.2.2", features = ["serde"] } clap = { version = "4.5.4", features = ["derive"] } -ed25519-dalek = { version = "2.1.0", features = ["serde"] } log = { version = "0.4.21", features = ["release_max_level_debug"] } -num_cpus = "1.16.0" pretty_env_logger = "0.5.0" -serde = { version = "1.0.195", features = ["derive"] } -serde_with = { version = "3.5.0", features = ["base64"] } -toml = "0.8.8" rand = "0.8.5" hypertube = "0.2.2" mio = "0.8.11" diff --git a/packages/centipede/src/main.rs b/packages/centipeded/src/main.rs similarity index 98% rename from packages/centipede/src/main.rs rename to packages/centipeded/src/main.rs index 6685dd1..02c2255 100644 --- a/packages/centipede/src/main.rs +++ b/packages/centipeded/src/main.rs @@ -17,8 +17,6 @@ use miette::{Context, Diagnostic, IntoDiagnostic, Report, Result}; use rand::thread_rng; use thiserror::Error; -mod config; - #[derive(Debug, clap::Parser)] struct Opt { /// Path to config file. @@ -105,6 +103,10 @@ fn main() -> Result<()> { }) .expect("failed to set shutdown signal handler"); + tokio::runtime::Builder::new_current_thread() + .build() + .into_diagnostic()?; + thread::scope(|s| { { let shutdown = shutdown.clone();