From 9893341622c5b15763c3e4af3e50a13ef3aed166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Fri, 15 Oct 2021 21:49:01 +0200 Subject: [PATCH] aquatic_udp: update access list at startup, exit on failure --- TODO.md | 1 - aquatic_udp/src/lib/lib.rs | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/TODO.md b/TODO.md index a28072c..775bfab 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,6 @@ # TODO * access lists: - * disallow any activity until access list is loaded / load it at startup * test functionality * rename Allow to Require? * serde-rename AccessListTypes to lowercase diff --git a/aquatic_udp/src/lib/lib.rs b/aquatic_udp/src/lib/lib.rs index b44bb33..f7bc466 100644 --- a/aquatic_udp/src/lib/lib.rs +++ b/aquatic_udp/src/lib/lib.rs @@ -6,6 +6,7 @@ use std::thread::Builder; use std::time::Duration; use anyhow::Context; +use aquatic_common::AccessListType; use crossbeam_channel::unbounded; use privdrop::PrivDrop; @@ -23,6 +24,13 @@ pub const APP_NAME: &str = "aquatic_udp: UDP BitTorrent tracker"; pub fn run(config: Config) -> ::anyhow::Result<()> { let state = State::default(); + match config.access_list.list_type { + AccessListType::Allow | AccessListType::Deny => { + state.access_list.lock().update_from_path(&config.access_list.path)?; + }, + AccessListType::Ignore => {}, + } + let num_bound_sockets = start_workers(config.clone(), state.clone())?; if config.privileges.drop_privileges {