This repository was archived by the owner on Nov 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package teaproxy
22
33import (
4+ "bufio"
45 "bytes"
56 "compress/gzip"
67 "github.com/TeaWeb/code/teaconfigs"
78 "github.com/iwind/TeaGo/logs"
9+ "net"
810 "net/http"
911)
1012
@@ -225,3 +227,12 @@ func (this *ResponseWriter) Close() {
225227 this .gzipWriter = nil
226228 }
227229}
230+
231+ // Hijack
232+ func (this * ResponseWriter ) Hijack () (conn net.Conn , buf * bufio.ReadWriter , err error ) {
233+ hijack , ok := this .writer .(http.Hijacker )
234+ if ok {
235+ return hijack .Hijack ()
236+ }
237+ return
238+ }
Original file line number Diff line number Diff line change @@ -27,6 +27,19 @@ type BlockAction struct {
2727
2828func (this * BlockAction ) Perform (waf * WAF , request * requests.Request , writer http.ResponseWriter ) (allow bool ) {
2929 if writer != nil {
30+ // if status code eq 444, we close the connection
31+ if this .StatusCode == 444 {
32+ hijack , ok := writer .(http.Hijacker )
33+ if ok {
34+ conn , _ , _ := hijack .Hijack ()
35+ if conn != nil {
36+ _ = conn .Close ()
37+ return
38+ }
39+ }
40+ }
41+
42+ // output response
3043 if this .StatusCode > 0 {
3144 writer .WriteHeader (this .StatusCode )
3245 } else {
You can’t perform that action at this time.
0 commit comments