-
Notifications
You must be signed in to change notification settings - Fork 21
Adding the client hello sni information at Connection.sniHostName() #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
66aa6c0
draft implementation of connection.sniHostName()
jaylu c6253d5
tidy up the implementation
jaylu bf80779
fix the HA Proxy feature
jaylu a19a2a7
simplify the code, store the HAProxy info and SNI info as channel att…
jaylu 51cb8ba
update test cases
jaylu 61ba56f
rollback test cases
jaylu 92676fe
fix the client request hang up
jaylu aada173
make MuSniHandler.java none public
jaylu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package io.muserver; | ||
|
|
||
| import io.netty.channel.ChannelHandlerContext; | ||
| import io.netty.channel.SimpleChannelInboundHandler; | ||
| import io.netty.handler.codec.haproxy.HAProxyMessage; | ||
| import io.netty.util.AttributeKey; | ||
|
|
||
| class HAProxyMessageHandler extends SimpleChannelInboundHandler<HAProxyMessage> { | ||
|
|
||
| static final AttributeKey<ProxiedConnectionInfo> HA_PROXY_INFO = AttributeKey.valueOf("HA_PROXY_INFO"); | ||
|
|
||
| @Override | ||
| protected void channelRead0(ChannelHandlerContext ctx, HAProxyMessage msg) { | ||
| ProxiedConnectionInfoImpl proxyConnectionInfo = ProxiedConnectionInfoImpl.fromNetty(msg); | ||
| ctx.channel().attr(HA_PROXY_INFO).set(proxyConnectionInfo); | ||
| if (!ctx.channel().config().isAutoRead()) { | ||
| ctx.read(); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package io.muserver; | ||
|
|
||
| import io.netty.buffer.ByteBufAllocator; | ||
| import io.netty.channel.ChannelHandlerContext; | ||
| import io.netty.handler.ssl.SniHandler; | ||
| import io.netty.handler.ssl.SslContext; | ||
| import io.netty.handler.ssl.SslHandler; | ||
| import io.netty.util.AttributeKey; | ||
| import io.netty.util.Mapping; | ||
|
|
||
| import javax.net.ssl.SSLParameters; | ||
| import java.util.function.Supplier; | ||
|
|
||
|
|
||
| class MuSniHandler extends SniHandler { | ||
|
|
||
| static final AttributeKey<String> SNI_HOSTNAME = AttributeKey.valueOf("SNI_HOSTNAME"); | ||
|
|
||
| public MuSniHandler(Supplier<Mapping<? super String, ? extends SslContext>> mappingProvider) { | ||
| super(mappingProvider.get()); | ||
| } | ||
|
|
||
| @Override | ||
| protected void replaceHandler(ChannelHandlerContext ctx, String hostname, SslContext sslContext) throws Exception { | ||
| ctx.channel().attr(SNI_HOSTNAME).set(hostname()); | ||
| super.replaceHandler(ctx, hostname, sslContext); | ||
| } | ||
|
|
||
| @Override | ||
| protected SslHandler newSslHandler(SslContext context, ByteBufAllocator allocator) { | ||
| SslHandler sslHandler = context.newHandler(allocator); | ||
| SSLParameters params = sslHandler.engine().getSSLParameters(); | ||
| params.setUseCipherSuitesOrder(true); | ||
| sslHandler.engine().setSSLParameters(params); | ||
| return sslHandler; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one thing to highlight, for JDK 8, if not doing this extra ctx.read(), it will randomly failed the text - client request timeout.