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

Function discussion_send

Scripts/ButSystem.py:17774–17940  ·  view source on GitHub ↗

Send a discussion message (text, file, GIF, and/or voice).

()

Source from the content-addressed store, hash-verified

17772 return
17773 # If we get here: tunnel may still be starting; keep proc running but URL unknown
17774 log.warning("cloudflared tunnel started but URL was not detected in time")
17775 except Exception as e:
17776 log.exception("cloudflared start failed: %s", e)
17777
17778
17779def start_tor_hidden_service(port: int):
17780 """Start Tor with an ephemeral hidden service and set TOR_ONION.
17781
17782 This fixes common issues with a static HiddenServiceDir (stale keys/permissions),
17783 by using a fresh directory each run (logic adapted from Connections.py).
17784 """
17785 global TOR_ONION, TOR_PROC, TOR_HS_DIR
17786 try:
17787 if not have_cmd("tor") and _is_termux():
17788 termux_pkg_install("tor")
17789 if not have_cmd("tor"):
17790 log.warning("tor not available")
17791 return
17792
17793 # Ensure base folder exists
17794 os.makedirs(TOR_DIR, exist_ok=True)
17795
17796 # Fresh hidden-service + data dir each run
17797 run_id = secrets.token_hex(4)
17798 data_dir = os.path.join(TOR_DIR, f"data_{run_id}")
17799 hs_dir = os.path.join(TOR_DIR, f"hs_{run_id}")
17800 os.makedirs(data_dir, exist_ok=True)
17801 os.makedirs(hs_dir, exist_ok=True)
17802 TOR_HS_DIR = hs_dir
17803
17804 # Tor prefers 0700 perms
17805 try:
17806 os.chmod(data_dir, 0o700)
17807 os.chmod(hs_dir, 0o700)
17808 except Exception:
17809 pass
17810
17811 torrc = os.path.join(TOR_DIR, f"torrc_{run_id}")
17812 torrc_text = "\n".join([
17813 f"DataDirectory {data_dir}",
17814 "SocksPort 0",
17815 "ControlPort 0",
17816 "Log notice stdout",
17817 f"HiddenServiceDir {hs_dir}",
17818 f"HiddenServicePort 80 127.0.0.1:{port}",
17819 ]) + "\n"
17820 with open(torrc, "w", encoding="utf-8") as f:
17821 f.write(torrc_text)
17822
17823 proc = subprocess.Popen(
17824 ["tor", "-f", torrc],
17825 stdout=subprocess.PIPE,
17826 stderr=subprocess.STDOUT,
17827 text=True,
17828 bufsize=1
17829 )
17830 TOR_PROC = proc
17831

Callers

nothing calls this directly

Calls 15

_feature_tables_initFunction · 0.70
current_userFunction · 0.70
_filestorage_sizeFunction · 0.70
_Function · 0.70
db_connectFunction · 0.70
aesgcm_encrypt_textFunction · 0.70
now_zFunction · 0.70

Tested by

no test coverage detected