(port)
Validate a single string specifying ports for Onion
    services. These look like: "80 127.0.0.1:4321"
Validate a single string specifying ports for Onion
    services. These look like: "80 127.0.0.1:4321"
Validate a single string specifying ports for Onion services . These look like : 80 127 . 0 . 0 . 1 : 4321
def _validate_single_port_string(port):
    """
    Validate a single string specifying ports for Onion
    services. These look like: "80 127.0.0.1:4321"
    """
    if ' ' not in port or len(port.split(' ')) != 2:
        raise ValueError(
            "Port '{}' should have exactly one space in it".format(port)
        )
    (external, internal) = port.split(' ')
    try:
        external = int(external)
    except ValueError:
        raise ValueError(
            "Port '{}' external port isn't an int".format(port)
        )
    if ':' not in internal:
        raise ValueError(
            "Port '{}' local address should be 'IP:port'".format(port)
        )
    if not internal.startswith('unix:'):
        ip, localport = internal.split(':')
        if ip != 'localhost' and not _is_non_public_numeric_address(ip):
            raise ValueError(
                "Port '{}' internal IP '{}' should be a local "
                "address".format(port, ip)
            )
def _validate_single_port_string ( port ) : if ' ' not in port or len ( port . split ( ' ' ) ) != 2 : raise ValueError ( "Port '{}' should have exactly one space in it" . format ( port ) ) ( external , internal ) = port . split ( ' ' ) try : external = int ( external ) except ValueError : raise ValueError ( "Port '{}' external port isn't an int" . format ( port ) ) if ':' not in internal : raise ValueError ( "Port '{}' local address should be 'IP:port'" . format ( port ) ) if not internal . startswith ( 'unix:' ) : ip , localport = internal . split ( ':' ) if ip != 'localhost' and not _is_non_public_numeric_address ( ip ) : raise ValueError ( "Port '{}' internal IP '{}' should be a local " "address" . format ( port , ip ) )