netaddress.go
func (na *NetAddress) ReachabilityTo(o *NetAddress) int {
	const (
		Unreachable = 0
		Default     = iota
		Teredo
		Ipv6_weak
		Ipv4
		Ipv6_strong
		Private
	)
	if !na.Routable() {
		return Unreachable
	} else if na.RFC4380() {
		if !o.Routable() {
			return Default
		} else if o.RFC4380() {
			return Teredo
		} else if o.IP.To4() != nil {
			return Ipv4
		} else { // ipv6
			return Ipv6_weak
		}
	} else if na.IP.To4() != nil {
		if o.Routable() && o.IP.To4() != nil {
			return Ipv4
		}
		return Default
	} else /* ipv6 */ {
		var tunnelled bool
		// Is our v6 is tunnelled?
		if o.RFC3964() || o.RFC6052() || o.RFC6145() {
			tunnelled = true
		}
		if !o.Routable() {
			return Default
		} else if o.RFC4380() {
			return Teredo
		} else if o.IP.To4() != nil {
			return Ipv4
		} else if tunnelled {
			// only prioritise ipv6 if we aren't tunnelling it.
			return Ipv6_weak
		}
		return Ipv6_strong
	}
}
func (na *NetAddress) ReachabilityTo(o *NetAddress) int {
	const (
		Unreachable = 0
		Default     = iota
		Teredo
		Ipv6_weak
		Ipv4
		Ipv6_strong
		Private
	)
	if !na.Routable() {
		return Unreachable
	} else if na.RFC4380() {
		if !o.Routable() {
			return Default
		} else if o.RFC4380() {
			return Teredo
		} else if o.IP.To4() != nil {
			return Ipv4
		} else { // ipv6
			return Ipv6_weak
		}
	} else if na.IP.To4() != nil {
		if o.Routable() && o.IP.To4() != nil {
			return Ipv4
		}
		return Default
	} else /* ipv6 */ {
		var tunnelled bool
		// Is our v6 is tunnelled?
		if o.RFC3964() || o.RFC6052() || o.RFC6145() {
			tunnelled = true
		}
		if !o.Routable() {
			return Default
		} else if o.RFC4380() {
			return Teredo
		} else if o.IP.To4() != nil {
			return Ipv4
		} else if tunnelled {
			// only prioritise ipv6 if we aren't tunnelling it.
			return Ipv6_weak
		}
		return Ipv6_strong
	}
}
func ( na * NetAddress ) ReachabilityTo ( o * NetAddress ) int { const ( Unreachable = 0 Default = iota Teredo Ipv6_weak Ipv4 Ipv6_strong Private ) if ! na . Routable ( ) { return Unreachable } else if na . RFC4380 ( ) { if ! o . Routable ( ) { return Default } else if o . RFC4380 ( ) { return Teredo } else if o . IP . To4 ( ) != nil { return Ipv4 } else { // ipv6 return Ipv6_weak } } else if na . IP . To4 ( ) != nil { if o . Routable ( ) && o . IP . To4 ( ) != nil { return Ipv4 } return Default } else /* ipv6 */ { var tunnelled bool // Is our v6 is tunnelled? if o . RFC3964 ( ) || o . RFC6052 ( ) || o . RFC6145 ( ) { tunnelled = true } if ! o . Routable ( ) { return Default } else if o . RFC4380 ( ) { return Teredo } else if o . IP . To4 ( ) != nil { return Ipv4 } else if tunnelled { // only prioritise ipv6 if we aren't tunnelling it. return Ipv6_weak } return Ipv6_strong } }
// ReachabilityTo checks whenever o can be reached from na.
ReachabilityTo checks whenever o can be reached from na .