实现WAF

This commit is contained in:
GoEdgeLab
2020-10-08 15:06:42 +08:00
parent b4cfc33875
commit 4245c73c47
110 changed files with 8179 additions and 3 deletions

View File

@@ -0,0 +1,35 @@
package requests
import (
"bytes"
"io"
"io/ioutil"
"net/http"
)
type Request struct {
*http.Request
BodyData []byte
}
func NewRequest(raw *http.Request) *Request {
return &Request{
Request: raw,
}
}
func (this *Request) Raw() *http.Request {
return this.Request
}
func (this *Request) ReadBody(max int64) (data []byte, err error) {
data, err = ioutil.ReadAll(io.LimitReader(this.Request.Body, max))
return
}
func (this *Request) RestoreBody(data []byte) {
rawReader := bytes.NewBuffer(data)
buf := make([]byte, 1024)
io.CopyBuffer(rawReader, this.Request.Body, buf)
this.Request.Body = ioutil.NopCloser(rawReader)
}

View File

@@ -0,0 +1,15 @@
package requests
import "net/http"
type Response struct {
*http.Response
BodyData []byte
}
func NewResponse(resp *http.Response) *Response {
return &Response{
Response: resp,
}
}