Skip to content

Commit 1247123

Browse files
committed
Remove Playit.gg completely — only Pinggy as tunnel provider
1 parent d3cdf11 commit 1247123

2 files changed

Lines changed: 5 additions & 391 deletions

File tree

backend/api_server.py

Lines changed: 0 additions & 198 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,204 +1940,6 @@ def _ensure_ssh_key():
19401940
logging.error(f"Failed to generate SSH key: {e}")
19411941
return None
19421942

1943-
def run_playit_tunnel():
1944-
import subprocess
1945-
import re
1946-
import urllib.request
1947-
1948-
import sys
1949-
import stat
1950-
1951-
try:
1952-
is_windows = sys.platform == "win32"
1953-
exe_name = "playit.exe" if is_windows else "playit"
1954-
playit_exe = os.path.join(state.app_data_dir, exe_name)
1955-
1956-
if not os.path.exists(playit_exe):
1957-
logging.info("Downloading playit agent...")
1958-
state.broadcast_log_sync(
1959-
"🌐 Downloading Playit.gg agent...", "info"
1960-
)
1961-
download_url = (
1962-
"https://github.com/playit-cloud/playit-agent/releases/latest/download/playit-windows-x86_64-signed.exe"
1963-
if is_windows
1964-
else "https://github.com/playit-cloud/playit-agent/releases/latest/download/playit-linux-amd64"
1965-
)
1966-
urllib.request.urlretrieve(download_url, playit_exe)
1967-
if not is_windows:
1968-
os.chmod(playit_exe, os.stat(playit_exe).st_mode | stat.S_IEXEC)
1969-
state.broadcast_log_sync("✅ Playit.gg downloaded.", "success")
1970-
1971-
logging.info("Starting Playit.gg tunnel...")
1972-
state.broadcast_log_sync("🌐 Starting Playit.gg tunnel...", "info")
1973-
1974-
state.tunnel_process = subprocess.Popen(
1975-
[playit_exe, "--stdout"],
1976-
stdout=subprocess.PIPE,
1977-
stderr=subprocess.STDOUT,
1978-
stdin=subprocess.PIPE,
1979-
text=True,
1980-
bufsize=1,
1981-
creationflags=subprocess.CREATE_NO_WINDOW
1982-
if sys.platform == "win32"
1983-
else 0,
1984-
)
1985-
1986-
connected_emitted = False
1987-
claim_required = False
1988-
fallback_emitted = False
1989-
1990-
for line in iter(state.tunnel_process.stdout.readline, ""):
1991-
if not line:
1992-
break
1993-
line = line.strip()
1994-
if not line:
1995-
continue
1996-
1997-
# Print raw output to help debug and let user see the connection string
1998-
if (
1999-
"playit" in line.lower()
2000-
or "tunnel" in line.lower()
2001-
or "port" in line.lower()
2002-
or ".gg" in line.lower()
2003-
or "connected" in line.lower()
2004-
):
2005-
state.broadcast_log_sync(f"[Playit Agent]: {line}", "info")
2006-
2007-
# Intercept Claim Link
2008-
claim_match = re.search(
2009-
r"Visit link to setup (https://playit\.gg/claim/[a-zA-Z0-9]+)",
2010-
line,
2011-
)
2012-
if claim_match:
2013-
claim_link = claim_match.group(1)
2014-
claim_required = True
2015-
state.broadcast_log_sync(
2016-
{"type": "playit_claim", "link": claim_link}
2017-
)
2018-
state.broadcast_log_sync(
2019-
"⚠️ Playit authorization required. Check the UI pop-up.",
2020-
"warning",
2021-
)
2022-
2023-
# Also intercept manual setup links if present
2024-
setup_match = re.search(
2025-
r"(https://playit\.gg/manage/tunnels)",
2026-
line,
2027-
)
2028-
if setup_match and not claim_required:
2029-
state.broadcast_log_sync(
2030-
{"type": "playit_claim", "link": setup_match.group(1)}
2031-
)
2032-
state.broadcast_log_sync(
2033-
"⚠️ Tunnel setup required in Playit dashboard. Check the UI pop-up.",
2034-
"warning",
2035-
)
2036-
2037-
# Intercept assigned domain if printed by the agent
2038-
ip_match = re.search(
2039-
r"([a-zA-Z0-9-]+\.(?:[a-zA-Z0-9-]+\.)*(?:playit\.gg|playit\.site|joinmc\.link)(?::\d+)?)",
2040-
line,
2041-
)
2042-
2043-
playit_cache_file = os.path.join(
2044-
state.app_data_dir, "playit_cache.json"
2045-
)
2046-
2047-
if ip_match:
2048-
domain = ip_match.group(1)
2049-
state.tunnel_address = domain
2050-
logging.info(f"Playit tunnel established: {domain}")
2051-
2052-
# Cache the domain so we have it for next time
2053-
try:
2054-
import json
2055-
2056-
with open(playit_cache_file, "w") as f:
2057-
json.dump({"domain": domain}, f)
2058-
except Exception as e:
2059-
logging.error(f"Failed to cache playit domain: {e}")
2060-
2061-
state.broadcast_log_sync(
2062-
f"✅ Public server active via Playit! Address: {domain}",
2063-
"success",
2064-
)
2065-
state.broadcast_log_sync(
2066-
{
2067-
"type": "tunnel_connected",
2068-
"address": state.tunnel_address,
2069-
}
2070-
)
2071-
connected_emitted = True
2072-
claim_required = False
2073-
continue
2074-
2075-
# Fallback Detect Connection True if we don't catch the IP immediately
2076-
if (
2077-
(
2078-
"agent registered" in line
2079-
or "secret key valid" in line
2080-
or "tunnel running" in line
2081-
)
2082-
and not connected_emitted
2083-
and not claim_required
2084-
and not fallback_emitted
2085-
):
2086-
fallback_emitted = True
2087-
cached_domain = "Check Playit.gg Dashboard"
2088-
2089-
# Try to read the domain from cache
2090-
try:
2091-
import json
2092-
2093-
if os.path.exists(playit_cache_file):
2094-
with open(playit_cache_file, "r") as f:
2095-
data = json.load(f)
2096-
if "domain" in data:
2097-
cached_domain = data["domain"]
2098-
except Exception as e:
2099-
logging.error(f"Failed to read playit domain cache: {e}")
2100-
2101-
state.tunnel_address = cached_domain
2102-
logging.info("Playit tunnel established using fallback.")
2103-
2104-
if cached_domain == "Check Playit.gg Dashboard":
2105-
# We don't have the IP in cache. To help the user, let's also show the dashboard pop-up
2106-
# so they can see their IP and manage their tunnels directly from the app.
2107-
state.broadcast_log_sync(
2108-
{
2109-
"type": "playit_claim",
2110-
"link": "https://playit.gg/manage/tunnels",
2111-
}
2112-
)
2113-
state.broadcast_log_sync(
2114-
"✅ Tunnel connected! Check the Playit.gg panel to configure it.",
2115-
"success",
2116-
)
2117-
else:
2118-
state.broadcast_log_sync(
2119-
f"✅ Public server active! Address: {cached_domain}",
2120-
"success",
2121-
)
2122-
2123-
state.broadcast_log_sync(
2124-
{
2125-
"type": "tunnel_connected",
2126-
"address": state.tunnel_address,
2127-
}
2128-
)
2129-
# Do not set connected_emitted = True so we can still catch the domain if it prints later
2130-
continue
2131-
2132-
except Exception as e:
2133-
logging.exception(f"Tunnel error: {e}")
2134-
state.broadcast_log_sync(f"❌ Playit tunnel error: {e}", "error")
2135-
state.tunnel_address = None
2136-
2137-
if provider.lower() == "playit":
2138-
threading.Thread(target=run_playit_tunnel, daemon=True).start()
2139-
return {"message": "Playit tunnel starting...", "status": "connecting"}
2140-
21411943
def run_tunnel():
21421944
import subprocess
21431945
import re

0 commit comments

Comments
 (0)