mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-09 04:52:35 +02:00
fixed CIDR whitelist shared its IP cache map when it should not
This commit is contained in:
parent
f97e3f65fe
commit
cceebff93a
1 changed files with 3 additions and 4 deletions
|
@ -11,15 +11,14 @@ import (
|
|||
|
||||
type cidrWhitelist struct {
|
||||
cidrWhitelistOpts
|
||||
m *Middleware
|
||||
m *Middleware
|
||||
cachedAddr F.Map[string, bool] // cache for trusted IPs
|
||||
}
|
||||
|
||||
type cidrWhitelistOpts struct {
|
||||
Allow []*types.CIDR `json:"allow"`
|
||||
StatusCode int `json:"statusCode"`
|
||||
Message string `json:"message"`
|
||||
|
||||
cachedAddr F.Map[string, bool] // cache for trusted IPs
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -28,7 +27,6 @@ var (
|
|||
Allow: []*types.CIDR{},
|
||||
StatusCode: http.StatusForbidden,
|
||||
Message: "IP not allowed",
|
||||
cachedAddr: F.NewMapOf[string, bool](),
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -39,6 +37,7 @@ func NewCIDRWhitelist(opts OptionsRaw) (*Middleware, E.Error) {
|
|||
before: wl.checkIP,
|
||||
}
|
||||
wl.cidrWhitelistOpts = cidrWhitelistDefaults
|
||||
wl.cachedAddr = F.NewMapOf[string, bool]()
|
||||
err := Deserialize(opts, &wl.cidrWhitelistOpts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Add table
Reference in a new issue