mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-09 13:02:33 +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
|
@ -12,14 +12,13 @@ import (
|
||||||
type cidrWhitelist struct {
|
type cidrWhitelist struct {
|
||||||
cidrWhitelistOpts
|
cidrWhitelistOpts
|
||||||
m *Middleware
|
m *Middleware
|
||||||
|
cachedAddr F.Map[string, bool] // cache for trusted IPs
|
||||||
}
|
}
|
||||||
|
|
||||||
type cidrWhitelistOpts struct {
|
type cidrWhitelistOpts struct {
|
||||||
Allow []*types.CIDR `json:"allow"`
|
Allow []*types.CIDR `json:"allow"`
|
||||||
StatusCode int `json:"statusCode"`
|
StatusCode int `json:"statusCode"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
|
|
||||||
cachedAddr F.Map[string, bool] // cache for trusted IPs
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -28,7 +27,6 @@ var (
|
||||||
Allow: []*types.CIDR{},
|
Allow: []*types.CIDR{},
|
||||||
StatusCode: http.StatusForbidden,
|
StatusCode: http.StatusForbidden,
|
||||||
Message: "IP not allowed",
|
Message: "IP not allowed",
|
||||||
cachedAddr: F.NewMapOf[string, bool](),
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -39,6 +37,7 @@ func NewCIDRWhitelist(opts OptionsRaw) (*Middleware, E.Error) {
|
||||||
before: wl.checkIP,
|
before: wl.checkIP,
|
||||||
}
|
}
|
||||||
wl.cidrWhitelistOpts = cidrWhitelistDefaults
|
wl.cidrWhitelistOpts = cidrWhitelistDefaults
|
||||||
|
wl.cachedAddr = F.NewMapOf[string, bool]()
|
||||||
err := Deserialize(opts, &wl.cidrWhitelistOpts)
|
err := Deserialize(opts, &wl.cidrWhitelistOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Add table
Reference in a new issue