Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/socks5.py
Show First 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | def run(self): | ||||
(sockconn, peer) = self.s.accept() | (sockconn, peer) = self.s.accept() | ||||
if self.running: | if self.running: | ||||
conn = Socks5Connection(self, sockconn, peer) | conn = Socks5Connection(self, sockconn, peer) | ||||
thread = threading.Thread(None, conn.handle) | thread = threading.Thread(None, conn.handle) | ||||
thread.daemon = True | thread.daemon = True | ||||
thread.start() | thread.start() | ||||
def start(self): | def start(self): | ||||
assert(not self.running) | assert not self.running | ||||
self.running = True | self.running = True | ||||
self.thread = threading.Thread(None, self.run) | self.thread = threading.Thread(None, self.run) | ||||
self.thread.daemon = True | self.thread.daemon = True | ||||
self.thread.start() | self.thread.start() | ||||
def stop(self): | def stop(self): | ||||
self.running = False | self.running = False | ||||
# connect to self to end run loop | # connect to self to end run loop | ||||
s = socket.socket(self.conf.af) | s = socket.socket(self.conf.af) | ||||
s.connect(self.conf.addr) | s.connect(self.conf.addr) | ||||
s.close() | s.close() | ||||
self.thread.join() | self.thread.join() |