Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
changed if rpyc evolves'''
# authenticate
if self.authenticator:
h, p = sock.getpeername()
try:
sock, credentials = self.authenticator(sock)
except AuthenticationError:
self.logger.info("%s:%s failed to authenticate, rejecting connection", h, p)
return None
else:
credentials = None
# build a connection
h, p = sock.getpeername()
config = dict(self.protocol_config, credentials=credentials,
endpoints = (sock.getsockname(), sock.getpeername())) #connid="%s:%d"%(h, p))
return Connection(self.service, Channel(SocketStream(sock)), config=config)
Note that this code is cut and paste from the rpyc internals and may have to be
changed if rpyc evolves'''
# authenticate
if self.authenticator:
h, p = sock.getpeername()
try:
sock, credentials = self.authenticator(sock)
except AuthenticationError:
self.logger.info("%s:%s failed to authenticate, rejecting connection", h, p)
return None
else:
credentials = None
# build a connection
h, p = sock.getpeername()
config = dict(self.protocol_config, credentials=credentials, connid="%s:%d"%(h, p))
return Connection(self.service, Channel(SocketStream(sock)), config=config)
def _serve_client(self, sock, credentials):
addrinfo = sock.getpeername()
if credentials:
self.logger.info("welcome %s (%r)", addrinfo, credentials)
else:
self.logger.info("welcome %s", addrinfo)
try:
config = dict(self.protocol_config, credentials=credentials,
endpoints=(sock.getsockname(), addrinfo), logger=self.logger)
conn = self.service._connect(Channel(SocketStream(sock)), config)
self._handle_connection(conn)
finally:
self.logger.info("goodbye %s", addrinfo)
def _serve_client(self, sock, credentials):
h, p = sock.getpeername()
self.logger.info("welcome %s:%s", h, p)
try:
config = dict(self.protocol_config, credentials = credentials)
conn = Connection(self.service, Channel(SocketStream(sock)),
config = config, _lazy = True)
conn._init_service()
conn.serve_all()
finally:
self.logger.info("goodbye %s:%s", h, p)
def _serve_client(self, sock, credentials):
addrinfo = sock.getpeername()
h = addrinfo[0]
p = addrinfo[1]
if credentials:
self.logger.info("welcome [%s]:%s (%r)", h, p, credentials)
else:
self.logger.info("welcome [%s]:%s", h, p)
try:
config = dict(self.protocol_config, credentials = credentials,
endpoints = (sock.getsockname(), addrinfo), logger = self.logger)
conn = Connection(self.service, Channel(SocketStream(sock)),
config = config, _lazy = True)
conn._init_service()
conn.serve_all()
finally:
self.logger.info("goodbye [%s]:%s", h, p)
Note that this code is cut and paste from the rpyc internals and may have to be
changed if rpyc evolves'''
# authenticate
if self.authenticator:
h, p = sock.getpeername()
try:
sock, credentials = self.authenticator(sock)
except AuthenticationError:
self.logger.info("%s:%s failed to authenticate, rejecting connection", h, p)
return None
else:
credentials = None
# build a connection
h, p = sock.getpeername()
config = dict(self.protocol_config, credentials=credentials, connid="%s:%d"%(h, p))
return Connection(self.service, Channel(SocketStream(sock)), config=config)
def connectionMade(self):
self.stream = TwistedSocketStream(self.transport)
self.conn = rpyc.Connection(self.factory.service, Channel(self.stream),
config = self.factory.config, _lazy = True)
self.conn._init_service()
if self.factory.logging:
log.msg("%s: connected %s" % (self, self.conn))
if self.factory.on_connected is not None:
reactor.callLater(0, self.factory.on_connected, self.conn)
def connectionLost(self, reason=None):
from rpyc.lib.compat import select, select_error, get_exc_errno
from network.lib.buffer import Buffer
import threading
class addGetPeer(object):
""" add some functions needed by some obfsproxy transports """
def __init__(self, peer):
self.peer=peer
def getPeer(self):
return self.peer
class PupyChannel(Channel):
def __init__(self, *args, **kwargs):
super(PupyChannel, self).__init__(*args, **kwargs)
self.compress = True
self.COMPRESSION_LEVEL = 5
self.COMPRESSION_THRESHOLD = self.stream.MAX_IO_CHUNK
self._send_channel_lock = threading.Lock()
self._recv_channel_lock = threading.Lock()
def consume(self):
return self.stream.consume()
def wake(self):
return self.stream.wake()
def recv(self):
# print "RECV", threading.currentThread()