mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 00:38:33 +02:00
add host filter
This commit is contained in:
@@ -7,6 +7,7 @@ type (
|
|||||||
Filters struct {
|
Filters struct {
|
||||||
StatusCodes LogFilter[*StatusCodeRange] `json:"status_codes"`
|
StatusCodes LogFilter[*StatusCodeRange] `json:"status_codes"`
|
||||||
Method LogFilter[HTTPMethod] `json:"method"`
|
Method LogFilter[HTTPMethod] `json:"method"`
|
||||||
|
Host LogFilter[Host] `json:"host"`
|
||||||
Headers LogFilter[*HTTPHeader] `json:"headers"` // header exists or header == value
|
Headers LogFilter[*HTTPHeader] `json:"headers"` // header exists or header == value
|
||||||
CIDR LogFilter[*CIDR] `json:"cidr"`
|
CIDR LogFilter[*CIDR] `json:"cidr"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ type (
|
|||||||
HTTPHeader struct {
|
HTTPHeader struct {
|
||||||
Key, Value string
|
Key, Value string
|
||||||
}
|
}
|
||||||
|
Host string
|
||||||
CIDR struct{ types.CIDR }
|
CIDR struct{ types.CIDR }
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -79,6 +80,10 @@ func (k *HTTPHeader) Fulfill(req *http.Request, res *http.Response) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h Host) Fulfill(req *http.Request, res *http.Response) bool {
|
||||||
|
return req.Host == string(h)
|
||||||
|
}
|
||||||
|
|
||||||
func (cidr CIDR) Fulfill(req *http.Request, res *http.Response) bool {
|
func (cidr CIDR) Fulfill(req *http.Request, res *http.Response) bool {
|
||||||
ip, _, err := net.SplitHostPort(req.RemoteAddr)
|
ip, _, err := net.SplitHostPort(req.RemoteAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user