// isWhitelisted returns whether the IP address is included in the whitelisted
// networks and IPs.
480513
func isWhitelisted(addr net.Addr) bool {
	if len(cfg.whitelists) == 0 {
		return false
	}

	host, _, err := net.SplitHostPort(addr.String())
	if err != nil {
		srvrLog.Warnf("Unable to SplitHostPort on '%s': %v", addr, err)
		return false
	}
	ip := net.ParseIP(host)
	if ip == nil {
		srvrLog.Warnf("Unable to parse IP '%s'", addr)
		return false
	}

	for _, ipnet := range cfg.whitelists {
		if ipnet.Contains(ip) {
			return true
		}
	}
	return false
}
646458
func (na *cnmNetworkAllocator) IsAllocated(n *api.Network) bool {
	_, ok := na.networks[n.ID]
	return ok
}
191470
func (wl *BasicNet) Permitted(ip net.IP) bool {
	if !validIP(ip) { // see whitelist.go for this function
		return false
	}

	wl.lock.Lock()
	defer wl.lock.Unlock()
	for i := range wl.whitelist {
		if wl.whitelist[i].Contains(ip) {
			return true
		}
	}
	return false
}
110702
func VerifyAgainstWhitelist(tolerations []api.Toleration, whitelist []api.Toleration) bool {
	if len(whitelist) == 0 {
		return true
	}

	t := ConvertTolerationToAMap(tolerations)
	w := ConvertTolerationToAMap(whitelist)

	for k1, v1 := range t {
		if v2, ok := w[k1]; !ok || !AreEqual(v1, v2) {
			return false
		}
	}
	return true
}
400852
func (ctx *context) IsWWW() bool {
	host := ctx.Host()
	if index := strings.IndexByte(host, '.'); index > 0 {
		// if it has a subdomain and it's www then return true.
		if subdomain := host[0:index]; !strings.Contains(ctx.Application().ConfigurationReadOnly().GetVHost(), subdomain) {
			return subdomain == "www"
		}
	}
	return false
}
343106
func (wl HostStub) Permitted(ip net.IP) bool {
	log.Printf("WARNING: whitelist check for %s but whitelisting is stubbed", ip)
	return true
}
25323
func isInNet(host, pattern, mask string) bool {
	if len(host) == 0 {
		return false
	}

	address, err := net.ResolveIPAddr("ip4", host)

	if err != nil {
		return false
	}

	maskIp := net.IPMask(net.ParseIP(mask))
	return address.IP.Mask(maskIp).String() == pattern
}
1047218
func (w whitelist) IsValid(value string) bool {
	return w.rule.IsValid(value)
}
1170919
func (s *UpdateInputSecurityGroupInput) SetWhitelistRules(v []*InputWhitelistRuleCidr) *UpdateInputSecurityGroupInput {
	s.WhitelistRules = v
	return s
}
1080488
func Whitelisting() echo.HandlerFunc {

	// swagger:route GET /me/whitelisting me info whitelisting getMeWhitelisted
	//
	// Shows the whitelisting informations for the current user
	//
	// You can personalize the request via query string parameters
	//
	//	Produces:
	//	- application/json
	//
	//	Security:
	//		oauth: profile:read
	//
	//	Responses:
	//		default: MeWhitelisting

	return func(c echo.Context) error {
		return user.Whitelisting()(c)
	}
}
885921
func Whitelist() echo.HandlerFunc {

	// swagger:route GET /users/{id}/whitelist users whitelist GetWhitelist
	//
	// Show the whitelist of the specified user
	//
	// You can personalize the request via query string parameters
	//
	//	Produces:
	//	- application/json
	//
	//	Security:
	//		oauth: profile:read
	//
	//	Responses:
	//		default: UsersIdWhitelist

	return func(c echo.Context) error {
		if !rest.IsGranted("profile:read", c) {
			return rest.InvalidScopeResponse("profile:read", c)
		}
		whitelist := c.Get("other").(*nerdz.User).Whitelist()
		return rest.SelectFields(rest.GetUsersInfo(whitelist), c)
	}
}
489609
func (s *DescribeOriginEndpointOutput) SetWhitelist(v []*string) *DescribeOriginEndpointOutput {
	s.Whitelist = v
	return s
}
230295
func (n *node) isAllowed(c nodeContent, here bool) bool {
	if n.container.duplicates {
		return true
	}
	checkNode := n
	if here {
		checkNode = n.parent
	}
	for _, child := range checkNode.children {
		if child.content.key() == c.key() {
			return false
		}
	}
	return true
}
585499
func (s *Service) WhitelistedAddOnServiceListByOrganization(ctx context.Context, organizationIdentity string, lr *ListRange) (WhitelistedAddOnServiceListByOrganizationResult, error) {
	var whitelistedAddOnService WhitelistedAddOnServiceListByOrganizationResult
	return whitelistedAddOnService, s.Get(ctx, &whitelistedAddOnService, fmt.Sprintf("/organizations/%v/whitelisted-addon-services", organizationIdentity), nil, lr)
}
734035
func (t *TxInfo) IsLiveTicket() bool {
	return t.Type == "Ticket" && t.Mature == "True" && t.SpendStatus != "Voted" &&
		t.PoolStatus == "live" && t.TicketLiveBlocks < t.TicketExpiry
}
921706
func IsLocalhost(host string) bool {
	if host == "localhost" {
		return true
	}
	ip := net.ParseIP(host)
	return ip.IsLoopback() || ip.IsUnspecified()
}
762059
func setWhitelistIdentityEntry(ctx context.Context, s logical.Storage, instanceID string, identity *whitelistIdentity) error {
	entry, err := logical.StorageEntryJSON("whitelist/identity/"+instanceID, identity)
	if err != nil {
		return err
	}

	if err := s.Put(ctx, entry); err != nil {
		return err
	}
	return nil
}