""" abstraction layer over OS-depenedent byte streams """ import sys import os import socket import time import errno from select import select from rpyc.utils.lib import safe_import win32file = safe_import("win32file") win32pipe = safe_import("win32pipe") msvcrt = safe_import("msvcrt") retry_errnos = set([errno.EAGAIN]) if hasattr(errno, "WSAEWOULDBLOCK"): retry_errnos.add(errno.WSAEWOULDBLOCK) class Stream(object): __slots__ = () def close(self): raise NotImplementedError() @property def closed(self): raise NotImplementedError() def fileno(self): raise NotImplementedError() def poll(self, timeout): """indicate whether the stream has data to read"""
encrypts the transport. the credentials returned alongside with the new socket can be any object. it will be stored in the rpyc connection configruation under the key "credentials", and may be used later by the service logic. if no credentials are applicable, just return None as in the example above. rpyc includes integration with tlslite, a TLS/SSL library: the VdbAuthenticator class authenticates clients based on username-password pairs. """ import os import anydbm from rpyc.utils.lib import safe_import tlsapi = safe_import("tlslite.api") class AuthenticationError(Exception): pass def _load_vdb_with_mode(vdb, mode): """taken from tlslite/BaseDB.py -- patched for file mode""" # {{ db = anydbm.open(vdb.filename, mode) try: if db["--Reserved--type"] != vdb.type: raise ValueError("Not a %s database" % (vdb.type, )) except KeyError: raise ValueError("Not a recognized database")
authenticate the client and return a TLS/SSL-wrapped socket object that encrypts the transport. the credentials returned alongside with the new socket can be any object. it will be stored in the rpyc connection configruation under the key "credentials", and may be used later by the service logic. if no credentials are applicable, just return None as in the example above. rpyc includes integration with tlslite, a TLS/SSL library: the VdbAuthenticator class authenticates clients based on username-password pairs. """ import os import anydbm from rpyc.utils.lib import safe_import tlsapi = safe_import("tlslite.api") class AuthenticationError(Exception): pass def _load_vdb_with_mode(vdb, mode): """taken from tlslite/BaseDB.py -- patched for file mode""" # {{ db = anydbm.open(vdb.filename, mode) try: if db["--Reserved--type"] != vdb.type: raise ValueError("Not a %s database" % (vdb.type,)) except KeyError: raise ValueError("Not a recognized database")