改进SYN Flood检测

This commit is contained in:
GoEdgeLab
2022-01-13 11:36:05 +08:00
parent b137170f78
commit 3411267079
2 changed files with 30 additions and 7 deletions

View File

@@ -41,3 +41,18 @@ func (this *BaseClientConn) RawIP() string {
ip, _, _ := net.SplitHostPort(this.rawConn.RemoteAddr().String())
return ip
}
// TCPConn 转换为TCPConn
func (this *BaseClientConn) TCPConn() (*net.TCPConn, bool) {
conn, ok := this.rawConn.(*net.TCPConn)
return conn, ok
}
// SetLinger 设置Linger
func (this *BaseClientConn) SetLinger(seconds int) error {
tcpConn, ok := this.TCPConn()
if ok {
return tcpConn.SetLinger(seconds)
}
return nil
}