addresses: [] Sequence of SocketAddress
tls:
certificates: file containing full certificate chain in PEM format
- key: file contaiing private key in PEM format
+ key: file containing private key in PEM format
A :ref:`setting-yaml-webservice.listen` section contains a sequence of `IncomingWSConfig`_, for example:
+/*
+ * This file is part of PowerDNS or dnsdist.
+ * Copyright -- PowerDNS.COM B.V. and its contributors
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * In addition, for the avoidance of any doubt, permission is granted to
+ * link this program with OpenSSL and to (re)distribute the binaries
+ * produced as the result of such linking.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
#[cxx::bridge(namespace = "pdns::rust::misc")]
pub mod rustmisc {
+/*
+ * This file is part of PowerDNS or dnsdist.
+ * Copyright -- PowerDNS.COM B.V. and its contributors
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * In addition, for the avoidance of any doubt, permission is granted to
+ * link this program with OpenSSL and to (re)distribute the binaries
+ * produced as the result of such linking.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
/*
TODO
- Table based routing?
-- Authorization: metrics and plain files (and more?) are not subject to password auth plus the code needs a n careful audit.
-- Code is now in settings dir. It's only possible to split the modules into separate Rust libs if we
- use shared libs (in theory, I did not try). Currently all CXX using Rust cargo's must be compiled
- as one and refer to a single static Rust runtime
- Ripping out yahttp stuff, providing some basic classes only. ATM we do use a few yahttp include files (but no .cc)
- Some classes (NetmaskGroup, ComboAddress) need a UniquePtr Wrapper to keep them opaque (iputils
cannot be included without big headages in bridge.hh at the moment). We could seperate
}
}
+#[allow(clippy::too_many_arguments)]
fn file_wrapper(
ctx: &Context,
handler: FileFunc,
handler(ctx, method, path, request, response);
}
+#[allow(clippy::too_many_arguments)]
fn api_wrapper(
logger: &cxx::SharedPtr<rustweb::Logger>,
ctx: &Context,
response: &mut rustweb::Response,
);
-// Match a request and return the function that imlements it, this should probably be table based.
+// Match a request and return the function that implements it, this should probably be table based.
fn matcher(
method: &Method,
path: &str,
unsafe impl Sync for rustmisc::Logger {}
#[cxx::bridge(namespace = "pdns::rust::web::rec")]
+#[allow(clippy::needless_lifetimes)] // Needed to avoid clippy warning for Request
mod rustweb {
extern "C++" {
type CredentialsHolder;
}
// Clippy does not seem to understand what cxx does and complains about needless_lifetimes
- // I was unable to silence that warning
+ // The warning is silenced that warning above
struct Request<'a> {
body: Vec<u8>,
uri: String,
else if (configLevel == "detailed") {
loglevel = pdns::rust::misc::LogLevel::Detailed;
}
+ // 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);
}
}
}
-// Convert what we receive from Rust into C++ data, call funtions and convert results back to Rust data
+// Convert what we receive from Rust into C++ data, call functions and convert results back to Rust data
static void rustWrapper(const std::function<void(HttpRequest*, HttpResponse*)>& func, const pdns::rust::web::rec::Request& rustRequest, pdns::rust::web::rec::Response& rustResponse)
{
HttpRequest request;
HttpResponse response;
- request.body = std::string(reinterpret_cast<const char*>(rustRequest.body.data()), rustRequest.body.size());
+ request.body = std::string(reinterpret_cast<const char*>(rustRequest.body.data()), rustRequest.body.size()); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
request.url = std::string(rustRequest.uri);
for (const auto& [key, value] : rustRequest.vars) {
request.getvars[std::string(key)] = std::string(value);
for (const auto& [key, value] : rustRequest.parameters) {
request.parameters[std::string(key)] = std::string(value);
}
- request.d_slog = g_slog; // XXX
- response.d_slog = g_slog; // XXX
+ // These two log objects are not used by the Rust code, as they take the logging object from the
+ // context, initalized from an argument to pdns::rust::web::rec::serveweb()
+ request.d_slog = g_slog;
+ response.d_slog = g_slog;
try {
func(&request, &response);
}