Beispiel #1
0
def ssl_connect(host,
                port,
                keyfile=None,
                certfile=None,
                ca_certs=None,
                ssl_version=None,
                service=VoidService,
                config={}):
    """creates an SSL-wrapped connection to the given host (encrypted and 
    authenticated).
    host - the hostname to connect to
    port - the TCP port to use
    service - the local service to expose (defaults to Void)
    config - configuration dict
    
    keyfile, certfile, ca_certs, ssl_version -- arguments to ssl.wrap_socket.
    see that module's documentation for further info."""
    kwargs = {"server_side": False}
    if keyfile:
        kwargs["keyfile"] = keyfile
    if certfile:
        kwargs["certfile"] = certfile
    if ca_certs:
        kwargs["ca_certs"] = ca_certs
    if ssl_version:
        kwargs["ssl_version"] = ssl_version
    else:
        kwargs["ssl_version"] = ssl.PROTOCOL_TLSv1
    s = SocketStream.ssl_connect(host, port, kwargs)
    return Connection(service, Channel(s), config=config)
Beispiel #2
0
def connect(host, port, service=VoidService, config={}):
    """creates a socket-connection to the given host
    host - the hostname to connect to
    port - the TCP port to use
    service - the local service to expose (defaults to Void)
    config - configuration dict"""
    return Connection(service, Channel(SocketStream.connect(host, port)), config=config)
Beispiel #3
0
def ssl_connect(host,
                port,
                keyfile=None,
                certfile=None,
                ca_certs=None,
                cert_reqs=None,
                ssl_version=None,
                ciphers=None,
                service=VoidService,
                config={},
                ipv6=False,
                keepalive=False):
    """
    creates an SSL-wrapped connection to the given host (encrypted and
    authenticated).
    
    :param host: the hostname to connect to
    :param port: the TCP port to use
    :param service: the local service to expose (defaults to Void)
    :param config: configuration dict
    :param ipv6: whether to create an IPv6 socket or an IPv4 one
    
    The following arguments are passed directly to 
    `ssl.wrap_socket <http://docs.python.org/dev/library/ssl.html#ssl.wrap_socket>`_:
    
    :param keyfile: see ``ssl.wrap_socket``. May be ``None``
    :param certfile: see ``ssl.wrap_socket``. May be ``None``
    :param ca_certs: see ``ssl.wrap_socket``. May be ``None``
    :param cert_reqs: see ``ssl.wrap_socket``. By default, if ``ca_cert`` is specified,
                      the requirement is set to ``CERT_REQUIRED``; otherwise it is 
                      set to ``CERT_NONE``
    :param ssl_version: see ``ssl.wrap_socket``. The default is ``PROTOCOL_TLSv1``
    :param ciphers: see ``ssl.wrap_socket``. May be ``None``. New in Python 2.7/3.2

    :returns: an RPyC connection
    """
    ssl_kwargs = {"server_side": False}
    if keyfile is not None:
        ssl_kwargs["keyfile"] = keyfile
    if certfile is not None:
        ssl_kwargs["certfile"] = certfile
    if ca_certs is not None:
        ssl_kwargs["ca_certs"] = ca_certs
        ssl_kwargs["cert_reqs"] = ssl.CERT_REQUIRED
    if cert_reqs is not None:
        ssl_kwargs["cert_reqs"] = cert_reqs
    if ssl_version is None:
        ssl_kwargs["ssl_version"] = ssl.PROTOCOL_TLSv1
    else:
        ssl_kwargs["ssl_version"] = ssl_version
    if ciphers is not None:
        ssl_kwargs["ciphers"] = ciphers
    s = SocketStream.ssl_connect(host,
                                 port,
                                 ssl_kwargs,
                                 ipv6=ipv6,
                                 keepalive=keepalive)
    return connect_stream(s, service, config)
Beispiel #4
0
def connect(host, port, service=VoidService, config={}):
    """creates a socket-connection to the given host
    host - the hostname to connect to
    port - the TCP port to use
    service - the local service to expose (defaults to Void)
    config - configuration dict"""
    return Connection(service,
                      Channel(SocketStream.connect(host, port)),
                      config=config)
Beispiel #5
0
 def server(listener = listener):
     client = listener.accept()[0]
     listener.close()
     conn = connect_stream(SocketStream(client), service = remote_service,
         config = remote_config)
     try:
         conn.serve_all()
     except KeyboardInterrupt:
         interrupt_main()
Beispiel #6
0
def tlslite_connect(host, port, username, password, service = VoidService, config = {}):
    """creates a TLS-connection to the given host (encrypted and authenticated)
    username - the username used to authenticate the client
    password - the password used to authenticate the client
    host - the hostname to connect to
    port - the TCP port to use
    service - the local service to expose (defaults to Void)
    config - configuration dict"""
    s = SocketStream.tlslite_connect(host, port, username, password)
    return Connection(service, Channel(s), config=config)
Beispiel #7
0
 def server(listener=listener, args=args):
     client = listener.accept()[0]
     listener.close()
     conn = connect_stream(SocketStream(client), service = remote_service, config = remote_config)        
     try:
         for k in args:
             conn._local_root.exposed_namespace[k] = args[k]
         conn.serve_all()
     except KeyboardInterrupt:
         interrupt_main()
