// Add whitelists an IP.
331456
func (wl *Basic) Add(ip net.IP) {
	if !validIP(ip) {
		return
	}

	wl.lock.Lock()
	defer wl.lock.Unlock()
	wl.whitelist[ip.String()] = true
}
153762
func (bl *blackList) insert(ip string, port int) {
	if bl.list.Len() >= bl.maxSize {
		return
	}

	bl.list.Set(bl.genKey(ip, port), &blockedItem{
		ip:         ip,
		port:       port,
		createTime: time.Now(),
	})
}
1372962
func (g *GSLBRecordSets) AddServer(ip string) {
	var record GSLBServer
	var isExist = false
	for i := range g.Servers {
		if g.Servers[i].IPAddress == ip {
			isExist = true
		}
	}

	if !isExist {
		record = GSLBServer{
			IPAddress: ip,
			Enabled:   "True",
			Weight:    "1",
		}
		g.Servers = append(g.Servers, record)
	}
}
1213581
func (p *ProxyLB) AddServer(ip string, port int, enabled bool) {
	p.Settings.ProxyLB.AddServer(ip, port, enabled)
}
715133
func (api *API) AddUserApiAlowedIps(user_id string, ips []string) (*User, error) {
	result := new(User)
	req := struct {
		Ips []string `json:"ips"`
	}{ips}
	url := createUrl(api, userPathSegment, user_id, "api/ips")
	err := api.Client.Post(url, &req, &result, http.StatusCreated)
	if err != nil {
		return nil, err
	}
	result.api = api
	return result, nil
}
622725
func (c *CNIConfig) AddNetworkList(ctx context.Context, list *NetworkConfigList, rt *RuntimeConf) (types.Result, error) {
	var err error
	var result types.Result
	for _, net := range list.Plugins {
		result, err = c.addNetwork(ctx, list.Name, list.CNIVersion, net, result, rt)
		if err != nil {
			return nil, err
		}
	}

	if err = setCachedResult(result, list.Name, rt); err != nil {
		return nil, fmt.Errorf("failed to set network %q cached result: %v", list.Name, err)
	}

	return result, nil
}
1374651
func (c *Client) ListIPv4(id string) (list []IPv4, err error) {
	var ipMap map[string][]IPv4
	if err := c.get(`server/list_ipv4?SUBID=`+id+`&public_network=yes`, &ipMap); err != nil {
		return nil, err
	}

	for _, iplist := range ipMap {
		for _, ip := range iplist {
			list = append(list, ip)
		}
	}
	sort.Sort(ipv4s(list))
	return list, nil
}
414374
func (wl *Basic) Remove(ip net.IP) {
	if !validIP(ip) {
		return
	}

	wl.lock.Lock()
	defer wl.lock.Unlock()
	delete(wl.whitelist, ip.String())
}
350306
func (api *API) AddFirewallPolicyRules(fp_id string, fp_rules []FirewallPolicyRule) (*FirewallPolicy, error) {
	result := new(FirewallPolicy)
	data := struct {
		Rules []FirewallPolicyRule `json:"rules"`
	}{fp_rules}
	url := createUrl(api, firewallPolicyPathSegment, fp_id, "rules")
	err := api.Client.Post(url, &data, &result, http.StatusAccepted)
	if err != nil {
		return nil, err
	}
	result.api = api
	return result, nil
}
1219215
func whitelistKey(whiteKeys []string, key string) bool {
	for _, whiteKey := range whiteKeys {
		if key == whiteKey {
			return true
		}
	}
	return false
}
927531
func (pl *List) addPeer(t *peerThunk) error {
	if t.peer.Status().ConnectionStatus != peer.Available {
		return pl.addToUnavailablePeers(t)
	}

	return pl.addToAvailablePeers(t)
}
1043156
func (api *API) AddFirewallPolicyServerIps(fp_id string, ip_ids []string) (*FirewallPolicy, error) {
	result := new(FirewallPolicy)
	request := serverIps{
		ServerIps: ip_ids,
	}

	url := createUrl(api, firewallPolicyPathSegment, fp_id, "server_ips")
	err := api.Client.Post(url, &request, &result, http.StatusAccepted)
	if err != nil {
		return nil, err
	}
	result.api = api
	return result, nil
}
1146707
func (api *PrivateAdminAPI) AddPeer(url string) (bool, error) {
	// Make sure the server is running, fail otherwise
	server := api.node.Server()
	if server == nil {
		return false, ErrNodeStopped
	}
	// Try to add the url as a static peer and return
	node, err := enode.ParseV4(url)
	if err != nil {
		return false, fmt.Errorf("invalid enode: %v", err)
	}
	server.AddPeer(node)
	return true, nil
}
323770
func (s *DistinctNetSet) Add(ip net.IP) bool {
	key := s.key(ip)
	n := s.members[string(key)]
	if n < s.Limit {
		s.members[string(key)] = n + 1
		return true
	}
	return false
}
759847
func (api *API) ListFirewallPolicyServerIps(fp_id string) ([]ServerIpInfo, error) {
	result := []ServerIpInfo{}
	url := createUrl(api, firewallPolicyPathSegment, fp_id, "server_ips")
	err := api.Client.Get(url, &result, http.StatusOK)
	if err != nil {
		return nil, err
	}
	return result, nil
}
324015
func AddIp(ip, iface string) error {
	link, err := netlink.LinkByName(iface)
	if err != nil {
		return err
	}

	addr, err := netlink.ParseAddr(ip)
	if err != nil {
		return err
	}

	return netlink.AddrAdd(link, addr)
}
340307
func (wl *BasicNet) Remove(n *net.IPNet) {
	if n == nil {
		return
	}

	index := -1
	wl.lock.Lock()
	defer wl.lock.Unlock()
	for i := range wl.whitelist {
		if wl.whitelist[i].String() == n.String() {
			index = i
			break
		}
	}

	if index == -1 {
		return
	}

	wl.whitelist = append(wl.whitelist[:index], wl.whitelist[index+1:]...)
}