MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / Socks5Server

Class Socks5Server

test/functional/test_framework/socks5.py:127–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

setup_nodesMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected