MCPcopy Create free account
hub / github.com/dedsec1121fk/DedSec / start_tor

Function start_tor

Scripts/Developer Base/Free Internet.py:388–409  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

386
387
388def start_tor() -> Tuple[bool, str]:
389 global TOR_PROCESS
390 ok, msg = install_tor_support()
391 if not ok:
392 return False, msg
393 if tor_running():
394 return True, "Tor is already running."
395 try:
396 logf = open(TOR_STDOUT_PATH, "ab")
397 TOR_PROCESS = subprocess.Popen(
398 [tor_binary(), "--SocksPort", f"127.0.0.1:{TOR_SOCKS_PORT}", "--DataDirectory", str(TOR_DATA_DIR)],
399 stdout=logf, stderr=subprocess.STDOUT, stdin=subprocess.DEVNULL, close_fds=True
400 )
401 for _ in range(40):
402 if tor_running():
403 return True, "Tor started on 127.0.0.1:9050."
404 if TOR_PROCESS and TOR_PROCESS.poll() is not None:
405 break
406 time.sleep(0.5)
407 return False, "Tor did not finish bootstrapping yet. Check tor.log in the browser data folder."
408 except Exception as e:
409 return False, f"Could not start Tor: {e}"
410
411
412def stop_tor() -> Tuple[bool, str]:

Callers 5

tor_fetchFunction · 0.70
browser_settingsFunction · 0.70
browser_update_toolsFunction · 0.70
browser_tor_startFunction · 0.70
browser_openFunction · 0.70

Calls 3

install_tor_supportFunction · 0.70
tor_runningFunction · 0.70
tor_binaryFunction · 0.70

Tested by

no test coverage detected