MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / __init__

Method __init__

test/functional/test_framework/socks5.py:268–290  ·  view source on GitHub ↗
(self, conf)

Source from the content-addressed store, hash-verified

266
267class Socks5Server():
268 def __init__(self, conf):
269 self.conf = conf
270 self.s = socket.socket(conf.af)
271 self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
272 # When using dynamic port allocation (port=0), ensure we don't get a
273 # port that conflicts with the test framework's static port range.
274 if conf.addr[1] == 0:
275 set_ephemeral_port_range(self.s)
276 self.s.bind(conf.addr)
277 # When port=0, the OS assigns an available port. Update conf.addr
278 # to reflect the actual bound address so callers can use it.
279 self.conf.addr = self.s.getsockname()
280 self.s.listen(5)
281 # Set to False when stop is initiated
282 self._running = False
283 self._running_lock = threading.Lock()
284 self.thread = None
285 self.queue = queue.Queue() # report connections and exceptions to client
286 self.keep_alive = conf.keep_alive
287 # Store the background handlers, needed for clean shutdown
288 # Append-only array, completed handlers are set to None
289 self._handlers = []
290 self._handlers_lock = threading.Lock()
291
292 def is_running(self) -> bool:
293 with self._running_lock:

Callers

nothing calls this directly

Calls 4

set_ephemeral_port_rangeFunction · 0.85
bindMethod · 0.80
LockMethod · 0.80
listenMethod · 0.45

Tested by

no test coverage detected