Custom private blocks (#1705)

Co-authored-by: Asim Aslam <asim@aslam.me>
This commit is contained in:
Di Wu
2020-06-17 00:05:42 +08:00
committed by GitHub
parent c67d78f1ef
commit 6add74b4f6
2 changed files with 30 additions and 0 deletions

View File

@@ -17,6 +17,15 @@ func init() {
}
}
// AppendPrivateBlocks append private network blocks
func AppendPrivateBlocks(bs ...string) {
for _, b := range bs {
if _, block, err := net.ParseCIDR(b); err == nil {
privateBlocks = append(privateBlocks, block)
}
}
}
func isPrivateIP(ipAddr string) bool {
ip := net.ParseIP(ipAddr)
for _, priv := range privateBlocks {