Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad32e36ba2 | ||
|
|
00fd0bab84 | ||
|
|
8f90cf461d |
@@ -12,7 +12,7 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
# see: https://docs.github.com/zh/actions/using-jobs/choosing-the-runner-for-a-job
|
# see: https://docs.github.com/zh/actions/using-jobs/choosing-the-runner-for-a-job
|
||||||
# os: ['ubuntu-20.04', 'macos-12']
|
# os: ['ubuntu-20.04', 'macos-12']
|
||||||
os: ['ubuntu-20.04']
|
os: ['ubuntu-20.04']
|
||||||
name: build - ${{ matrix.os }}
|
name: build - ${{ matrix.os }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|||||||
+6
@@ -8,6 +8,7 @@ import org.noear.solon.aot.RuntimeNativeRegistrar;
|
|||||||
import org.noear.solon.aot.hint.MemberCategory;
|
import org.noear.solon.aot.hint.MemberCategory;
|
||||||
import org.noear.solon.core.AppContext;
|
import org.noear.solon.core.AppContext;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,6 +23,11 @@ public class NeutrinoCoreRuntimeNativeRegistrar implements RuntimeNativeRegistra
|
|||||||
metadata.registerReflection(clazz, MemberCategory.INVOKE_DECLARED_METHODS);
|
metadata.registerReflection(clazz, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Set<Class<?>> byteBufferClasses = ClassUtil.scanPackageBySuper("java", ByteBuffer.class);
|
||||||
|
for (Class<?> clazz : byteBufferClasses) {
|
||||||
|
metadata.registerReflection(clazz, MemberCategory.INVOKE_DECLARED_METHODS);
|
||||||
|
}
|
||||||
|
|
||||||
metadata.registerReflection(ProxyMessage.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
metadata.registerReflection(ProxyMessage.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
||||||
metadata.registerReflection(ProxyMessage.UdpBaseInfo.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
metadata.registerReflection(ProxyMessage.UdpBaseInfo.class, MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -77,8 +77,8 @@ public class ProxyConfiguration implements LifecycleBean {
|
|||||||
}
|
}
|
||||||
ch.pipeline().addFirst(new BytesMetricsHandler());
|
ch.pipeline().addFirst(new BytesMetricsHandler());
|
||||||
// ch.pipeline().addLast(new ChannelTrafficShapingHandler(1024 * 1024 * 20, 1024 * 1024 * 20, 100, 20000));
|
// ch.pipeline().addLast(new ChannelTrafficShapingHandler(1024 * 1024 * 20, 1024 * 1024 * 20, 100, 20000));
|
||||||
ch.pipeline().addLast("security", new TcpVisitorSecurityChannelHandler());
|
ch.pipeline().addLast(new TcpVisitorSecurityChannelHandler());
|
||||||
ch.pipeline().addLast(new VisitorFlowLimiterChannelHandler());
|
ch.pipeline().addLast("flowLimiter", new VisitorFlowLimiterChannelHandler());
|
||||||
ch.pipeline().addLast(new TcpVisitorChannelHandler());
|
ch.pipeline().addLast(new TcpVisitorChannelHandler());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -116,8 +116,8 @@ public class ProxyConfiguration implements LifecycleBean {
|
|||||||
if (null != proxyConfig.getServer().getUdp().getTransferLogEnable() && proxyConfig.getServer().getUdp().getTransferLogEnable()) {
|
if (null != proxyConfig.getServer().getUdp().getTransferLogEnable() && proxyConfig.getServer().getUdp().getTransferLogEnable()) {
|
||||||
ch.pipeline().addFirst(new LoggingHandler(UdpVisitorChannelHandler.class));
|
ch.pipeline().addFirst(new LoggingHandler(UdpVisitorChannelHandler.class));
|
||||||
}
|
}
|
||||||
pipeline.addLast(udpServerWorkerGroup, "security", new UdpVisitorSecurityChannelHandler());
|
pipeline.addLast(udpServerWorkerGroup, new UdpVisitorSecurityChannelHandler());
|
||||||
ch.pipeline().addLast(new VisitorFlowLimiterChannelHandler());
|
ch.pipeline().addLast("flowLimiter", new VisitorFlowLimiterChannelHandler());
|
||||||
pipeline.addLast(udpServerWorkerGroup, new UdpVisitorChannelHandler());
|
pipeline.addLast(udpServerWorkerGroup, new UdpVisitorChannelHandler());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+2
-2
@@ -48,8 +48,8 @@ public class HttpProxy implements EventListener<AppLoadEndEvent> {
|
|||||||
ch.pipeline().addFirst(new LoggingHandler(HttpProxy.class));
|
ch.pipeline().addFirst(new LoggingHandler(HttpProxy.class));
|
||||||
}
|
}
|
||||||
ch.pipeline().addFirst(new BytesMetricsHandler());
|
ch.pipeline().addFirst(new BytesMetricsHandler());
|
||||||
ch.pipeline().addLast("security", new HttpVisitorSecurityChannelHandler(proxyConfig.getServer().getTcp().getDomainName()));
|
ch.pipeline().addLast(new HttpVisitorSecurityChannelHandler(proxyConfig.getServer().getTcp().getDomainName()));
|
||||||
ch.pipeline().addLast(new VisitorFlowLimiterChannelHandler());
|
ch.pipeline().addLast("flowLimiter",new VisitorFlowLimiterChannelHandler());
|
||||||
ch.pipeline().addLast(new HttpVisitorChannelHandler());
|
ch.pipeline().addLast(new HttpVisitorChannelHandler());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+2
-2
@@ -57,8 +57,8 @@ public class HttpsProxy implements EventListener<AppLoadEndEvent> {
|
|||||||
}
|
}
|
||||||
ch.pipeline().addLast(createSslHandler());
|
ch.pipeline().addLast(createSslHandler());
|
||||||
ch.pipeline().addFirst(new BytesMetricsHandler());
|
ch.pipeline().addFirst(new BytesMetricsHandler());
|
||||||
ch.pipeline().addLast("security", new HttpVisitorSecurityChannelHandler(proxyConfig.getServer().getTcp().getDomainName()));
|
ch.pipeline().addLast(new HttpVisitorSecurityChannelHandler(proxyConfig.getServer().getTcp().getDomainName()));
|
||||||
ch.pipeline().addLast(new VisitorFlowLimiterChannelHandler());
|
ch.pipeline().addLast("flowLimiter",new VisitorFlowLimiterChannelHandler());
|
||||||
ch.pipeline().addLast(new HttpVisitorChannelHandler());
|
ch.pipeline().addLast(new HttpVisitorChannelHandler());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+1
-3
@@ -18,8 +18,6 @@ import org.noear.solon.Solon;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class VisitorFlowLimiterChannelHandler extends ChannelInboundHandlerAdapter {
|
public class VisitorFlowLimiterChannelHandler extends ChannelInboundHandlerAdapter {
|
||||||
|
|
||||||
private final LicenseService licenseService = Solon.context().getBean(LicenseService.class);
|
|
||||||
private final PortMappingService portMappingService = Solon.context().getBean(PortMappingService.class);
|
private final PortMappingService portMappingService = Solon.context().getBean(PortMappingService.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -38,7 +36,7 @@ public class VisitorFlowLimiterChannelHandler extends ChannelInboundHandlerAdapt
|
|||||||
}
|
}
|
||||||
if (null != upLimitRate || null != downLimitRate) {
|
if (null != upLimitRate || null != downLimitRate) {
|
||||||
// 如果不全为空,则需要做限速
|
// 如果不全为空,则需要做限速
|
||||||
ctx.pipeline().addAfter("security", "trafficShaping", new ChannelTrafficShapingHandler(downLimitRate == null ? 0 : downLimitRate, upLimitRate == null ? 0 : upLimitRate, 100, 600000));
|
ctx.pipeline().addAfter("flowLimiter", "trafficShaping", new ChannelTrafficShapingHandler(downLimitRate == null ? 0 : downLimitRate, upLimitRate == null ? 0 : upLimitRate, 100, 600000));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 每个连接第一次处理之后。无论是否限速,该连接后续都不在处理,避免频繁执行影响性能
|
// 每个连接第一次处理之后。无论是否限速,该连接后续都不在处理,避免频繁执行影响性能
|
||||||
|
|||||||
Reference in New Issue
Block a user