func ExtractPortsAndProtocolFromHostService(service string) (*PortsRange, string, error) {

	proto := ""
	var portSubString string

	portSubString, proto, err := ExtractPortsAndProtocol(service)
	if err != nil {
		proto = protocols.L4ProtocolTCP
		portSubString = strings.ToUpper(service)
	}

	if strings.Contains(portSubString, ":") {

		parts := strings.SplitN(portSubString, ":", 2)
		if len(parts) != 2 {
			return nil, "", fmt.Errorf("%s does not have a valid port range", service)
		}

		min, err := ConvertToSinglePort(parts[0])
		if err != nil {
			return nil, "", err
		}

		max, err := ConvertToSinglePort(parts[1])
		if err != nil {
			return nil, "", err
		}

		if min > max {
			return nil, "", fmt.Errorf("%s is not a valid port range", portSubString)
		}
		return &PortsRange{FromPort: min, ToPort: max}, proto, nil
	}

	min, err := ConvertToSinglePort(portSubString)
	if err != nil {
		return nil, "", err
	}

	return &PortsRange{FromPort: min, ToPort: min}, proto, nil
}
// ExtractPortsAndProtocolFromHostService extracts the port range and the protocol from a host service like tcp/80:100.
// If the prefix is neither tcp or udp it will return an error.
// NOTE: The protocol should be in uppercase to match our list of protocols here
// https://github.com/aporeto-inc/gaia/blob/master/protocols/protocols.go
ExtractPortsAndProtocolFromHostService extracts the port range and the protocol from a host service like tcp/80:100.
If the prefix is neither tcp or udp it will return an error.
// ExtractPortsAndProtocolFromHostService extracts the port range and the protocol from a host service like tcp / 80 : 100 . // If the prefix is neither tcp or udp it will return an error . // NOTE : The protocol should be in uppercase to match our list of protocols here // https : // github . com / aporeto - inc / gaia / blob / master / protocols / protocols . go
func ExtractPortsAndProtocolFromHostService(service string) (*PortsRange, string, error) {
	proto := ""
	var portSubString string
	portSubString, proto, err := ExtractPortsAndProtocol(service)
	if err != nil {
		proto = protocols.L4ProtocolTCP
		portSubString = strings.ToUpper(service)
	}
	if strings.Contains(portSubString, ":") {
		parts := strings.SplitN(portSubString, ":", 2)
		if len(parts) != 2 {
			return nil, "", fmt.Errorf("%s does not have a valid port range", service)
		}
		min, err := ConvertToSinglePort(parts[0])
		if err != nil {
			return nil, "", err
		}
		max, err := ConvertToSinglePort(parts[1])
		if err != nil {
			return nil, "", err
		}
		if min > max {
			return nil, "", fmt.Errorf("%s is not a valid port range", portSubString)
		}
		return &PortsRange{FromPort: min, ToPort: max}, proto, nil
	}
	min, err := ConvertToSinglePort(portSubString)
	if err != nil {
		return nil, "", err
	}
	return &PortsRange{FromPort: min, ToPort: min}, proto, nil
}
func ExtractPortsAndProtocolFromHostService ( service string ) ( * PortsRange , string , error ) { proto := " " var portSubString string portSubString , proto , err := ExtractPortsAndProtocol ( service ) if err != nil { proto = protocols . L4ProtocolTCP portSubString = strings . ToUpper ( service ) } if strings . Contains ( portSubString , " " ) { parts := strings . SplitN ( portSubString , " " , 2 ) if len ( parts ) != 2 { return nil , " " , fmt . Errorf ( " " , service ) } min , err := ConvertToSinglePort ( parts [ 0 ] ) if err != nil { return nil , " " , err } max , err := ConvertToSinglePort ( parts [ 1 ] ) if err != nil { return nil , " " , err } if min > max { return nil , " " , fmt . Errorf ( " " , portSubString ) } return & PortsRange { FromPort : min , ToPort : max } , proto , nil } min , err := ConvertToSinglePort ( portSubString ) if err != nil { return nil , " " , err } return & PortsRange { FromPort : min , ToPort : min } , proto , nil }
ExtractPortsAndProtocolFromHostService extracts the port range and the protocol from a host service like tcp/80:100.
ExtractPortsAndProtocolFromHostService extracts the port range and the protocol from a host service like tcp / 80 : 100 .