// Port assignment and IP for the given label or empty values.
170745
func (ns Networks) Port(label string) (string, int) {
	for _, n := range ns {
		for _, p := range n.ReservedPorts {
			if p.Label == label {
				return n.IP, p.Value
			}
		}
		for _, p := range n.DynamicPorts {
			if p.Label == label {
				return n.IP, p.Value
			}
		}
	}
	return "", 0
}
946405
func (r *Request) QueryOptionLabel(key string, labels map[string]string) *Request {
	if r.err != nil {
		return r
	}
	if b, err := json.Marshal(labels); err != nil {
		r.err = err
	} else {
		if r.params == nil {
			r.params = make(url.Values)
		}
		r.params.Add(string(key), string(b))
	}
	return r
}
894234
func (m *PublicPortManager) Set(portAddr string, data []registry.ExportDetails) {
	m.mu.Lock()
	defer m.mu.Unlock()

	h, ok := m.ports[portAddr]
	if ok {
		h.SetExports(data)
	} else {
		h = NewPublicPortHandler(portAddr, data...)
		m.ports[portAddr] = h
	}
}
429284
func (t *Target) addr() string {
	if t.IP.To4() != nil {
		return fmt.Sprintf("%v:%d", t.IP, t.Port)
	}
	return fmt.Sprintf("[%v]:%d", t.IP, t.Port)
}
296620
func portName(port int, protocol corev1.Protocol) string {
	if protocol == "" {
		protocol = corev1.ProtocolTCP
	}
	return strings.ToLower(fmt.Sprintf("%d-%s", port, protocol))
}
974629
func IP(i net.IP) func(*Server) error {
	return func(s *Server) error {
		s.ip = i
		return nil
	}
	return nil
}
1192522
func (s *service) assignIPToEndpoint(ip, eID string) (bool, int) {
	return s.ipToEndpoint.Insert(ip, eID)
}
914385
func (f *FlagSet) IPVar(p *net.IP, name string, value net.IP, usage string) {
	f.VarP(newIPValue(value, p), name, "", usage)
}
15276
func (h *HTTPBin) IP(w http.ResponseWriter, r *http.Request) {
	body, _ := json.Marshal(&ipResponse{
		Origin: getOrigin(r),
	})
	writeJSON(w, body, http.StatusOK)
}
549939
func (e *Endpoint) Empty() bool {
	return e == nil ||
		(e.ServiceName == "" && e.Port == 0 && len(e.IPv4) == 0 && len(e.IPv6) == 0)
}
529609
func IP() (string, error) {
	ips := make(chan string, 1)
	errs := make(chan error, 1)
	for _, server := range ipServers {
		server := server
		go func() {
			resp, err := http.Get(server)
			if err != nil {
				errs <- err
				return
			}
			body, _ := ioutil.ReadAll(resp.Body)
			ipAddr := strings.TrimSpace(string(body))
			ip := net.ParseIP(ipAddr)
			if ip == nil {
				errs <- fmt.Errorf("invalid ip address: %s", ipAddr)
				return
			}
			ips <- ip.String()
		}()
	}
	var errors []error
	var resps []string
	respMap := make(map[string]int)
	for (len(resps) < 2 || len(respMap) > 1) && len(resps)+len(errors) < len(ipServers) {
		select {
		case resp := <-ips:
			resps = append(resps, resp)
			respMap[resp]++
		case err := <-errs:
			errors = append(errors, err)
		}
	}
	if len(resps) == 0 {
		return "", errors[0]
	}
	// pick best ip address
	var best string
	mostVotes := 0
	for addr, votes := range respMap {
		if votes > mostVotes {
			mostVotes = votes
			best = addr
		}
	}
	return best, nil
}
1042737
func (h HostPortInfo) Add(ip, protocol string, port int32) {
	if port <= 0 {
		return
	}

	h.sanitize(&ip, &protocol)

	pp := NewProtocolPort(protocol, port)
	if _, ok := h[ip]; !ok {
		h[ip] = map[ProtocolPort]struct{}{
			*pp: {},
		}
		return
	}

	h[ip][*pp] = struct{}{}
}
555388
func IPLess(a, b net.IP) bool {
	b = b.To4()
	for i, ai := range a.To4() {
		if ai != b[i] {
			return ai < b[i]
		}
	}
	return false
}
448834
func (this *ControlPlaneDao) AssignIPs(assignmentRequest addressassignment.AssignmentRequest, _ *int) error {
	return this.facade.AssignIPs(datastore.Get(), assignmentRequest)
}
990442
func (s *Aloja) Port(p string) *Aloja {
	s.port = p
	return s
}
631453
func (n *Network) PeerPort(p *Peer, portName PortName) uint16 {
	peerPorts := n.PortsByPeerID[p.ID()]
	Expect(peerPorts).NotTo(BeNil())
	return peerPorts[portName]
}
435650
func (m *kubeGenericRuntimeManager) determinePodSandboxIP(podNamespace, podName string, podSandbox *runtimeapi.PodSandboxStatus) string {
	if podSandbox.Network == nil {
		klog.Warningf("Pod Sandbox status doesn't have network information, cannot report IP")
		return ""
	}
	ip := podSandbox.Network.Ip
	if len(ip) != 0 && net.ParseIP(ip) == nil {
		// ip could be an empty string if runtime is not responsible for the
		// IP (e.g., host networking).
		klog.Warningf("Pod Sandbox reported an unparseable IP %v", ip)
		return ""
	}
	return ip
}