diff options
author | Lia Lenckowski <lialenck@protonmail.com> | 2024-08-12 15:58:47 +0200 |
---|---|---|
committer | Lia Lenckowski <lialenck@protonmail.com> | 2024-08-12 15:58:47 +0200 |
commit | 4eb52cd5998235c2bffdbb4ebf8dac7e87f73888 (patch) | |
tree | 5c284b64d5da4ca5aa1012e6c745f51d927dba7f | |
parent | c5ae944b3d0442cf8c0015d42e32c1ceea8d1c20 (diff) | |
download | maesch-4eb52cd5998235c2bffdbb4ebf8dac7e87f73888.tar maesch-4eb52cd5998235c2bffdbb4ebf8dac7e87f73888.tar.bz2 maesch-4eb52cd5998235c2bffdbb4ebf8dac7e87f73888.tar.zst |
start implementing dbus stuff
-rw-r--r-- | Cargo.lock | 371 | ||||
-rw-r--r-- | Cargo.toml | 6 | ||||
-rw-r--r-- | src/daemon.rs | 153 | ||||
-rw-r--r-- | src/main.rs | 1 |
4 files changed, 503 insertions, 28 deletions
@@ -3,6 +3,21 @@ version = 3 [[package]] +name = "addr2line" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] name = "aho-corasick" version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -83,6 +98,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] +name = "backtrace" +version = "0.3.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] name = "base64" version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -113,6 +143,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] +name = "cc" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "504bdec147f2cc13c8b57ed9401fd8a147cc66b67ad5cb241394244f2c947549" + +[[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -171,6 +207,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] +name = "dbus" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bb21987b9fb1613058ba3843121dd18b163b254d8a6e797e144cbac14d96d1b" +dependencies = [ + "futures-channel", + "futures-util", + "libc", + "libdbus-sys", + "winapi", +] + +[[package]] +name = "dbus-crossroads" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a4c83437187544ba5142427746835061b330446ca8902eabd70e4afb8f76de0" +dependencies = [ + "dbus", +] + +[[package]] +name = "dbus-tokio" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "007688d459bc677131c063a3a77fb899526e17b7980f390b69644bdbc41fad13" +dependencies = [ + "dbus", + "libc", + "tokio", +] + +[[package]] name = "defguard_wireguard_rs" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -214,6 +283,95 @@ dependencies = [ ] [[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-executor" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] name = "getrandom" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -225,12 +383,24 @@ dependencies = [ ] [[package]] +name = "gimli" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" + +[[package]] name = "heck" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] name = "humantime" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -255,6 +425,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] +name = "libdbus-sys" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06085512b750d640299b79be4bad3d2fa90a9c00b1fd9e1b46364f66f0485c72" +dependencies = [ + "pkg-config", +] + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] name = "log" version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -276,17 +465,43 @@ dependencies = [ ] [[package]] +name = "miniz_oxide" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" +dependencies = [ + "hermit-abi", + "libc", + "wasi", + "windows-sys", +] + +[[package]] name = "mäsch" version = "0.1.0" dependencies = [ "atomic-write-file", "clap", + "dbus", + "dbus-crossroads", + "dbus-tokio", "defguard_wireguard_rs", "env_logger", + "futures", "log", "serde", "serde_json", "thiserror", + "tokio", "xdg", ] @@ -389,12 +604,62 @@ dependencies = [ ] [[package]] +name = "object" +version = "0.36.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" +dependencies = [ + "memchr", +] + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] name = "paste" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + +[[package]] name = "ppv-lite86" version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -452,6 +717,15 @@ dependencies = [ ] [[package]] +name = "redox_syscall" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +dependencies = [ + "bitflags 2.6.0", +] + +[[package]] name = "regex" version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -481,12 +755,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] name = "ryu" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] name = "serde" version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -519,6 +805,40 @@ dependencies = [ ] [[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] name = "strsim" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -556,6 +876,35 @@ dependencies = [ ] [[package]] +name = "tokio" +version = "1.39.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys", +] + +[[package]] +name = "tokio-macros" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -574,6 +923,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -13,3 +13,9 @@ serde_json = "1" serde = { version = "1", features = ["derive"] } thiserror = "1" xdg = "2" + +tokio = { version = "1", features = ["full"] } # TODO features restricten +dbus = "0" +dbus-tokio = "0" +dbus-crossroads = "0" +futures = "0" diff --git a/src/daemon.rs b/src/daemon.rs index 1c746fd..220c286 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -1,14 +1,23 @@ use atomic_write_file::AtomicWriteFile; use core::net::SocketAddr; -use defguard_wireguard_rs::{host::Peer, InterfaceConfiguration, WGApi, WireguardInterfaceApi}; -use defguard_wireguard_rs::{key::Key, net::IpAddrMask}; +use dbus::{channel::MatchingReceiver, message::MatchRule}; +use dbus_crossroads::Crossroads; +use defguard_wireguard_rs::{ + host::Peer, key::Key, net::IpAddrMask, InterfaceConfiguration, WGApi, WireguardInterfaceApi, +}; +use futures::future; use log::{info, warn}; use serde::{Deserialize, Serialize}; -use std::collections::BTreeSet; -use std::fs::File; -use std::io::{ErrorKind, Read, Write}; -use std::net::{TcpListener, ToSocketAddrs}; +use std::{ + collections::{HashMap, BTreeSet}, + fs::File, + io::{ErrorKind, Read, Write}, + net::ToSocketAddrs, + sync::Arc, + time::SystemTime, +}; use thiserror::Error; +use tokio::{net::TcpListener, runtime::Builder, sync::RwLock, task}; use xdg::BaseDirectories; use std::str::FromStr; @@ -26,7 +35,13 @@ pub enum DaemonError { Decoding(#[from] serde_json::Error), #[error("{0}")] + IpMaskParse(#[from] defguard_wireguard_rs::net::IpAddrParseError), + + #[error("{0}")] WgInterfaceError(#[from] defguard_wireguard_rs::error::WireguardInterfaceError), + + #[error("{0}")] + DbusError(#[from] dbus::Error), } #[derive(Serialize, Deserialize, Clone)] @@ -38,12 +53,16 @@ enum Endpoint { // subset of defguard_wireguard_rs::host::Peer, with hostname added #[derive(Serialize, Deserialize)] struct PeerConfig { - pubkey: Key, psk: Option<Key>, ips: Vec<(IpAddrMask, Option<String>)>, // if false: the hostnames are kept around for sharing, but we personally do not use them use_hostnames: bool, endpoint: Option<Endpoint>, + + last_changed: SystemTime, + known_to: Vec<usize>, + + mäsch_endpoint: SocketAddr, } fn default_wg_port() -> u16 { @@ -52,7 +71,6 @@ fn default_wg_port() -> u16 { #[derive(Serialize, Deserialize)] struct Network { - name: String, privkey: String, // this really should be a different type, but this is what defguard takes... @@ -61,12 +79,27 @@ struct Network { #[serde(default = "default_wg_port")] listen_port: u16, - peers: Vec<PeerConfig>, + peers: HashMap<Key, PeerConfig>, + + mäsch_port: u16, } #[derive(Serialize, Deserialize, Default)] struct Config { - networks: Vec<Network>, + networks: HashMap<String, Network>, +} + +struct State { + conf: Config, + apis: HashMap<String, WGApi>, +} + +impl Drop for State { + fn drop(&mut self) { + for api in self.apis.values() { + let _ = api.remove_interface(); + } + } } pub fn daemon() -> Result<(), DaemonError> { @@ -80,22 +113,18 @@ pub fn daemon() -> Result<(), DaemonError> { }; info!("read config"); - //let networks = vec![Network { - // name: "kek".to_string(), + //let networks: HashMap<String, Network> = vec![("kek".to_owned(), Network { // privkey: "OK9WQudPVO5rXxcdxdtTzRmJzVu+KuqLMstYsZd8mWE=".to_string(), // address: "1.2.3.4".to_string(), // listen_port: 5221, // peers: vec![PeerConfig { // pubkey: Key::from_str("Osrxi/bRVK+FQit7YMbIgSaOWmRDOZQoh/7ddV4eEE8=").unwrap(), // psk: Some(Key::from_str("wFiG3II9ivYBn+xjLGChC0PjNlbOibZ1K6pmspPD0Hg=").unwrap()), - // use_hostnames: true, + // use_hostnames: false, // endpoint: Some(Endpoint::Domain("alex.69owo.de".to_string(), 12456)), // ips: vec![(IpAddrMask::from_str("5.4.3.2/24").unwrap(), Some("blah.blub".to_owned()))], // }], - //}]; - - // TODO call wg.remove_interface on program exit using a drop impl on an 'Interface' struct - // containing the Network and WGApi + //})].into_iter().collect(); let mut hostfile = match File::open("/etc/hosts") { Ok(mut f) => { @@ -121,13 +150,18 @@ pub fn daemon() -> Result<(), DaemonError> { } }; - for nw in config.networks { - let wg = WGApi::new(nw.name.clone(), false)?; + let mut state = State { + conf: config, + apis: HashMap::new(), + }; + + for (name, nw) in &state.conf.networks { + let wg = WGApi::new(name.clone(), false)?; let defguard_peers = nw .peers .iter() - .map(|p| Peer { - public_key: p.pubkey.clone(), + .map(|(peer_key, p)| Peer { + public_key: peer_key.clone(), preshared_key: p.psk.clone(), protocol_version: None, endpoint: p @@ -151,16 +185,16 @@ pub fn daemon() -> Result<(), DaemonError> { .collect(); wg.create_interface()?; wg.configure_interface(&InterfaceConfiguration { - name: nw.name.clone(), - prvkey: nw.privkey, - address: nw.address, + name: name.clone(), + prvkey: nw.privkey.clone(), + address: nw.address.clone(), port: nw.listen_port as u32, peers: defguard_peers, })?; if let Some((hosts_str, hosts)) = &mut hostfile { nw.peers - .iter() + .values() .map(|peer| { if peer.use_hostnames { peer.ips @@ -181,7 +215,9 @@ pub fn daemon() -> Result<(), DaemonError> { .count(); } - info!("loaded configuration for {0}", nw.name); + state.apis.insert(name.clone(), wg); + + info!("loaded configuration for {0}", name); } info!("loaded all existing configurations"); @@ -190,10 +226,71 @@ pub fn daemon() -> Result<(), DaemonError> { let mut f = AtomicWriteFile::open("/etc/hosts")?; f.write(hosts_str.as_bytes())?; - f.commit(); + f.commit()?; } - // TODO open dbus & network interfaces + let state = Arc::new(RwLock::new(state)); + + let rt = Builder::new_current_thread().enable_all().build()?; + rt.block_on(run_listeners(state))?; + + Ok(()) +} + +async fn run_listeners(state: Arc<RwLock<State>>) -> Result<(), DaemonError> { + for (name, nw) in &state.read().await.conf.networks { + let addr = IpAddrMask::from_str(&nw.address)?.ip; + let listener = TcpListener::bind((addr, nw.mäsch_port)).await?; + + task::spawn(make_fatal(run_network( + state.clone(), + listener, + name.clone(), + ))); + } + + let mut cr = Crossroads::new(); + let if_token = cr.register("de.69owo.maesch", |b| { + b.signal::<(String, String), _>("Proposal", ("network", "peer_data")); + //b.method_with_cr_async("MigrateQuick"); + }); + + cr.insert("/de/69owo/maesch", &[if_token], state.clone()); + + let (res, c) = dbus_tokio::connection::new_session_sync()?; + let _ = tokio::spawn(make_fatal(async { + res.await; + Result::<!, &'static str>::Err("lost connection to dbus!") + })); + + c.start_receive( + MatchRule::new_method_call(), + Box::new(move |msg, conn| { + cr.handle_message(msg, conn).unwrap(); + true + }), + ); + + c.request_name("de.69owo.maesch", true, true, false).await?; + future::pending::<!>().await +} + +async fn make_fatal<E: std::fmt::Display, O, F: std::future::Future<Output = Result<O, E>>>( + f: F, +) -> () { + match f.await { + Err(e) => { + eprintln!("oh no: {e}"); + std::process::exit(1); + } + _ => (), + }; +} +async fn run_network( + state: Arc<RwLock<State>>, + sock: TcpListener, + nw_name: String, +) -> Result<(), DaemonError> { Ok(()) } diff --git a/src/main.rs b/src/main.rs index d85da33..c61306c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ #![feature(let_chains)] +#![feature(never_type)] pub mod daemon; |