def _endpoint_from_socksport_line(reactor, socks_config):
    """
    Internal helper.

    Returns an IStreamClientEndpoint for the given config, which is of
    the same format expected by the SOCKSPort option in Tor.
    """
    if socks_config.startswith('unix:'):
        # XXX wait, can SOCKSPort lines with "unix:/path" still
        # include options afterwards? What about if the path has a
        # space in it?
        return UNIXClientEndpoint(reactor, socks_config[5:])

    # options like KeepAliveIsolateSOCKSAuth can be appended
    # to a SocksPort line...
    if ' ' in socks_config:
        socks_config = socks_config.split()[0]
    if ':' in socks_config:
        host, port = socks_config.split(':', 1)
        port = int(port)
    else:
        host = '127.0.0.1'
        port = int(socks_config)
    return TCP4ClientEndpoint(reactor, host, port)
Internal helper.

    Returns an IStreamClientEndpoint for the given config, which is of
    the same format expected by the SOCKSPort option in Tor.