File tree Expand file tree Collapse file tree 1 file changed +1
-11
lines changed Expand file tree Collapse file tree 1 file changed +1
-11
lines changed Original file line number Diff line number Diff line change @@ -179,24 +179,14 @@ func newIPChecker(configs []TrustOption) *ipChecker {
179179 return checker
180180}
181181
182- // Go1.16+ added `ip.IsPrivate()` but until that use this implementation
183- func isPrivateIPRange (ip net.IP ) bool {
184- if ip4 := ip .To4 (); ip4 != nil {
185- return ip4 [0 ] == 10 ||
186- ip4 [0 ] == 172 && ip4 [1 ]& 0xf0 == 16 ||
187- ip4 [0 ] == 192 && ip4 [1 ] == 168
188- }
189- return len (ip ) == net .IPv6len && ip [0 ]& 0xfe == 0xfc
190- }
191-
192182func (c * ipChecker ) trust (ip net.IP ) bool {
193183 if c .trustLoopback && ip .IsLoopback () {
194184 return true
195185 }
196186 if c .trustLinkLocal && ip .IsLinkLocalUnicast () {
197187 return true
198188 }
199- if c .trustPrivateNet && isPrivateIPRange ( ip ) {
189+ if c .trustPrivateNet && ip . IsPrivate ( ) {
200190 return true
201191 }
202192 for _ , trustedRange := range c .trustExtraRanges {
You can’t perform that action at this time.
0 commit comments