Download common/ip.go from AZILS/new-api: direct link, hf CLI and curl.
- Browser
- Download file 478 Bytes
-
https://huggingface.co/spaces/AZILS/new-api/resolve/main/common/ip.go
- Command line
-
hf download hf://spaces/AZILS/new-api/common/ip.go
-
curl -L -o ip.go https://huggingface.co/spaces/AZILS/new-api/resolve/main/common/ip.go
478 Bytes
| package common | |
| import "net" | |
| func IsPrivateIP(ip net.IP) bool { | |
| if ip.IsLoopback() || ip.IsLinkLocalUnicast() || ip.IsLinkLocalMulticast() { | |
| return true | |
| } | |
| private := []net.IPNet{ | |
| {IP: net.IPv4(10, 0, 0, 0), Mask: net.CIDRMask(8, 32)}, | |
| {IP: net.IPv4(172, 16, 0, 0), Mask: net.CIDRMask(12, 32)}, | |
| {IP: net.IPv4(192, 168, 0, 0), Mask: net.CIDRMask(16, 32)}, | |
| } | |
| for _, privateNet := range private { | |
| if privateNet.Contains(ip) { | |
| return true | |
| } | |
| } | |
| return false | |
| } | |