优化WAF关闭连接操作

This commit is contained in:
GoEdgeLab
2021-09-29 11:06:00 +08:00
parent f06d3cacb3
commit 593a27604d
4 changed files with 24 additions and 10 deletions

View File

@@ -11,6 +11,7 @@ import (
"github.com/iwind/TeaGo/types"
"io"
"io/ioutil"
"net"
"net/http"
)
@@ -305,3 +306,17 @@ func (this *HTTPRequest) WAFRestoreBody(data []byte) {
func (this *HTTPRequest) WAFServerId() int64 {
return this.Server.Id
}
// WAFClose 关闭连接
func (this *HTTPRequest) WAFClose() {
requestConn := this.RawReq.Context().Value(HTTPConnContextKey)
if requestConn == nil {
return
}
conn, ok := requestConn.(net.Conn)
if ok {
_ = conn.Close()
return
}
return
}