Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def stop(self, reason="proxy terminating", skip_proto=None):
debug("stop(%s, %s)", reason, skip_proto)
self.main_queue.put(None)
#empty the main queue:
q = Queue()
q.put(None)
self.main_queue = q
for proto in (self.client_protocol, self.server_protocol):
if proto and proto!=skip_proto:
proto.flush_then_close(["disconnect", reason])
def __init__(self, scheduler, conn, process_packet_cb, get_packet_cb=None):
"""
You must call this constructor and source_has_more() from the main thread.
"""
assert scheduler is not None
assert conn is not None
self.scheduler = scheduler
self._conn = conn
if FAKE_JITTER>0:
fj = FakeJitter(self.scheduler, process_packet_cb)
self._process_packet_cb = fj.process_packet_cb
else:
self._process_packet_cb = process_packet_cb
self._write_queue = Queue(1)
self._read_queue = Queue(20)
# Invariant: if .source is None, then _source_has_more == False
self._get_packet_cb = get_packet_cb
#counters:
self.input_packetcount = 0
self.input_raw_packetcount = 0
self.output_packetcount = 0
self.output_raw_packetcount = 0
#initial value which may get increased by client/server after handshake:
self.max_packet_size = 32*1024
self.abs_max_packet_size = 32*1024*1024
self.large_packets = ["hello"]
self.aliases = {}
self.chunked_compression = True
self._log_stats = True
self._closed = False
def stop(self, reason="proxy terminating", skip_proto=None):
debug("stop(%s, %s)", reason, skip_proto)
self.main_queue.put(None)
#empty the main queue:
q = Queue()
q.put(None)
self.main_queue = q
#empty the encode queue:
q = Queue()
q.put(None)
self.encode_queue = q
for proto in (self.client_protocol, self.server_protocol):
if proto and proto!=skip_proto:
proto.flush_then_close(["disconnect", reason])
def stop(self, reason="proxy terminating", skip_proto=None):
debug("stop(%s, %s)", reason, skip_proto)
self.main_queue.put(None)
#empty the main queue:
q = Queue()
q.put(None)
self.main_queue = q
#empty the encode queue:
q = Queue()
q.put(None)
self.encode_queue = q
for proto in (self.client_protocol, self.server_protocol):
if proto and proto!=skip_proto:
proto.flush_then_close(["disconnect", reason])
def stop(self, reason="proxy terminating", skip_proto=None):
log("stop(%s, %s)", reason, skip_proto)
self.exit = True
if self.control_socket_path:
try:
os.unlink(self.control_socket_path)
except:
pass
self.main_queue.put(None)
#empty the main queue:
q = Queue()
q.put(None)
self.main_queue = q
#empty the encode queue:
q = Queue()
q.put(None)
self.encode_queue = q
for proto in (self.client_protocol, self.server_protocol):
if proto and proto!=skip_proto:
proto.flush_then_close(["disconnect", reason])
def __init__(self, conn, process_packet_cb, get_packet_cb=None):
"""
You must call this constructor and source_has_more() from the main thread.
"""
assert conn is not None
self._conn = conn
if FAKE_JITTER>0:
fj = FakeJitter(process_packet_cb)
self._process_packet_cb = fj.process_packet_cb
else:
self._process_packet_cb = process_packet_cb
self._write_queue = Queue(1)
self._read_queue = Queue(20)
# Invariant: if .source is None, then _source_has_more == False
self._get_packet_cb = get_packet_cb
#counters:
self.input_packetcount = 0
self.input_raw_packetcount = 0
self.output_packetcount = 0
self.output_raw_packetcount = 0
#initial value which may get increased by client/server after handshake:
self.max_packet_size = 32*1024
self.large_packets = ["hello"]
self.aliases = {}
self.chunked_compression = True
self._closed = False
self._encoder = self.bencode
self._decompressor = decompressobj()
def stop(self, reason="proxy terminating", skip_proto=None):
log("stop(%s, %s)", reason, skip_proto)
self.exit = True
if self.control_socket_path:
try:
os.unlink(self.control_socket_path)
except:
pass
self.main_queue.put(None)
#empty the main queue:
q = Queue()
q.put(None)
self.main_queue = q
#empty the encode queue:
q = Queue()
q.put(None)
self.encode_queue = q
for proto in (self.client_protocol, self.server_protocol):
if proto and proto!=skip_proto:
proto.flush_then_close(["disconnect", reason])