See branch rosuav/pre-listening-ports for a first attempt at this.

With Stdio.Port(), it's possible to receive an open socket as a file
descriptor and start accepting connections on it. (Notably, this
allows systemd to provide a socket as FD 3, allowing unprivileged
programs to listen on privileged ports.) Currently, this isn't
possible with Protocols.HTTP.Server.Port or its friends.

For unencrypted connections, this isn't too hard. Instead of having it
construct a Port, it can receive one already listening. For SSLPort
though, it inherits SSL.Port, so this doesn't work. What would be a
good API for making this possible?

(Protocols.WebSocket.Port and Protocols.WebSocket.SSLPort inherit from
their non-websocket equivalents, so they broadly "come along for the
ride".)

Incidentally, this actually means it is easier to use opportunistic
TLS than mandated, since a regular Port can, with a handful of lines
of code, be enhanced to call on SSL.File directly. But API-wise it
would be a bit quirky if Port supports this feature and SSLPort
doesn't.

Recommendations?

ChrisA
  • Run... Chris Angelico
    • ... Henrik Grubbstr�m (Lysator) @ Pike (-) developers forum
      • ... Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum
    • ... Chris Angelico
      • ... Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum
      • ... Henrik Grubbstr�m (Lysator) @ Pike (-) developers forum
      • ... Chris Angelico

Reply via email to