daurnimator/multi-protocol.lua

daurnimator/multi-protocol.lua

This snippet demonstrates listening for multiple protocol signatures on the one TCP port. I left off concurrency to make it easier to understand.

The TLS path will only work with the newly commited cqueues :starttls pushback, which runs userspace buffered data through the incoming BIO before reading off the socket.

A couple of the protocol patterns I stole from prosody (where a similar idea is done via ‘mod_net_multiplex’).