diff options
author | Alex Auvolat <alex@adnab.me> | 2023-03-09 14:41:16 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2023-03-09 14:41:16 +0100 |
commit | b06e50a5bef3d79f51a06f73bb9f97210302fe1a (patch) | |
tree | 7e2bf6fc16461c2c21847f085e885270c604d2f8 /src | |
parent | 3acf041d00a20b6c139e2a0202dafb29a1deecd4 (diff) | |
download | wgautomesh-b06e50a5bef3d79f51a06f73bb9f97210302fe1a.tar.gz wgautomesh-b06e50a5bef3d79f51a06f73bb9f97210302fe1a.zip |
do more things at init time
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 091335f..f951f94 100644 --- a/src/main.rs +++ b/src/main.rs @@ -201,8 +201,8 @@ impl Daemon { } fn run(&self) -> Result<()> { - if let Err(e) = self.state.lock().unwrap().setup_wg_peers(self, 0) { - error!("Error initializing wireguard peers: {}", e); + if let Err(e) = self.initialize() { + error!("Error while initializing Wireguard configuration: {}", e); } let request = self.make_packet(&Gossip::Request)?; @@ -222,6 +222,13 @@ impl Daemon { unreachable!() } + fn initialize(&self) -> Result<()> { + let mut state = self.state.lock().unwrap(); + state.read_wg_peers(self)?; + state.setup_wg_peers(self, 0)?; + Ok(()) + } + fn wg_loop(&self) -> ! { let mut i = 0; loop { |