refactor(socket): 移除未使用的网络相关导入和注释掉的 RST 攻击检测逻辑

移除了 `ServerEvent.go` 中未使用的 `net` 和 `strings` 包导入。同时,
将原有的 RST 攻击检测及防护逻辑代码注释掉,便于后续重新设计或彻底删除。

fix(logic): 调整 fight pool 初始化与释放策略

将 `fight/action.go` 中的 `Fightpool` 类型从 `*ants.MultiPool`
改为 `*ants.Pool`,并调整其初始化方式为 `NewPool(-1)` 以适应动态扩容。
此外,在 `main.go` 中将 `ReleaseTimeout` 参数由 100 调整为 0,
确保立即清理超时任务。

feat(fight): 优化战斗输入状态重置逻辑

在 `fight/action.go` 的 `ReadyFight` 方法中提前设置
`GetInputByPlayer(c, false).Finished = true`,避免重复赋值。
同时更新了状态睡眠效果的处理流程,并简化了输入模块的状态缓存机制,
移除了冗余的 `Initeffectcache` 函数调用及相关逻辑。

perf(fight): 动态计算玩家动作等待时间

在 `loop.go` 的 `collectPlayerActions` 方法中,
将固定超时时间替换为基于 `waittime` 的动态等待时间计算公式,
提高响应灵活性。同时修复通道关闭判断条件以增强稳定性。

refactor(fight): 更新技能效果解析和状态持续逻辑

修改 `input.go` 中 `GenSataus` 方法以正确初始化状态数组;
在 `Turn.go` 中重构 `Turn_End` 方法内的执行逻辑,
确保仅在我方后手时增加回合数,提升战斗流程准确性。

chore(service): 删除废弃文件 SocketHandler_Tomee.go

完全移除已弃用的 `SocketHandler_Tomee.go` 文件及其全部内容,
减少项目冗余代码。
```
This commit is contained in:
2025-11-13 05:05:05 +08:00
parent f281b949ba
commit 6e01848b04
8 changed files with 34 additions and 77 deletions

View File

@@ -3,9 +3,7 @@ package socket
import (
"context"
"log"
"net"
"os"
"strings"
"sync/atomic"
"time"
@@ -49,14 +47,14 @@ func (s *Server) OnClose(c gnet.Conn, err error) (action gnet.Action) {
}
}()
// 识别 RST 导致的连接中断(错误信息含 "connection reset"
if err != nil && (strings.Contains(err.Error(), "connection reset") || strings.Contains(err.Error(), "reset by peer")) {
remoteIP := c.RemoteAddr().(*net.TCPAddr).IP.String()
// if err != nil && (strings.Contains(err.Error(), "connection reset") || strings.Contains(err.Error(), "reset by peer")) {
// remoteIP := c.RemoteAddr().(*net.TCPAddr).IP.String()
log.Printf("RST 攻击检测: 来源 %s, 累计攻击次数 %d", remoteIP)
// log.Printf("RST 攻击检测: 来源 %s, 累计攻击次数 %d", remoteIP)
// 防护逻辑:临时封禁异常 IP可扩展为 IP 黑名单)
// go s.tempBlockIP(remoteIP, 5*time.Minute)
}
// // 防护逻辑:临时封禁异常 IP可扩展为 IP 黑名单)
// // go s.tempBlockIP(remoteIP, 5*time.Minute)
// }
//fmt.Println(err, c.RemoteAddr().String(), "断开连接")
atomic.AddInt64(&s.connected, -1)