// ProjectPort prints the public port for a port binding.
166954
func ProjectPort(p project.APIProject, c *cli.Context) error {
	if len(c.Args()) != 2 {
		return cli.NewExitError("Please pass arguments in the form: SERVICE PORT", 1)
	}

	index := c.Int("index")
	protocol := c.String("protocol")
	serviceName := c.Args()[0]
	privatePort := c.Args()[1]

	port, err := p.Port(context.Background(), index, protocol, serviceName, privatePort)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	fmt.Println(port)
	return nil
}
1279338
func OptionPortMapping(portBindings []types.PortBinding) SandboxOption {
	return func(sb *sandbox) {
		if sb.config.generic == nil {
			sb.config.generic = make(map[string]interface{})
		}
		// Store a copy of the bindings as generic data to pass to the driver
		pbs := make([]types.PortBinding, len(portBindings))
		copy(pbs, portBindings)
		sb.config.generic[netlabel.PortMap] = pbs
	}
}
701374
func CreateOptionPortMapping(portBindings []types.PortBinding) EndpointOption {
	return func(ep *endpoint) {
		// Store a copy of the bindings as generic data to pass to the driver
		pbs := make([]types.PortBinding, len(portBindings))
		copy(pbs, portBindings)
		ep.generic[netlabel.PortMap] = pbs
	}
}
664666
func (n *Graph) MapInPort(name, procName, procPort string) error {
	var channel reflect.Value
	var err error
	if p, procFound := n.procs[procName]; procFound {
		if g, isNet := p.(*Graph); isNet {
			// Is a subnet
			channel, err = g.getInPort(procPort)
		} else {
			// Is a proc
			channel, err = n.getProcPort(procName, procPort, reflect.RecvDir)
		}
	} else {
		return fmt.Errorf("Could not map inport: process '%s' not found", procName)
	}
	if err == nil {
		n.inPorts[name] = port{proc: procName, port: procPort, channel: channel}
	}
	return err
}
561608
func (s *Server) EnablePublicEndpointPort(request *PublicEndpointRequest, _ *struct{}) error {
	return s.f.EnablePublicEndpointPort(s.context(), request.Serviceid, request.EndpointName, request.Name, request.IsEnabled)
}
935888
func (cl *Client) publicAddr(peer net.IP) IpPort {
	return IpPort{cl.publicIp(peer), uint16(cl.incomingPeerPort())}
}
454580
func Convert_v1_EndpointPort_To_core_EndpointPort(in *v1.EndpointPort, out *core.EndpointPort, s conversion.Scope) error {
	return autoConvert_v1_EndpointPort_To_core_EndpointPort(in, out, s)
}
1019343
func (p *PortAllocator) RequestPort(ip net.IP, proto string, port int) (int, error) {
	return p.RequestPortInRange(ip, proto, port, port)
}
504062
func (_m *ClientInterface) AddPublicEndpointPort(serviceid string, endpointName string, portAddr string, usetls bool, protocol string, isEnabled bool, restart bool) (*servicedefinition.Port, error) {
	ret := _m.Called(serviceid, endpointName, portAddr, usetls, protocol, isEnabled, restart)

	var r0 *servicedefinition.Port
	if rf, ok := ret.Get(0).(func(string, string, string, bool, string, bool, bool) *servicedefinition.Port); ok {
		r0 = rf(serviceid, endpointName, portAddr, usetls, protocol, isEnabled, restart)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(*servicedefinition.Port)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(string, string, string, bool, string, bool, bool) error); ok {
		r1 = rf(serviceid, endpointName, portAddr, usetls, protocol, isEnabled, restart)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
184142
func (a *NetAddr) Port(defaultPort int) int {
	_, port, err := net.SplitHostPort(a.Addr)
	if err != nil {
		return defaultPort
	}
	porti, err := strconv.Atoi(port)
	if err != nil {
		return defaultPort
	}
	return porti
}
65747
func (s *Service) RemovePort(application string, portAddr string) error {
	if s.Endpoints == nil {
		return fmt.Errorf("Service %s has no Endpoints", s.Name)
	}

	//find the matching endpoint
	for i := range s.Endpoints {
		ep := &s.Endpoints[i]

		if ep.Application == application && ep.Purpose == "export" {
			if len(ep.PortList) == 0 {
				break
			}

			portFound := false
			var ports = make([]servicedefinition.Port, 0)
			for _, port := range ep.PortList {
				if port.PortAddr != portAddr {
					ports = append(ports, port)
				} else {
					portFound = true
				}
			}

			//error removing an unknown port
			if !portFound {
				return fmt.Errorf("endpoint %s does not have a port endpoint %s", application, portAddr)
			}

			ep.PortList = ports
			return nil
		}
	}

	return fmt.Errorf("unable to find application %s in service: %s", application, s.Name)
}
111644
func (s *HealthCheckPolicy) SetPort(v int64) *HealthCheckPolicy {
	s.Port = &v
	return s
}
143325
func (s *OptionConfiguration) SetPort(v int64) *OptionConfiguration {
	s.Port = &v
	return s
}
919895
func (a *api) RemovePublicEndpointPort(serviceid, endpointName, portAddr string) error {
	client, err := a.connectMaster()
	if err != nil {
		return err
	}

	return client.RemovePublicEndpointPort(serviceid, endpointName, portAddr)
}
841788
func (s *CreateTargetGroupInput) SetPort(v int64) *CreateTargetGroupInput {
	s.Port = &v
	return s
}
706976
func (p *Packet) SourcePort() uint16 {
	if p.ipHdr.ipProto == IPProtocolTCP {
		return p.tcpHdr.sourcePort
	}

	return p.udpHdr.sourcePort
}
1194310
func (m *PublicPortManager) Disable(portAddr string) {
	m.mu.RLock()
	defer m.mu.RUnlock()

	// get the port handler and stop it if it exists
	h, ok := m.ports[portAddr]
	if ok {
		h.Stop()
	}
}