]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Remove remains of unused PoC code 15114/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 12 Feb 2025 09:51:55 +0000 (10:51 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 12 Feb 2025 09:54:50 +0000 (10:54 +0100)
pdns/recursordist/rec-rust-lib/rust/src/web.rs
pdns/recursordist/ws-recursor.cc

index aa0a7849fa2d55caf1dedd56f364e53c43375862..6445db01eac97df0dbbb6c8de41491ff8f982426 100644 (file)
@@ -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<String>,
     password_ch: cxx::UniquePtr<rustweb::CredentialsHolder>,
     api_ch: cxx::UniquePtr<rustweb::CredentialsHolder>,
     acl: cxx::UniquePtr<rustmisc::NetmaskGroup>,
@@ -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<rustweb::IncomingWSConfig>,
-    urls: &[String],
     password_ch: cxx::UniquePtr<rustweb::CredentialsHolder>,
     api_ch: cxx::UniquePtr<rustweb::CredentialsHolder>,
     acl: cxx::UniquePtr<rustmisc::NetmaskGroup>,
@@ -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<IncomingWSConfig>,
-            urls: &[String],
             pwch: UniquePtr<CredentialsHolder>,
             apikeych: UniquePtr<CredentialsHolder>,
             acl: UniquePtr<NetmaskGroup>,
index 17a9eb5a799d6fc42a076015d683f4ab83ceb471..850bcb1954a11ce8e7139a30d51dd99f69a3746f 100644 (file)
@@ -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<CredentialsHolder> 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<const ::rust::String>{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)