Browse Source
* Revert the minimal golang version requirement from 1.17 to 1.16 and add a warning in Makefile * Apply suggestions from code review Co-authored-by: John Olheiser <john.olheiser@gmail.com> * 1.16 * Update modules/util/net.go Co-authored-by: Gusted <williamzijl7@hotmail.com> * correct bool conditional yay tests for catching this :) * Update hostmatcher.go Co-authored-by: John Olheiser <john.olheiser@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: Gusted <williamzijl7@hotmail.com>tags/v1.16.6
Lunny Xiao
3 years ago
committed by
GitHub
6 changed files with 31 additions and 7 deletions
@ -0,0 +1,19 @@
|
||||
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package util |
||||
|
||||
import ( |
||||
"net" |
||||
) |
||||
|
||||
// IsIPPrivate for net.IP.IsPrivate.
|
||||
func IsIPPrivate(ip net.IP) bool { |
||||
if ip4 := ip.To4(); ip4 != nil { |
||||
return ip4[0] == 10 || |
||||
(ip4[0] == 172 && ip4[1]&0xf0 == 16) || |
||||
(ip4[0] == 192 && ip4[1] == 168) |
||||
} |
||||
return len(ip) == net.IPv6len && ip[0]&0xfe == 0xfc |
||||
} |
Loading…
Reference in new issue