func (p *Prefix) Includes(other *Prefix) (ret bool) {
	if p.net == nil || other.net == nil {
		panic(p)
	}
	otherIP := other.net.IP
	otherFirst := otherIP.Mask(other.net.Mask)
	otherLast := other.LastIP()
	return p.net.Contains(otherFirst) && p.net.Contains(otherLast)
}
Check if this prefix includes the prefix.
package models
import (
	"net"
	"strconv"
	"net/url"
	log "github.com/sirupsen/logrus"
)
type Prefix struct {
	net *net.IPNet
	Addr      string
	PrefixLen int
}
const IP_PREFIX_LENGTH int = 32
func (p *Prefix) String() string {
	return p.net.String()
}
func NewPrefix(addrString string) (p Prefix, err error) {
	if addrString == "" {
		return
	}
	ip, ipNet, err := net.ParseCIDR(addrString)
	if err != nil {
		return
	}
	sz, _ := ipNet.Mask.Size()
	p = Prefix{ipNet, ip.String(), sz}
	return
}
func NewPrefixFromFQDN(fqdn string) (p []Prefix, err error) {
	ips, err := net.LookupIP(fqdn)
	if err != nil {
		log.Warnf("Failed to look-up ip from fqdn: %+v", fqdn)
		return
	}
	p, err = NewPrefixFromIps(ips)
	return
}
func NewPrefixFromURI(uri string) (p []Prefix, err error) {
	url, err := url.Parse(uri)
	if err != nil {
		log.Warnf("Failed to parse uri: %+v to object", uri)
		return
	}
	ips, err := net.LookupIP(url.Hostname())
	if err != nil {
		log.Warnf("Failed to look-up ip from fqdn: %+v", url.Hostname())
		return
	}
	p, err = NewPrefixFromIps(ips)
	return
}
func NewPrefixFromIps(ips []net.IP) (p []Prefix, err error) {
	for _, ip := range ips {
		cdir := ip.String() + "/" + strconv.Itoa(IP_PREFIX_LENGTH)
		var ipNet *net.IPNet
		ip, ipNet, err = net.ParseCIDR(cdir)
		if err != nil {
			return
		}
		sz, _ := ipNet.Mask.Size()
		p = append(p, Prefix{ ipNet, ip.String(), sz })
	}
	return
}
func (p *Prefix) LastIP() (ip net.IP) {
	ip = p.net.IP
	for i := 0; i < len(p.net.IP); i++ {
		ip[i] |= ^p.net.Mask[i]
	}
	return
}