sdk模块去除solon相关依赖
This commit is contained in:
+27
@@ -0,0 +1,27 @@
|
||||
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;
|
||||
import org.noear.solon.aot.hint.MemberCategory;
|
||||
import org.noear.solon.core.AppContext;
|
||||
|
||||
/**
|
||||
* @author songyinyin
|
||||
* @since 2023/10/21 22:50
|
||||
*/
|
||||
@Component
|
||||
public class NeutrinoClientRuntimeNativeRegistrar implements RuntimeNativeRegistrar {
|
||||
@Override
|
||||
public void register(AppContext context, RuntimeNativeMetadata metadata) {
|
||||
metadata.registerResourceInclude("test.jks");
|
||||
|
||||
metadata.registerReflection(ProxyConfig.Protocol.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||
metadata.registerReflection(ProxyConfig.Client.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||
metadata.registerReflection(ProxyConfig.Tunnel.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||
metadata.registerReflection(ProxyConfig.Tcp.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||
metadata.registerReflection(ProxyConfig.Udp.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||
metadata.registerReflection(ProxyConfig.Reconnection.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||
}
|
||||
}
|
||||
+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