Replies: 1 comment
-
I have been looking for a solution for this problem for some days, and after hacking my way around in the event loop code to no avail, I realized that I could just fake it all and use zero byte reads and writes to make the event loop do the waiting for me, and then pass the ready file descriptor to SSL to perform the actual I/O. WIth some simple logic for handling the I made a little experiment repo where I wrapped this all up in a Janet-like stream with For those interested, the repo is below. For now this requires a modified spork, but I hope to PR these changes: https://github.com/zevv/janetttls |
Beta Was this translation helpful? Give feedback.
-
TLS could be done as a separate library most certainly, getting it right and integrated into the event loop though might be difficult. Are the
janet_listen
andjanet_unlisten
functions available to external code?I'm sort of looking into doing TLS, but I keep getting hung up at BIO pairs have to read, and write, sometimes to just complete a read or a write call! Still thinking on how to go about this, would love some ideas.
What would be really good is if we could wrap up a stream and still treat it as a stream with net/write and net/read, where I think currently we'd have to have an abstract type that can :read and :write. Basically, when performing IO on an TLS stream the IO handling routines (read/write) have to step the TLS state machine and perform all necessary reads/writes before handing back the IO that the caller issued. I'm still thinking through it and wondering if I'll run into an issue whereby the caller issues an IO and it lets the caller continue as if the IO completed instead of yielding out to the event loop wrongly. I know without integrating this into Janet we will definitely run into a "someone called net/write and broke stuff" sort of ordeal quite easily (meaning we'd be at the point where some streams can't be treated as streams which would make things "uglier" IMO).
Beta Was this translation helpful? Give feedback.
All reactions