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)
def ssh_connect(remote_machine, remote_port, service=VoidService, config={}): """ Connects to an RPyC server over an SSH tunnel (created by plumbum). See `Plumbum tunneling <http://plumbum.readthedocs.org/en/latest/remote.html#tunneling>`_ for further details. .. note:: This function attempts to allocate a free TCP port for the underlying tunnel, but doing so is inherently prone to a race condition with other processes who might bind the same port before sshd does. Albeit unlikely, there is no sure way around it. :param remote_machine: an :class:`plumbum.remote.RemoteMachine` instance :param remote_port: the port of the remote server :param service: the local service to expose (defaults to Void) :param config: configuration dict :returns: an RPyC connection """ # with _ssh_connect_lock: ssh_connect_lock.__enter__() loc_port = _get_free_port() tun = remote_machine.tunnel(loc_port, remote_port) stream = TunneledSocketStream.connect("localhost", loc_port) stream.tun = tun ssh_connect_lock.__exit__() return Connection(service, Channel(stream), config=config)
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)
def connect_stream(stream, service=VoidService, config={}): """creates a connection over a given stream :param stream: the stream to use :param service: the local service to expose (defaults to Void) :param config: configuration dict :returns: an RPyC connection """ return connect_channel(Channel(stream), service=service, config=config)
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)
def ssh_connect(sshctx, remote_port, service=VoidService, config={}): """ Connects to an RPyC server over an SSH tunnel :param sshctx: an :class:`rpyc.utils.ssh.SshContext` instance :param remote_port: the port of the remote server :param service: the local service to expose (defaults to Void) :param config: configuration dict :returns: an RPyC connection """ loc_port = _get_free_port() tun = sshctx.tunnel(loc_port, remote_port) stream = TunneledSocketStream.connect("localhost", loc_port) stream.tun = tun return Connection(service, Channel(stream), config=config)
def ssh_connect(remote_machine, remote_port, service=VoidService, config={}): """ Connects to an RPyC server over an SSH tunnel (created by plumbum). See `http://plumbum.readthedocs.org/en/latest/remote.html#tunneling`_ for more details. :param remote_machine: an :class:`plumbum.remote.RemoteMachine` instance :param remote_port: the port of the remote server :param service: the local service to expose (defaults to Void) :param config: configuration dict :returns: an RPyC connection """ loc_port = _get_free_port() tun = remote_machine.tunnel(loc_port, remote_port) stream = TunneledSocketStream.connect("localhost", loc_port) stream.tun = tun return Connection(service, Channel(stream), config=config)
def connect_stream(stream, service=VoidService, config={}): """creates a connection over a given stream stream - the stream to use service - the local service to expose (defaults to Void) config - configuration dict""" return connect_channel(Channel(stream), service=service, config=config)