mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-17 22:32:26 +08:00
fix(engine): wrong syntax/behaviour at prepareCIDR
This commit is contained in:
parent
39b372f163
commit
e14a43cc4c
4
gin.go
4
gin.go
@ -324,9 +324,9 @@ func (engine *Engine) Run(addr ...string) (err error) {
|
||||
|
||||
func (engine *Engine) prepareCIDR() ([]*net.IPNet, error) {
|
||||
if engine.TrustedProxies != nil {
|
||||
cidr := make([]*net.IPNet, len(engine.TrustedProxies), 0)
|
||||
cidr := make([]*net.IPNet, 0, len(engine.TrustedProxies))
|
||||
for _, trustedProxy := range engine.TrustedProxies {
|
||||
if strings.Contains(trustedProxy, "/") {
|
||||
if !strings.Contains(trustedProxy, "/") {
|
||||
trustedProxy += "/32"
|
||||
}
|
||||
_, cidrNet, err := net.ParseCIDR(trustedProxy)
|
||||
|
Loading…
x
Reference in New Issue
Block a user