MCPcopy Create free account
hub / github.com/e2wugui/zeze / checkThrottle

Method checkThrottle

ZezeJava/ZezeJava/src/main/java/Zeze/Net/Service.java:822–831  ·  view source on GitHub ↗

接收一个协议(尚未处理)时,判断单个socket是否接收超限 @return 是否检查通过, false则丢弃该协议(也可以同时关闭连接)

(@NotNull AsyncSocket sender, int moduleId, int protocolId, int size)

Source from the content-addressed store, hash-verified

820 * @return 是否检查通过, false则丢弃该协议(也可以同时关闭连接)
821 */
822 @SuppressWarnings("MethodMayBeStatic")
823 public boolean checkThrottle(@NotNull AsyncSocket sender, int moduleId, int protocolId, int size) {
824 var throttle = sender.getTimeThrottle();
825 if (null != throttle && !throttle.checkNow(size)) {
826 // trySendResultCode(Procedure.Busy); // 超过速度限制,不报告错误。因为可能是一种攻击。
827 sender.close(throttleException); // 默认关闭连接。
828 return false; // 超过速度控制,丢弃这条协议。
829 }
830 return true;
831 }
832
833 public boolean discard(@NotNull AsyncSocket sender, int moduleId, int protocolId, int size) throws Exception {
834 return false;

Callers 1

decodeMethod · 0.80

Calls 3

checkNowMethod · 0.65
closeMethod · 0.65
getTimeThrottleMethod · 0.45

Tested by

no test coverage detected