func ParsePortRange(inPortRange string) (PortRange, error) {
	// Extract the protocol.
	protocol := "tcp"
	parts := strings.SplitN(inPortRange, "/", 2)
	if len(parts) == 2 {
		inPortRange = parts[0]
		protocol = parts[1]
	}

	// Parse the ports.
	portRange, err := parsePortRange(inPortRange)
	if err != nil {
		return portRange, errors.Trace(err)
	}
	if portRange.FromPort == -1 {
		protocol = "icmp"
	}
	portRange.Protocol = protocol

	return portRange, portRange.Validate()
}
// ParsePortRange builds a PortRange from the provided string. If the
// string does not include a protocol then "tcp" is used. Validate()
// gets called on the result before returning. If validation fails the
// invalid PortRange is still returned.
// Example strings: "80/tcp", "443", "12345-12349/udp", "icmp".
ParsePortRange builds a PortRange from the provided string. If the
string does not include a protocol then "tcp" is used. Validate()
gets called on the result before returning. If validation fails the
invalid PortRange is still returned.
// ParsePortRange builds a PortRange from the provided string . If the // string does not include a protocol then " tcp " is used . Validate () // gets called on the result before returning . If validation fails the // invalid PortRange is still returned . // Example strings : " 80 / tcp " " 443 " " 12345 - 12349 / udp " " icmp " .
func ParsePortRange(inPortRange string) (PortRange, error) {
	protocol := "tcp"
	parts := strings.SplitN(inPortRange, "/", 2)
	if len(parts) == 2 {
		inPortRange = parts[0]
		protocol = parts[1]
	}
	portRange, err := parsePortRange(inPortRange)
	if err != nil {
		return portRange, errors.Trace(err)
	}
	if portRange.FromPort == -1 {
		protocol = "icmp"
	}
	portRange.Protocol = protocol
	return portRange, portRange.Validate()
}
func ParsePortRange ( inPortRange string ) ( PortRange , error ) { protocol := " " parts := strings . SplitN ( inPortRange , " " , 2 ) if len ( parts ) == 2 { inPortRange = parts [ 0 ] protocol = parts [ 1 ] } portRange , err := parsePortRange ( inPortRange ) if err != nil { return portRange , errors . Trace ( err ) } if portRange . FromPort == - 1 { protocol = " " } portRange . Protocol = protocol return portRange , portRange . Validate ( ) }
ParsePortRange builds a PortRange from the provided string.
ParsePortRange builds a PortRange from the provided string .
// Extract the protocol. // Parse the ports.