HDDEMUX(1)

๐Ÿ“ฆ
version 0.5 ยท 4 versions
, in debian trixie, ubuntu noble, ubuntu questing

๐Ÿ’– hddemux โ€” the manual, but make it slay ๐Ÿ’–

okay bestie, gather round, because hddemux (that's the manual page name, section 1, Unix manual pages, iykyk) is genuinely one of the cutest little programs out there and I need you to understand it. no cap.


โœจ NAME โœจ

hddemux โ€” demultiplexes incoming TCP connections between HTTP and DNS.

like... it's a traffic cop but make it fashion. ๐Ÿ’…


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

hddemux

that's it. that's the whole synopsis. no flags, no args, no nonsense. she just runs. iconic behavior honestly. ๐Ÿ‘‘


๐ŸŒธ DESCRIPTION ๐ŸŒธ

so here's the vibe. hddemux takes a set of listening stream-based file descriptors (peep sd_listen_fds(3) for the lore) and accepts new connections on them. ๐Ÿซถ

when a new connection comes in, it looks at the first few octets</> and decides whether this connection is HTTP/1.x or DNS.

  • if it thinks it's HTTP/1.x, it splices the connection to the HTTP_TARGET. ๐ŸŒˆ
  • if it thinks it's DNS, it splices the connection to the DNS_TARGET. ๐Ÿฆ‹

one port, two destinies. the way that it just knows?? obsessed.


๐ŸŽ€ ENVIRONMENT VARIABLES ๐ŸŽ€

okay this is the part where you actually configure her, so pay attention bestie.

  • HTTP_TARGET and DNS_TARGET โ€” these should be either a DNS name or an IP address, and optionally you can follow that with a colon and a port number. if either variable is unset, it just defaults to localhost. (yes really, just localhost. she's lowkey humble like that. ๐Ÿ™ˆ)
  • if the port number is not specified, HTTP_TARGET defaults to TCP port 80, and DNS_TARGET defaults to TCP port 53.
  • HDDEMUX_DEBUG โ€” set this to a non-empty string and she will send a lot of verbose debugging info to stderr. like a lot a lot. she will tell you everything. ๐Ÿ’€
  • IDLE_TIMEOUT โ€” this sets the number of milliseconds that hddemux will permit a session to be in an open state with no traffic passing before it tries to close both sides. the default is 600000 (that's 10 minutes, for the non-math girlies ๐Ÿงฎ). set this variable to 0 to never try to do this kind of cleanup.

๐Ÿ’œ SIGNALS ๐Ÿ’œ

when hddemux receives SIGUSR1, it dumps an overview of the current state of the demuxer to stderr โ€” that's the configuration, outstanding established streams, etc. etc.

basically you poke her and she trauma-dumps her whole current situation to stderr. relatable tbh. ๐Ÿ˜ญ


๐ŸŒˆ EXAMPLES ๐ŸŒˆ

for systemd, you need a .socket unit file:

#/lib/systemd/hddemux.socket
[Unit]
Description=HTTP/1.x and DNS demuxer socket
Documentation=man:hddemux(1)

[Socket]
ListenStream=/run/hddemux/socket

[Install]
WantedBy=sockets.target

and a .service unit file:

#/lib/systemd/hddemux.service
[Unit]
Description=HTTP/1.x and DNS demuxer service
Documentation=man:hddemux(1)
Requires=hddemux.socket

[Service]
Type=notify
ExecStart=/usr/bin/hddemux
WorkingDirectory=/run/hddemux/workdir
User=hddemux
Group=hddemux

[Install]
Also=hddemux.socket

and configuration? you do that by overriding the .service file โ€” e.g. with Service.Environment= entries. go read the "edit" documentation in systemctl(1) and the "Overriding vendor settings" section of systemd.unit(5). ๐Ÿซก


โญ CONSTRAINTS โญ

hddemux is designed to demultiplex HTTP/1.x from stream-based DNS. trying to demultiplex other protocols โ€” and yes that includes HTTP/2 or later โ€” is not advised. ๐Ÿšซ

if you want more info and analysis, please see draft-dkg-dprive-demux-dns-http. it's giving "required reading". ๐Ÿ“š


๐Ÿ’€ WARNING ๐Ÿ’€

note that this effectively acts as a stream redirector once the client's first flight has been processed. it does this with no attempt to defend against stream redirection loops, so be careful not to redirect it to itself โ€” or it will eat all of your memory in infinite recursion. ๐Ÿ’€๐Ÿ’€๐Ÿ’€

bestie. do not point it at itself. i am begging you. that's the whole warning. she will simply consume everything you love. ๐Ÿ”ฅ


๐Ÿ”ฅ SEE ALSO ๐Ÿ”ฅ


๐Ÿ‘‘ AUTHORS ๐Ÿ‘‘

Daniel Kahn Gillmor <dkg@fifthhorseman.net>. ๐Ÿซถ


and that's the whole page, bestie!! this version is from 2017 May, and yeah โ€” HDDEMUX(1) really is the source, that's where all of this came from. mwah. ๐Ÿ’‹โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from