Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rec: move to embedded web service written in Rust #15114

Open
wants to merge 34 commits into
base: master
Choose a base branch
from

Conversation

omoerbeek
Copy link
Member

Short description

This PR introduces a Rust written embedded web service

Main new features

  • Using a well maintained libraries (hyper and rusttls), instead of YaHTTP. We still use a few existing YaHTTP classes to represent http related data on the C++ side, but header only.
  • The actual method implementing the various (REST) functionality did not change, they are now called from Rust code.
  • We support multiple listen addresses and incoming TLS. It is also possible to listen on some addresses for plaintext http, and on some others require https. In contrast: current code only supports one listening address and no https.
  • A few regression tests now use https.
  • The settings directory a been changed to the more general rec-rust-lib as it contains settings and web related code. The produced static lib is also renamed. We work in one crate as having multiple crates is a bit of a pain in combination with a static lib. See https://cxx.rs/build/other.html#linking-the-c-and-rust-together. To be revisited in the future.

Future areas of improvement:

  • TLS config is very basic (e.g. no encrypted private keys or TLS version options)
  • Routing is done in code, it would be better to setup a table by the app
  • Review of enabled features in new imported crates.
  • Move JSON handling to Rust?
  • http2 support? I do wonder if that would bring us anything in the Recusor context.

The new authentication and authorization code needs a good review to establish it's indeed equivalent to the existing code.

Checklist

I have:

  • read the CONTRIBUTING.md document
  • compiled this code
  • tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)

… Cargo.lock version = 3

The default rusttls provider has quite some dependecies that need newer Rust.
ring is much morer lenient.
@omoerbeek omoerbeek added rec enhancement dependencies Pull requests that update a dependency file rust Pull requests that update Rust code labels Feb 4, 2025
@omoerbeek omoerbeek added this to the rec-5.3.0 milestone Feb 4, 2025
@coveralls
Copy link

coveralls commented Feb 4, 2025

Pull Request Test Coverage Report for Build 13134121058

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 159 of 176 (90.34%) changed or added relevant lines in 6 files are covered.
  • 121 unchanged lines in 20 files lost coverage.
  • Overall coverage decreased (-8.2%) to 64.762%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pdns/recursordist/rec-web-stubs.hh 0 1 0.0%
pdns/recursordist/rec-rust-lib/cxxsupport.cc 27 29 93.1%
pdns/recursordist/rec-main.cc 10 13 76.92%
pdns/recursordist/ws-recursor.cc 111 122 90.98%
Files with Coverage Reduction New Missed Lines %
pdns/webserver.hh 1 83.33%
pdns/packethandler.cc 1 72.58%
pdns/recursordist/ws-recursor.cc 1 66.74%
pdns/recursordist/lwres.cc 2 69.66%
pdns/sstuff.hh 2 56.83%
pdns/backends/gsql/gsqlbackend.hh 2 97.71%
pdns/recursordist/syncres.hh 3 87.67%
pdns/stubresolver.cc 3 77.58%
pdns/misc.cc 3 62.71%
pdns/recursordist/rec-main.cc 3 62.39%
Totals Coverage Status
Change from base Build 13133792161: -8.2%
Covered Lines: 128201
Relevant Lines: 166819

💛 - Coveralls


void RecursorWebServer::jsonstat(HttpRequest* req, HttpResponse* resp)
static void jsonstat(HttpRequest* req, HttpResponse* resp)

Check warning

Code scanning / CodeQL

Poorly documented large function Warning

Poorly documented function: fewer than 2% comments for a function of 112 lines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file enhancement rec rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants