Skip to content

httpd: extract reusable server code - #132

Merged
mvo5 merged 3 commits into
systemd:mainfrom
mvo5:relayd-1
Sep 22, 2026
Merged

mvo5 merged 3 commits into
systemd:mainfrom
mvo5:relayd-1

Conversation

@mvo5

@mvo5 mvo5 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

This PR prepares for a coming additional server binary. Its useful on its own and extracts a bunch of the existing helpers for TLS server handling into shared code. Small tweaks along the way, see the individual commits.

Comment thread src/lib.rs Outdated
Extract the existing code varlink-httpd code that builds the
SslAcceptorBuilder with the cert_path and key_path into
tls_acceptor_builder() so that it can be reused.

Do the same for the `accept` part of a connection and move
that into `tls_accept`.

This will allow us to reuse this in next TLS server we need to
build.

No behavior change, pure extraction.
Extract the accept code from varlink-httpd into the new `listen.rs`
helpers. This allows us to reuse it again when building a second
TLS server.

Also tweak it slightly so that on accept() error we add a small
delay before retring (there is really not much else we can do
and the old code was spinning without delay which was wasteful).

Also tweak the error message so that we give a useful hint when
running out of file descriptors.
Ensure that a connection completes its handshake within a new
TLS_HANDSHAKE_TIMEOUT of 10s to ensure we cannot get DoS'ed
by opening a connection and then not sending any data.
@mvo5
mvo5 merged commit d7e87ab into systemd:main Sep 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants