add ALPN support to tls socket #239
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi!
I've written this PR to add ALPN support for TLS sockets. My goal for this is to make its way to uWebsockets.js, if you agree with this.
I've written this so that socket creation gets an array of protocols that are allowed (e.g. http/1.1 or h2).
I haven't written c code in very long time, so please forgive me if I've made any stupid mistakes. Any feedback is welcome.
number_of_digitsis a bit "dumb" but I assume that it would be quickest vs a loop, and I'm not sure what the best way to do a global variable withalpn_indexwould be as well, so fixes are of course welcome as well;usage would be something like this I assume (http/1.1 only would be used of course, when h2 is not supported):
Using the above settings, I've also used openssl to validate that it works correctly (using the demo http_server.c)