sdk模块去除solon相关依赖
This commit is contained in:
@@ -3,32 +3,75 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>neutrino-proxy</artifactId>
|
||||
<groupId>org.dromara.neutrino-proxy</groupId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-parent</artifactId>
|
||||
<version>2.5.12</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<groupId>org.dromara.neutrino-proxy</groupId>
|
||||
<artifactId>neutrino-proxy-client-sdk</artifactId>
|
||||
|
||||
<version>${revision}</version>
|
||||
<packaging>jar</packaging>
|
||||
<properties>
|
||||
<revision>2.0.1</revision>
|
||||
<lombok.version>1.18.30</lombok.version>
|
||||
<hutool.version>5.8.20</hutool.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.dromara.neutrino-proxy</groupId>
|
||||
<artifactId>neutrino-proxy-core</artifactId>
|
||||
<version>${revision}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-test</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon.aot</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon.logging.logback</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-cache</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-lib</artifactId>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>${lombok.version}</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.jsqlparser</groupId>
|
||||
<artifactId>jsqlparser</artifactId>
|
||||
<version>4.5</version>
|
||||
<scope>compile</scope>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-slf4j-impl</artifactId>
|
||||
<version>2.20.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
-6
@@ -1,8 +1,6 @@
|
||||
package org.dromara.neutrinoproxy.client.sdk.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -10,13 +8,9 @@ import org.noear.solon.annotation.Inject;
|
||||
* @date: 2022/6/16
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
public class ProxyConfig {
|
||||
@Inject("${neutrino.proxy.protocol}")
|
||||
private Protocol protocol;
|
||||
@Inject("${neutrino.proxy.tunnel}")
|
||||
private Tunnel tunnel;
|
||||
@Inject("${neutrino.proxy.client}")
|
||||
private Client client;
|
||||
|
||||
@Data
|
||||
|
||||
+5
-8
@@ -11,7 +11,6 @@ import org.dromara.neutrinoproxy.client.sdk.config.ProxyConfig;
|
||||
import org.dromara.neutrinoproxy.client.sdk.util.ProxyUtil;
|
||||
import org.dromara.neutrinoproxy.client.sdk.util.UdpServerUtil;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.noear.solon.Solon;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
@@ -31,6 +30,8 @@ public class IAbProxyClientService {
|
||||
|
||||
public Bootstrap udpServerBootstrap;
|
||||
|
||||
public Boolean isAotRuntime;
|
||||
|
||||
private volatile Channel channel;
|
||||
/**
|
||||
* 重连次数
|
||||
@@ -46,7 +47,7 @@ public class IAbProxyClientService {
|
||||
reconnectExecutor.scheduleWithFixedDelay(this::reconnect, 10, proxyConfig.getTunnel().getReconnection().getIntervalSeconds(), TimeUnit.SECONDS);
|
||||
try {
|
||||
this.start();
|
||||
UdpServerUtil.initCache(proxyConfig, udpServerBootstrap);
|
||||
UdpServerUtil.initCache(proxyConfig, udpServerBootstrap,isAotRuntime);
|
||||
} catch (Exception e) {
|
||||
// 启动连不上也做一下重连,因此先catch异常
|
||||
log.error("[CmdChannel] start error", e);
|
||||
@@ -56,23 +57,19 @@ public class IAbProxyClientService {
|
||||
public void start() {
|
||||
if (StrUtil.isEmpty(proxyConfig.getTunnel().getServerIp())) {
|
||||
log.error("not found server-ip config.");
|
||||
Solon.stop();
|
||||
return;
|
||||
}
|
||||
if (null == proxyConfig.getTunnel().getServerPort()) {
|
||||
log.error("not found server-port config.");
|
||||
Solon.stop();
|
||||
return;
|
||||
}
|
||||
if (null != proxyConfig.getTunnel().getSslEnable() && proxyConfig.getTunnel().getSslEnable()
|
||||
&& StrUtil.isEmpty(proxyConfig.getTunnel().getJksPath())) {
|
||||
log.error("not found jks-path config.");
|
||||
Solon.stop();
|
||||
return;
|
||||
}
|
||||
if (StrUtil.isEmpty(proxyConfig.getTunnel().getLicenseKey())) {
|
||||
log.error("not found license-key config.");
|
||||
Solon.stop();
|
||||
return;
|
||||
}
|
||||
if (null == channel || !channel.isActive()) {
|
||||
@@ -82,7 +79,7 @@ public class IAbProxyClientService {
|
||||
log.error("client start error", e);
|
||||
}
|
||||
} else {
|
||||
channel.writeAndFlush(ProxyMessage.buildAuthMessage(proxyConfig.getTunnel().getLicenseKey(), ProxyUtil.getClientId()));
|
||||
channel.writeAndFlush(ProxyMessage.buildAuthMessage(proxyConfig.getTunnel().getLicenseKey(), ProxyUtil.getClientId(proxyConfig)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +96,7 @@ public class IAbProxyClientService {
|
||||
channel = future.channel();
|
||||
// 连接成功,向服务器发送客户端认证信息(licenseKey)
|
||||
ProxyUtil.setCmdChannel(future.channel());
|
||||
future.channel().writeAndFlush(ProxyMessage.buildAuthMessage(proxyConfig.getTunnel().getLicenseKey(), ProxyUtil.getClientId()));
|
||||
future.channel().writeAndFlush(ProxyMessage.buildAuthMessage(proxyConfig.getTunnel().getLicenseKey(), ProxyUtil.getClientId(proxyConfig)));
|
||||
log.info("[CmdChannel] connect proxy server success. channelId:{}", future.channel().id().asLongText());
|
||||
|
||||
// reconnectServiceEnable = true;
|
||||
|
||||
-3
@@ -7,12 +7,9 @@ import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.handler.timeout.IdleStateEvent;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.neutrinoproxy.client.sdk.config.IBeanHandler;
|
||||
import org.dromara.neutrinoproxy.client.sdk.config.ProxyConfig;
|
||||
import org.dromara.neutrinoproxy.client.sdk.util.ProxyUtil;
|
||||
import org.dromara.neutrinoproxy.core.Constants;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.Dispatcher;
|
||||
import org.noear.solon.Solon;
|
||||
|
||||
/**
|
||||
* 处理与服务端之间的数据传输
|
||||
|
||||
-2
@@ -10,8 +10,6 @@ import org.dromara.neutrinoproxy.client.sdk.config.IBeanHandler;
|
||||
import org.dromara.neutrinoproxy.client.sdk.util.ProxyUtil;
|
||||
import org.dromara.neutrinoproxy.core.Constants;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.Dispatcher;
|
||||
import org.noear.solon.Solon;
|
||||
|
||||
/**
|
||||
* 处理与服务端之间的数据传输
|
||||
|
||||
+9
-6
@@ -1,5 +1,7 @@
|
||||
package org.dromara.neutrinoproxy.client.sdk.handler;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.neutrinoproxy.client.sdk.config.ProxyConfig;
|
||||
@@ -8,8 +10,6 @@ import org.dromara.neutrinoproxy.core.ExceptionEnum;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessageHandler;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.Match;
|
||||
import org.noear.snack.ONode;
|
||||
import org.noear.solon.Solon;
|
||||
|
||||
/**
|
||||
* 认证信息处理器
|
||||
@@ -21,21 +21,24 @@ import org.noear.solon.Solon;
|
||||
public class ProxyMessageAuthHandler implements ProxyMessageHandler {
|
||||
private ProxyConfig proxyConfig;
|
||||
|
||||
public ProxyMessageAuthHandler(ProxyConfig proxyConfig){
|
||||
private Runnable stop;
|
||||
|
||||
public ProxyMessageAuthHandler(ProxyConfig proxyConfig,Runnable stop){
|
||||
this.proxyConfig=proxyConfig;
|
||||
this.stop=stop;
|
||||
}
|
||||
@Override
|
||||
public void handle(ChannelHandlerContext context, ProxyMessage proxyMessage) {
|
||||
String info = proxyMessage.getInfo();
|
||||
ONode load = ONode.load(info);
|
||||
Integer code = load.get("code").getInt();
|
||||
JSONObject load = JSONUtil.parseObj(info);
|
||||
Integer code = load.getInt("code");
|
||||
log.info("Auth result:{}", info);
|
||||
if (ExceptionEnum.AUTH_FAILED.getCode().equals(code)) {
|
||||
// 客户端认证失败,直接停止服务
|
||||
log.info("client auth failed , client stop.");
|
||||
context.channel().close();
|
||||
if (!proxyConfig.getTunnel().getReconnection().getUnlimited()) {
|
||||
Solon.stop();
|
||||
stop.run();
|
||||
}
|
||||
} else if (ExceptionEnum.CONNECT_FAILED.getCode().equals(code) ||
|
||||
ExceptionEnum.LICENSE_CANNOT_REPEAT_CONNECT.getCode().equals(code)
|
||||
|
||||
+4
-3
@@ -1,10 +1,11 @@
|
||||
package org.dromara.neutrinoproxy.client.sdk.handler;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.neutrinoproxy.core.*;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.Match;
|
||||
import org.noear.snack.ONode;
|
||||
|
||||
/**
|
||||
* 异常信息处理器
|
||||
@@ -18,8 +19,8 @@ public class ProxyMessageErrorHandler implements ProxyMessageHandler {
|
||||
@Override
|
||||
public void handle(ChannelHandlerContext ctx, ProxyMessage proxyMessage) {
|
||||
log.info("error: {}", proxyMessage.getInfo());
|
||||
ONode load = ONode.load(proxyMessage.getInfo());
|
||||
Integer code = load.get("code").getInt();
|
||||
JSONObject load = JSONUtil.parseObj(proxyMessage.getInfo());
|
||||
Integer code = load.getInt("code");
|
||||
if (ExceptionEnum.AUTH_FAILED.getCode().equals(code)) {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
+5
-1
@@ -26,12 +26,16 @@ public abstract class ProxyMessageFactory extends IProxyConfiguration {
|
||||
public abstract void beanInject(String beanName, Object t);
|
||||
public abstract Object getBean(String beanName);
|
||||
|
||||
public abstract void stop();
|
||||
public abstract boolean isAotRuntime();
|
||||
|
||||
public void start(ProxyConfig proxyConfig){
|
||||
init(proxyConfig);
|
||||
IAbProxyClientService clientService=new IAbProxyClientService();
|
||||
clientService.setProxyConfig(proxyConfig);
|
||||
clientService.setCmdTunnelBootstrap((Bootstrap) getBean("cmdTunnelBootstrap"));
|
||||
clientService.setUdpServerBootstrap((Bootstrap) getBean("udpServerBootstrap"));
|
||||
clientService.setIsAotRuntime(isAotRuntime());
|
||||
clientService.init();
|
||||
}
|
||||
|
||||
@@ -60,7 +64,7 @@ public abstract class ProxyMessageFactory extends IProxyConfiguration {
|
||||
}
|
||||
public void dispatcher(ProxyConfig proxyConfig, Bootstrap tcpProxyTunnelBootstrap, Bootstrap realServerBootstrap) {
|
||||
List<ProxyMessageHandler> list = Lists.newArrayList(
|
||||
new ProxyMessageAuthHandler(proxyConfig),
|
||||
new ProxyMessageAuthHandler(proxyConfig,()->stop()),
|
||||
new ProxyMessageConnectHandler(tcpProxyTunnelBootstrap,realServerBootstrap,proxyConfig),
|
||||
new ProxyMessageDisconnectHandler(),
|
||||
new ProxyMessageErrorHandler(),
|
||||
|
||||
+3
-2
@@ -1,5 +1,6 @@
|
||||
package org.dromara.neutrinoproxy.client.sdk.handler;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@@ -12,7 +13,6 @@ import org.dromara.neutrinoproxy.core.ProxyDataTypeEnum;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessageHandler;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.Match;
|
||||
import org.noear.snack.ONode;
|
||||
|
||||
/**
|
||||
* @author: aoshiguchen
|
||||
@@ -33,7 +33,8 @@ public class UdpProxyMessageConnectHandler implements ProxyMessageHandler {
|
||||
@Override
|
||||
public void handle(ChannelHandlerContext ctx, ProxyMessage proxyMessage) {
|
||||
final Channel cmdChannel = ctx.channel();
|
||||
final ProxyMessage.UdpBaseInfo udpBaseInfo = ONode.deserialize(proxyMessage.getInfo(), ProxyMessage.UdpBaseInfo.class);
|
||||
String info = proxyMessage.getInfo();
|
||||
final ProxyMessage.UdpBaseInfo udpBaseInfo = JSONUtil.toBean(info,ProxyMessage.UdpBaseInfo.class);
|
||||
log.info("[UDP connect]info:{}", proxyMessage.getInfo());
|
||||
|
||||
// 获取连接
|
||||
|
||||
+2
-2
@@ -1,5 +1,6 @@
|
||||
package org.dromara.neutrinoproxy.client.sdk.handler;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.Channel;
|
||||
@@ -12,7 +13,6 @@ import org.dromara.neutrinoproxy.core.ProxyDataTypeEnum;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessageHandler;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.Match;
|
||||
import org.noear.snack.ONode;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
@@ -26,7 +26,7 @@ public class UdpProxyMessageTransferHandler implements ProxyMessageHandler {
|
||||
|
||||
@Override
|
||||
public void handle(ChannelHandlerContext ctx, ProxyMessage proxyMessage) {
|
||||
final ProxyMessage.UdpBaseInfo udpBaseInfo = ONode.deserialize(proxyMessage.getInfo(), ProxyMessage.UdpBaseInfo.class);
|
||||
final ProxyMessage.UdpBaseInfo udpBaseInfo = JSONUtil.toBean(proxyMessage.getInfo(),ProxyMessage.UdpBaseInfo.class);
|
||||
log.debug("[UDP transfer]info:{} data:{}", proxyMessage.getInfo(), new String(proxyMessage.getData()));
|
||||
Channel channel = UdpServerUtil.takeChannel(udpBaseInfo, ctx.channel());
|
||||
if (null == channel) {
|
||||
|
||||
+7
-9
@@ -21,21 +21,20 @@
|
||||
*/
|
||||
package org.dromara.neutrinoproxy.client.sdk.util;
|
||||
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.handler.ssl.SslHandler;
|
||||
import io.netty.util.AttributeKey;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.neutrinoproxy.client.sdk.config.ProxyConfig;
|
||||
import org.dromara.neutrinoproxy.client.sdk.core.ProxyChannelBorrowListener;
|
||||
import org.dromara.neutrinoproxy.core.Constants;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.util.AttributeKey;
|
||||
import org.dromara.neutrinoproxy.core.util.FileUtil;
|
||||
import org.noear.solon.Solon;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLEngine;
|
||||
@@ -180,11 +179,10 @@ public class ProxyUtil {
|
||||
realServerChannels.clear();
|
||||
}
|
||||
|
||||
public static String getClientId() {
|
||||
public static String getClientId(ProxyConfig proxyConfig) {
|
||||
if (StringUtils.isNotBlank(clientId)) {
|
||||
return clientId;
|
||||
}
|
||||
ProxyConfig proxyConfig = Solon.context().getBean(ProxyConfig.class);
|
||||
if (StringUtils.isNotBlank(proxyConfig.getTunnel().getClientId())) {
|
||||
clientId = proxyConfig.getTunnel().getClientId();
|
||||
return clientId;
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@ import org.dromara.neutrinoproxy.client.sdk.config.ProxyConfig;
|
||||
import org.dromara.neutrinoproxy.client.sdk.constant.Constants;
|
||||
import org.dromara.neutrinoproxy.client.sdk.core.CustomThreadFactory;
|
||||
import org.dromara.neutrinoproxy.core.ProxyMessage;
|
||||
import org.noear.solon.core.runtime.NativeDetector;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
@@ -46,9 +46,9 @@ public class UdpServerUtil {
|
||||
* 2、维护一个UDP服务池,用于需要响应的UDP转发
|
||||
* @param proxyConfig
|
||||
*/
|
||||
public static void initCache(ProxyConfig proxyConfig, Bootstrap udpServerBootstrap) {
|
||||
public static void initCache(ProxyConfig proxyConfig, Bootstrap udpServerBootstrap,Boolean isAotRuntime) {
|
||||
// aot 阶段,不初始化UDP服务
|
||||
if (NativeDetector.isAotRuntime()) {
|
||||
if (isAotRuntime) {
|
||||
return;
|
||||
}
|
||||
if (null == proxyConfig.getClient().getUdp() || StringUtils.isEmpty(proxyConfig.getClient().getUdp().getPuppetPortRange())) {
|
||||
|
||||
@@ -19,6 +19,15 @@
|
||||
<artifactId>neutrino-proxy-client-sdk</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon-lib</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.noear</groupId>
|
||||
<artifactId>solon.aot</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package org.dromara.neutrinoproxy.client.sdk.config;
|
||||
package org.dromara.neutrinoproxy.client.config;
|
||||
|
||||
import org.dromara.neutrinoproxy.client.sdk.config.ProxyConfig;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.aot.RuntimeNativeMetadata;
|
||||
import org.noear.solon.aot.RuntimeNativeRegistrar;
|
||||
+11
@@ -6,6 +6,7 @@ import org.dromara.neutrinoproxy.client.sdk.handler.ProxyMessageFactory;
|
||||
import org.noear.solon.Solon;
|
||||
import org.noear.solon.annotation.Configuration;
|
||||
import org.noear.solon.core.BeanWrap;
|
||||
import org.noear.solon.core.runtime.NativeDetector;
|
||||
|
||||
/**
|
||||
* 代理配置
|
||||
@@ -33,4 +34,14 @@ public class ProxyConfiguration extends ProxyMessageFactory {
|
||||
public Object getBean(String beanName) {
|
||||
return Solon.context().getBean(beanName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
Solon.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAotRuntime() {
|
||||
return NativeDetector.isAotRuntime();
|
||||
}
|
||||
}
|
||||
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package org.dromara.neutrinoproxy.client.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author: aoshiguchen
|
||||
* @date: 2022/6/16
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
public class SolonProxyConfig {
|
||||
@Inject("${neutrino.proxy.protocol}")
|
||||
private Protocol protocol;
|
||||
@Inject("${neutrino.proxy.tunnel}")
|
||||
private Tunnel tunnel;
|
||||
@Inject("${neutrino.proxy.client}")
|
||||
private Client client;
|
||||
|
||||
@Data
|
||||
public static class Protocol {
|
||||
private Integer maxFrameLength;
|
||||
private Integer lengthFieldOffset;
|
||||
private Integer lengthFieldLength;
|
||||
private Integer initialBytesToStrip;
|
||||
private Integer lengthAdjustment;
|
||||
private Integer readIdleTime;
|
||||
private Integer writeIdleTime;
|
||||
private Integer allIdleTimeSeconds;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Tunnel {
|
||||
private String keyStorePassword;
|
||||
private String jksPath;
|
||||
private String serverIp;
|
||||
private Integer serverPort;
|
||||
private Boolean sslEnable;
|
||||
private Integer obtainLicenseInterval;
|
||||
private String licenseKey;
|
||||
private Integer threadCount;
|
||||
private String clientId;
|
||||
private Boolean transferLogEnable;
|
||||
private Boolean heartbeatLogEnable;
|
||||
private Reconnection reconnection;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Client {
|
||||
// private Tcp tcp;
|
||||
private Udp udp;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Reconnection {
|
||||
private Integer intervalSeconds;
|
||||
private Boolean unlimited;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Tcp {
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Udp {
|
||||
private Integer bossThreadCount;
|
||||
private Integer workThreadCount;
|
||||
private String puppetPortRange;
|
||||
private Boolean transferLogEnable;
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -1,7 +1,9 @@
|
||||
package org.dromara.neutrinoproxy.client.core;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.neutrinoproxy.client.config.ProxyConfiguration;
|
||||
import org.dromara.neutrinoproxy.client.config.SolonProxyConfig;
|
||||
import org.dromara.neutrinoproxy.client.sdk.config.ProxyConfig;
|
||||
import org.noear.solon.annotation.Component;
|
||||
import org.noear.solon.annotation.Init;
|
||||
@@ -18,10 +20,11 @@ public class ProxyClientService{
|
||||
@Inject
|
||||
private ProxyConfiguration proxyConfiguration;
|
||||
@Inject
|
||||
private ProxyConfig proxyConfig;
|
||||
private SolonProxyConfig solonProxyConfig;
|
||||
@Init
|
||||
public void init() {
|
||||
log.info("启动中....");
|
||||
ProxyConfig proxyConfig = BeanUtil.toBean(solonProxyConfig, ProxyConfig.class);
|
||||
proxyConfiguration.start(proxyConfig);
|
||||
log.info("启动成功....");
|
||||
}
|
||||
|
||||
+7
-1
@@ -1,13 +1,17 @@
|
||||
package org.dromara.neutrinoproxy.client.handler;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import org.dromara.neutrinoproxy.client.config.SolonProxyConfig;
|
||||
import org.dromara.neutrinoproxy.client.sdk.config.IBeanHandler;
|
||||
import org.dromara.neutrinoproxy.client.sdk.config.ProxyConfig;
|
||||
import org.dromara.neutrinoproxy.core.dispatcher.Dispatcher;
|
||||
import org.noear.solon.Solon;
|
||||
|
||||
|
||||
|
||||
public class BeanHandler implements IBeanHandler {
|
||||
|
||||
|
||||
@Override
|
||||
public Dispatcher getDispatcher(){
|
||||
return Solon.context().getBean("dispatcher");
|
||||
@@ -15,6 +19,8 @@ public class BeanHandler implements IBeanHandler {
|
||||
|
||||
@Override
|
||||
public ProxyConfig getProxyConfig() {
|
||||
return Solon.context().getBean(ProxyConfig.class);
|
||||
SolonProxyConfig solonProxyConfig = Solon.context().getBean(SolonProxyConfig.class);
|
||||
ProxyConfig proxyConfig = BeanUtil.toBean(solonProxyConfig, ProxyConfig.class);
|
||||
return proxyConfig;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user