MCPcopy
hub / github.com/sshuttle/sshuttle / wait_for_firewall_ready

Method wait_for_firewall_ready

sshuttle/methods/windivert.py:350–372  ·  view source on GitHub ↗
(self, sshuttle_pid)

Source from the content-addressed store, hash-verified

348 }
349
350 def wait_for_firewall_ready(self, sshuttle_pid):
351 debug2(f"network_config={self.network_config}")
352 self.conntrack = ConnTrack(f"sshuttle-windivert-{sshuttle_pid}", WINDIVERT_MAX_CONNECTIONS)
353 if not self.conntrack.is_owner:
354 raise Fatal("ConnTrack should be owner in wait_for_firewall_ready()")
355 thread_target_funcs = (self._egress_divert, self._ingress_divert, self._connection_gc)
356 ready_events = []
357 for fn in thread_target_funcs:
358 ev = threading.Event()
359 ready_events.append(ev)
360
361 def _target():
362 try:
363 fn(ev.set)
364 except Exception:
365 debug2(f"thread {fn.__name__} exiting due to: " + traceback.format_exc())
366 sys.stdin.close() # this will exist main thread
367 sys.stdout.close()
368
369 threading.Thread(name=fn.__name__, target=_target, daemon=True).start()
370 for ev in ready_events:
371 if not ev.wait(5): # at most 5 sec
372 raise Fatal("timeout in wait_for_firewall_ready()")
373
374 def restore_firewall(self, port, family, udp, user, group):
375 pass

Callers 2

test_mainFunction · 0.45
mainFunction · 0.45

Calls 4

debug2Function · 0.90
FatalClass · 0.90
ConnTrackClass · 0.85
startMethod · 0.80

Tested by 1

test_mainFunction · 0.36