code: func IsAllowedNetwork(host string, allowed []string) bool {
  	if hostNoPort, _, err := net.SplitHostPort(host); err == nil {
  		host = hostNoPort
  	}
  
  	addr, err := net.ResolveIPAddr("ip", host)
  	if err != nil {
  		return false
  	}
  
  	for _, n := range allowed {
  		result := true
  		if strings.HasPrefix(n, "!") {
  			result = false
  			n = n[1:]
  		}
  		_, cidr, err := net.ParseCIDR(n)
  		if err != nil {
  			continue
  		}
  		if cidr.Contains(addr.IP) {
  			return result
  		}
  	}
  
  	return false
  }
docs: // IsAllowedNetwork returns true if the given host (IP or resolvable
  // hostname) is in the set of allowed networks (CIDR format only).