This commit is contained in:
wujiawei 2024-09-28 19:27:13 +08:00
parent a5176c3cf1
commit c2a4926888

View File

@ -5,6 +5,7 @@ import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.SocketChannel;
import io.netty.handler.ssl.SslContext; import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder; import io.netty.handler.ssl.SslContextBuilder;
import io.netty.handler.ssl.SslHandler;
import io.netty.handler.ssl.util.InsecureTrustManagerFactory; import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.framework.lazy.cloud.network.heartbeat.common.InternalNetworkServerPermeateServerRealServer; import org.framework.lazy.cloud.network.heartbeat.common.InternalNetworkServerPermeateServerRealServer;
@ -13,8 +14,8 @@ import org.framework.lazy.cloud.network.heartbeat.common.encoder.TransferEncoder
import org.framework.lazy.cloud.network.heartbeat.common.filter.DebugChannelInitializer; import org.framework.lazy.cloud.network.heartbeat.common.filter.DebugChannelInitializer;
import org.framework.lazy.cloud.network.heartbeat.server.netty.handler.NettyServerPermeateServerRealHandler; import org.framework.lazy.cloud.network.heartbeat.server.netty.handler.NettyServerPermeateServerRealHandler;
import java.net.URI; import javax.net.ssl.SSLContext;
import java.net.URISyntaxException; import javax.net.ssl.SSLEngine;
@Slf4j @Slf4j
public class NettyServerPermeateServerRealFilter extends DebugChannelInitializer<SocketChannel> { public class NettyServerPermeateServerRealFilter extends DebugChannelInitializer<SocketChannel> {
@ -42,7 +43,7 @@ public class NettyServerPermeateServerRealFilter extends DebugChannelInitializer
try { try {
SslContext sslContext = SslContextBuilder.forClient() SslContext sslContext = SslContextBuilder.forClient()
.trustManager(InsecureTrustManagerFactory.INSTANCE).build(); .trustManager(InsecureTrustManagerFactory.INSTANCE).build();
pipeline.addLast("ssl", sslContext.newHandler(ch.alloc(),targetIp,targetPort)); pipeline.addLast(sslContext.newHandler(ch.alloc()));
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }