net.go 243 B

12345678910111213141516
  1. package common
  2. import (
  3. "inet.af/netaddr"
  4. )
  5. func IsIpPrivate(ip netaddr.IP) bool {
  6. if ip.IsPrivate() {
  7. return true
  8. }
  9. if ip.Is4() {
  10. parts := ip.As4()
  11. return parts[0] == 100 && parts[1]&0xc0 == 64 // 100.64.0.0/10
  12. }
  13. return false
  14. }