From 29ae8b9775e8f7c97d9e43e0ea4be8dfdc9fa7d6 Mon Sep 17 00:00:00 2001 From: "Cloud.Liu" Date: Tue, 13 Jul 2021 12:08:39 +0800 Subject: [PATCH] =?UTF-8?q?DEC-19253=20feat:=20netty-socketio=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E9=85=8D=E7=BD=AE=E5=8A=A0=E5=AF=86=E5=A5=97=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fine-socketio/pom.xml | 5 ++++ .../com/fr/third/socketio/Configuration.java | 23 +++++++++++++++++++ .../socketio/SocketIOChannelInitializer.java | 10 ++++++++ 3 files changed, 38 insertions(+) diff --git a/fine-socketio/pom.xml b/fine-socketio/pom.xml index 785a9fd41..cbc6deae1 100644 --- a/fine-socketio/pom.xml +++ b/fine-socketio/pom.xml @@ -35,6 +35,11 @@ fine-spring ${revision} + + com.fr.essential + fine-common + ${essentialVersion} + 以下是lib的本地jar包依赖<--> com.fr.third diff --git a/fine-socketio/src/main/java/com/fr/third/socketio/Configuration.java b/fine-socketio/src/main/java/com/fr/third/socketio/Configuration.java index 84c8383ed..8948b005e 100644 --- a/fine-socketio/src/main/java/com/fr/third/socketio/Configuration.java +++ b/fine-socketio/src/main/java/com/fr/third/socketio/Configuration.java @@ -98,6 +98,10 @@ public class Configuration { private List disconnectInterceptors = Collections.emptyList(); private List eventInterceptors = Collections.emptyList(); + private String[] nettyProtocols = new String[]{}; + + private String[] nettyCiphers = new String[]{}; + public Configuration() { } @@ -169,6 +173,9 @@ public class Configuration { setConnectInterceptors(conf.getConnectInterceptors().toArray(new Interceptor[0])); setDisconnectInterceptors(conf.getDisconnectInterceptors().toArray(new Interceptor[0])); setEventInterceptors(conf.getEventInterceptors().toArray(new EventInterceptor[0])); + + setNettyProtocols(conf.getNettyProtocols()); + setNettyCiphers(conf.getNettyCiphers()); } public JsonSupport getJsonSupport() { @@ -630,4 +637,20 @@ public class Configuration { public void setEventInterceptors(EventInterceptor[] eventInterceptors) { this.eventInterceptors = Arrays.asList(eventInterceptors); } + + public String[] getNettyProtocols() { + return nettyProtocols; + } + + public void setNettyProtocols(String[] nettyProtocols) { + this.nettyProtocols = nettyProtocols; + } + + public String[] getNettyCiphers() { + return nettyCiphers; + } + + public void setNettyCiphers(String[] nettyCiphers) { + this.nettyCiphers = nettyCiphers; + } } diff --git a/fine-socketio/src/main/java/com/fr/third/socketio/SocketIOChannelInitializer.java b/fine-socketio/src/main/java/com/fr/third/socketio/SocketIOChannelInitializer.java index 645767565..ae8133599 100644 --- a/fine-socketio/src/main/java/com/fr/third/socketio/SocketIOChannelInitializer.java +++ b/fine-socketio/src/main/java/com/fr/third/socketio/SocketIOChannelInitializer.java @@ -23,6 +23,7 @@ import javax.net.ssl.SSLEngine; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; +import com.fr.stable.ArrayUtils; import com.fr.third.socketio.scheduler.HashedWheelTimeoutScheduler; import com.fr.third.socketio.transport.PollingTransport; import com.fr.third.socketio.transport.WebSocketTransport; @@ -155,6 +156,15 @@ public class SocketIOChannelInitializer extends ChannelInitializer impl if (sslContext != null) { SSLEngine engine = sslContext.createSSLEngine(); engine.setUseClientMode(false); + + if (ArrayUtils.isNotEmpty(configuration.getNettyProtocols())) { + engine.setEnabledProtocols(configuration.getNettyProtocols()); + } + + if (ArrayUtils.isNotEmpty(configuration.getNettyCiphers())) { + engine.setEnabledCipherSuites(configuration.getNettyCiphers()); + } + pipeline.addLast(SSL_HANDLER, new SslHandler(engine)); } }