From: Otto Moerbeek Date: Wed, 12 Feb 2025 09:51:55 +0000 (+0100) Subject: Remove remains of unused PoC code X-Git-Tag: dnsdist-2.0.0-alpha1~95^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F15114%2Fhead;p=thirdparty%2Fpdns.git Remove remains of unused PoC code --- diff --git a/pdns/recursordist/rec-rust-lib/rust/src/web.rs b/pdns/recursordist/rec-rust-lib/rust/src/web.rs index aa0a7849fa..6445db01ea 100644 --- a/pdns/recursordist/rec-rust-lib/rust/src/web.rs +++ b/pdns/recursordist/rec-rust-lib/rust/src/web.rs @@ -155,7 +155,7 @@ fn file_wrapper( unauthorized(response, headers, "Basic"); return; } - handler(ctx, method, path, request, response); + handler(method, path, request, response); } #[allow(clippy::too_many_arguments)] @@ -267,9 +267,8 @@ fn api_wrapper( } } -// Data used by requests handlers, only counter is r/w. +// Data used by requests handlers, if you add a r/w variable, make sure it's safe for concurrent access! struct Context { - urls: Vec, password_ch: cxx::UniquePtr, api_ch: cxx::UniquePtr, acl: cxx::UniquePtr, @@ -279,38 +278,11 @@ struct Context { // Serve a file fn file( - ctx: &Context, method: &Method, path: &str, request: &rustweb::Request, response: &mut rustweb::Response, ) { - let mut uripath = path; - if uripath == "/" { - uripath = "/index.html"; - } - let pos = ctx - .urls - .iter() - .position(|x| String::from("/") + x == uripath); - if pos.is_none() { - rustmisc::log( - request.logger, - rustweb::Priority::Debug, - "not found", - &vec![ - rustmisc::KeyValue { - key: "method".to_string(), - value: method.to_string(), - }, - rustmisc::KeyValue { - key: "uripath".to_string(), - value: uripath.to_string(), - }, - ], - ); - } - // This calls into C++ if rustweb::serveStuff(request, response).is_err() { // Return 404 not found response. @@ -319,15 +291,15 @@ fn file( rustmisc::log( request.logger, rustweb::Priority::Debug, - "not found case 2", + "not found", &vec![ rustmisc::KeyValue { key: "method".to_string(), value: method.to_string(), }, rustmisc::KeyValue { - key: "uripath".to_string(), - value: uripath.to_string(), + key: "path".to_string(), + value: path.to_string(), }, ], ); @@ -335,7 +307,6 @@ fn file( } type FileFunc = fn( - ctx: &Context, method: &Method, path: &str, request: &rustweb::Request, @@ -889,7 +860,6 @@ async fn serveweb_async( pub fn serveweb( incoming: &Vec, - urls: &[String], password_ch: cxx::UniquePtr, api_ch: cxx::UniquePtr, acl: cxx::UniquePtr, @@ -898,7 +868,6 @@ pub fn serveweb( ) -> Result<(), std::io::Error> { // Context, atomically reference counted let ctx = Arc::new(Context { - urls: urls.to_vec(), password_ch, api_ch, acl, @@ -1049,8 +1018,6 @@ mod rustweb { type CredentialsHolder; #[namespace = "pdns::rust::misc"] type NetmaskGroup = crate::misc::rustmisc::NetmaskGroup; - //#[namespace = "pdns::rust::misc"] - //type ComboAddress = crate::misc::rustmisc::ComboAddress; #[namespace = "pdns::rust::misc"] type Priority = crate::misc::rustmisc::Priority; #[namespace = "pdns::rust::misc"] @@ -1073,10 +1040,9 @@ mod rustweb { * Functions callable from C++ */ extern "Rust" { - // The main entry point, This function will return, but will setup thread(s) to handle requests. + // The main entry point, This function will return, but will setup thread(s) and tokio runtime to handle requests. fn serveweb( incoming: &Vec, - urls: &[String], pwch: UniquePtr, apikeych: UniquePtr, acl: UniquePtr, diff --git a/pdns/recursordist/ws-recursor.cc b/pdns/recursordist/ws-recursor.cc index 17a9eb5a79..850bcb1954 100644 --- a/pdns/recursordist/ws-recursor.cc +++ b/pdns/recursordist/ws-recursor.cc @@ -1005,10 +1005,6 @@ void serveRustWeb() config.emplace_back(tmp); } - ::rust::Vec<::rust::String> urls; - for (const auto& [url, _] : g_urlmap) { - urls.emplace_back(url); - } auto passwordString = arg()["webserver-password"]; std::unique_ptr password; if (!passwordString.empty()) { @@ -1036,7 +1032,7 @@ void serveRustWeb() // This function returns after having created the web server object that handles the requests. // That object and its runtime are associated with a Posix thread that waits until all tasks are // done, which normally never happens. See rec-rust-lib/rust/src/web.rs for details - pdns::rust::web::rec::serveweb(config, ::rust::Slice{urls.data(), urls.size()}, std::move(password), std::move(apikey), std::move(aclPtr), std::move(logPtr), loglevel); + pdns::rust::web::rec::serveweb(config, std::move(password), std::move(apikey), std::move(aclPtr), std::move(logPtr), loglevel); } static void fromCxxToRust(const HttpResponse& cxxresp, pdns::rust::web::rec::Response& rustResponse)