Beispiel #8
0
def ssl_connect(
    host,
    port,
    keyfile=None,
    certfile=None,
    ca_certs=None,
    cert_reqs=None,
    ssl_version=None,
    ciphers=None,
    service=VoidService,
    config={},
    ipv6=False,
):
    """
    creates an SSL-wrapped connection to the given host (encrypted and
    authenticated).
    
    :param host: the hostname to connect to
    :param port: the TCP port to use
    :param service: the local service to expose (defaults to Void)
    :param config: configuration dict
    :param ipv6: whether to create an IPv6 socket or an IPv4 one
    
    The following arguments are passed directly to 
    `ssl.wrap_socket <http://docs.python.org/dev/library/ssl.html#ssl.wrap_socket>`_:
    
    :param keyfile: see ``ssl.wrap_socket``. May be ``None``
    :param certfile: see ``ssl.wrap_socket``. May be ``None``
    :param ca_certs: see ``ssl.wrap_socket``. May be ``None``
    :param cert_reqs: see ``ssl.wrap_socket``. By default, if ``ca_cert`` is specified,
                      the requirement is set to ``CERT_REQUIRED``; otherwise it is 
                      set to ``CERT_NONE``
    :param ssl_version: see ``ssl.wrap_socket``. The default is ``PROTOCOL_TLSv1``
    :param ciphers: see ``ssl.wrap_socket``. May be ``None``. New in Python 2.7/3.2

    :returns: an RPyC connection
    """
    ssl_kwargs = {"server_side": False}
    if keyfile is not None:
        ssl_kwargs["keyfile"] = keyfile
    if certfile is not None:
        ssl_kwargs["certfile"] = certfile
    if ca_certs is not None:
        ssl_kwargs["ca_certs"] = ca_certs
        ssl_kwargs["cert_reqs"] = ssl.CERT_REQUIRED
    if cert_reqs is not None:
        ssl_kwargs["cert_reqs"] = cert_reqs
    if ssl_version is None:
        ssl_kwargs["ssl_version"] = ssl.PROTOCOL_TLSv1
    else:
        ssl_kwargs["ssl_version"] = ssl_version
    if ciphers is not None:
        ssl_kwargs["ciphers"] = ciphers
    s = SocketStream.ssl_connect(host, port, ssl_kwargs, ipv6=ipv6)
    return connect_stream(s, service, config)
Beispiel #9
0
def unix_connect(path, service=VoidService, config={}):
    """
    creates a socket-connection to the given host and port

    :param path: the path to the unix domain socket
    :param service: the local service to expose (defaults to Void)
    :param config: configuration dict

    :returns: an RPyC connection
    """
    s = SocketStream.unix_connect(path)
    return connect_stream(s, service, config)
Beispiel #10
0
def unix_connect(path, service = VoidService, config = {}):
    """
    creates a socket-connection to the given host and port

    :param path: the path to the unix domain socket
    :param service: the local service to expose (defaults to Void)
    :param config: configuration dict

    :returns: an RPyC connection
    """
    s = SocketStream.unix_connect(path)
    return connect_stream(s, service, config)
Beispiel #11
0
def connect(host, port, service = VoidService, config = {}, ipv6 = False, keepalive = None):
    """
    creates a socket-connection to the given host and port

    :param host: the hostname to connect to
    :param port: the TCP port to use
    :param service: the local service to expose (defaults to Void)
    :param config: configuration dict
    :param ipv6: whether to use IPv6 or not

    :returns: an RPyC connection
    """
    s = SocketStream.connect(host, port, ipv6 = ipv6, keepalive = keepalive)
    return connect_stream(s, service, config)
Beispiel #12
0
def connect(host, port, service=VoidService, config={}, ipv6=False):
    """
    creates a socket-connection to the given host and port

    :param host: the hostname to connect to
    :param port: the TCP port to use
    :param service: the local service to expose (defaults to Void)
    :param config: configuration dict
    :param ipv6: whether to use IPv6 or not

    :returns: an RPyC connection
    """
    s = SocketStream.connect(host, port, ipv6=ipv6)
    return connect_stream(s, service, config)
Beispiel #13
0
def tls_connect(host,
                port,
                username,
                password,
                service=VoidService,
                config={}):
    """creates a TLS-connection to the given host (encrypted and authenticated)
    username - the username used to authenticate the client
    password - the password used to authenticate the client
    host - the hostname to connect to
    port - the TCP port to use
    service - the local service to expose (defaults to Void)
    config - configuration dict"""
    s = SocketStream.tls_connect(host, port, username, password)
    return Connection(service, Channel(s), config=config)
Beispiel #14
0
def ssl_connect(host, port, keyfile = None, certfile = None, ca_certs = None,
        ssl_version = None, service = VoidService, config = {}):
    """creates an SSL-wrapped connection to the given host (encrypted and 
    authenticated).
    host - the hostname to connect to
    port - the TCP port to use
    service - the local service to expose (defaults to Void)
    config - configuration dict
    
    keyfile, certfile, ca_certs, ssl_version -- arguments to ssl.wrap_socket.
    see that module's documentation for further info."""
    kwargs = {"server_side" : False}
    if keyfile:
        kwargs["keyfile"] = keyfile
    if certfile:
        kwargs["certfile"] = certfile
    if ca_certs:
        kwargs["ca_certs"] = ca_certs
    if ssl_version:
        kwargs["ssl_version"] = ssl_version
    else:
        kwargs["ssl_version"] = ssl.PROTOCOL_TLSv1
    s = SocketStream.ssl_connect(host, port, kwargs)
    return Connection(service, Channel(s), config = config)