// IsOnionHost determines whether a host is part of an onion address.
511031
func IsOnionHost(host string) bool {
	// Note the starting index of the onion suffix in the host depending
	// on its length.
	var suffixIndex int
	switch len(host) {
	case V2Len:
		suffixIndex = V2Len - OnionSuffixLen
	case V3Len:
		suffixIndex = V3Len - OnionSuffixLen
	default:
		return false
	}

	// Make sure the host ends with the ".onion" suffix.
	if host[suffixIndex:] != OnionSuffix {
		return false
	}

	// We'll now attempt to decode the host without its suffix, as the
	// suffix includes invalid characters. This will tell us if the host is
	// actually valid if successful.
	host = host[:suffixIndex]
	if _, err := Base32Encoding.DecodeString(host); err != nil {
		return false
	}

	return true
}
667440
func SelectInternalHostPort(hps []HostPort, machineLocal bool) string {
	index := bestAddressIndex(len(hps), func(i int) Address {
		return hps[i].Address
	}, internalAddressMatcher(machineLocal))
	if index < 0 {
		return ""
	}
	return hps[index].NetAddr()
}
352051
func (gc *gossipChannel) IsOrgInChannel(membersOrg api.OrgIdentityType) bool {
	gc.RLock()
	defer gc.RUnlock()
	for _, orgOfChan := range gc.orgs {
		if bytes.Equal(orgOfChan, membersOrg) {
			return true
		}
	}
	return false
}
66789
func (ch *Channel) IsOn(nk string) (*ChanPrivs, bool) {
	cp, ok := ch.Nicks[nk]
	return cp, ok
}
1077148
func (r Locale_Country) IsEuropeanUnionCountry(iso2CountryCode *string) (resp bool, err error) {
	params := []interface{}{
		iso2CountryCode,
	}
	err = r.Session.DoRequest("SoftLayer_Locale_Country", "isEuropeanUnionCountry", params, &r.Options, &resp)
	return
}
727591
func (c *CORS) isOriginAllowed(origin string) (allowed bool) {
	for _, allowedOriginPattern := range c.allowOriginPatterns {
		allowed, _ = regexp.MatchString(allowedOriginPattern, origin)
		if allowed {
			return
		}
	}
	return
}
392572
func (b *BtcWallet) IsOurAddress(a btcutil.Address) bool {
	result, err := b.wallet.HaveAddress(a)
	return result && (err == nil)
}
460050
func (h *Hostsfile) lookupStaticHost(hmapByName map[string][]net.IP, host string) []net.IP {
	fqhost := absDomainName(host)

	h.RLock()
	defer h.RUnlock()

	if len(hmapByName) == 0 {
		return nil
	}

	ips, ok := hmapByName[fqhost]
	if !ok {
		return nil
	}
	ipsCp := make([]net.IP, len(ips))
	copy(ipsCp, ips)
	return ipsCp
}
1298042
func isOperatorChar(c byte) bool {
	if c < 0 {
		return false
	}
	return bytes.IndexByte([]byte("+-*/%&|!<>=~^"), c) != -1
}
1215991
func (p *Prefix) IsHostmask() bool {
	return len(p.User) > 0 && len(p.Host) > 0
}
604200
func (s *Service) IsOnboarding(ctx context.Context) (isOnboarding bool, err error) {
	result, ok := s.onboardingKV.Load(onboardingKey)
	isOnboarding = !ok || !result.(bool)
	return isOnboarding, nil
}
1054664
func SSHHost(e ec2Describer, sshInterface string) func(multistep.StateBag) (string, error) {
	return func(state multistep.StateBag) (string, error) {
		const tries = 2
		// <= with current structure to check result of describing `tries` times
		for j := 0; j <= tries; j++ {
			var host string
			i := state.Get("instance").(*ec2.Instance)
			if sshInterface != "" {
				switch sshInterface {
				case "public_ip":
					if i.PublicIpAddress != nil {
						host = *i.PublicIpAddress
					}
				case "private_ip":
					if i.PrivateIpAddress != nil {
						host = *i.PrivateIpAddress
					}
				case "public_dns":
					if i.PublicDnsName != nil {
						host = *i.PublicDnsName
					}
				case "private_dns":
					if i.PrivateDnsName != nil {
						host = *i.PrivateDnsName
					}
				default:
					panic(fmt.Sprintf("Unknown interface type: %s", sshInterface))
				}
			} else if i.VpcId != nil && *i.VpcId != "" {
				if i.PublicIpAddress != nil && *i.PublicIpAddress != "" {
					host = *i.PublicIpAddress
				} else if i.PrivateIpAddress != nil && *i.PrivateIpAddress != "" {
					host = *i.PrivateIpAddress
				}
			} else if i.PublicDnsName != nil && *i.PublicDnsName != "" {
				host = *i.PublicDnsName
			}

			if host != "" {
				return host, nil
			}

			r, err := e.DescribeInstances(&ec2.DescribeInstancesInput{
				InstanceIds: []*string{i.InstanceId},
			})
			if err != nil {
				return "", err
			}

			if len(r.Reservations) == 0 || len(r.Reservations[0].Instances) == 0 {
				return "", fmt.Errorf("instance not found: %s", *i.InstanceId)
			}

			state.Put("instance", r.Reservations[0].Instances[0])
			time.Sleep(sshHostSleepDuration)
		}

		return "", errors.New("couldn't determine address for instance")
	}
}
458210
func (st *stateTracker) IsOn(c, n string) (*ChanPrivs, bool) {
	st.mu.Lock()
	defer st.mu.Unlock()
	nk, nok := st.nicks[n]
	ch, cok := st.chans[c]
	if nok && cok {
		return nk.isOn(ch)
	}
	return nil, false
}
99260
func (w Week) IsOccurring(t time.Time) bool {
	weekInt := int(w)

	if weekInt == Last {
		return isLastWeekInMonth(t)
	}

	return weekInMonth(t) == weekInt
}
1060635
func EnsureFirstHostPort(first HostPort, hps []HostPort) []HostPort {
	var result []HostPort
	found := false
	for _, hp := range hps {
		if hp.NetAddr() == first.NetAddr() && !found {
			// Found, so skip it.
			found = true
			continue
		}
		result = append(result, hp)
	}
	// Insert it at the top.
	result = append([]HostPort{first}, result...)
	return result
}
1309112
func (c *curvePoint) IsOnCurve() bool {
	yy := new(big.Int).Mul(c.y, c.y)
	xxx := new(big.Int).Mul(c.x, c.x)
	xxx.Mul(xxx, c.x)
	yy.Sub(yy, xxx)
	yy.Sub(yy, curveB)
	if yy.Sign() < 0 || yy.Cmp(P) >= 0 {
		yy.Mod(yy, P)
	}
	return yy.Sign() == 0
}
642017
func (r Network_Storage_Allowed_Host_VirtualGuest) CreateFromIpAddress(ipAddressId *int, iqn *string) (resp datatypes.Network_Storage_Allowed_Host, err error) {
	params := []interface{}{
		ipAddressId,
		iqn,
	}
	err = r.Session.DoRequest("SoftLayer_Network_Storage_Allowed_Host_VirtualGuest", "createFromIpAddress", params, &r.Options, &resp)
	return
}