MCPcopy Create free account
hub / github.com/ElementsProject/elements / Socks5Server

Class Socks5Server

test/functional/test_framework/socks5.py:126–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124 self.conn.close()
125
126class Socks5Server():
127 def __init__(self, conf):
128 self.conf = conf
129 self.s = socket.socket(conf.af)
130 self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
131 self.s.bind(conf.addr)
132 self.s.listen(5)
133 self.running = False
134 self.thread = None
135 self.queue = queue.Queue() # report connections and exceptions to client
136
137 def run(self):
138 while self.running:
139 (sockconn, _) = self.s.accept()
140 if self.running:
141 conn = Socks5Connection(self, sockconn)
142 thread = threading.Thread(None, conn.handle)
143 thread.daemon = True
144 thread.start()
145
146 def start(self):
147 assert not self.running
148 self.running = True
149 self.thread = threading.Thread(None, self.run)
150 self.thread.daemon = True
151 self.thread.start()
152
153 def stop(self):
154 self.running = False
155 # connect to self to end run loop
156 s = socket.socket(self.conf.af)
157 s.connect(self.conf.addr)
158 s.close()
159 self.thread.join()
160

Callers 1

setup_nodesMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected