Analyze the two files above. They constitute a net...

Tạo vào: 13 tháng 10, 2026

Trả lời bằng GPT-5.6 Thinking bởi Chat01

Câu hỏi

Analyze the two files above. They constitute a network-bridge playtesting tool for Roblox Studio. I need you to thoroughly map out all of its logic.

By “logic,” I do not simply mean the code itself. I mean the entire operational logic, behavioral logic, control logic, the essential logic involving the Roblox Studio APIs it uses, and other, more important aspects.

Continue until you have fully documented and analyzed the program in an ".md" file with enough detail to make it possible to reimplement the program in different programming languages.

You must also identify problems in the existing design, including user-interaction considerations, edge cases and limitations, complete state handling, safeguards, conflict prevention, stability, crash prevention, packet filtering or other idiomatic techniques for avoiding instability, as well as clean design, user experience, and UI controls.

However, keep in mind that some areas do not require as much thought or analysis.

Most importantly, first establish the design philosophy and the tool’s actual purpose. Only after understanding what it is designed to do should you determine the appropriate direction for the rest of the analysis.

py
MATT'S LOCALHOST — COMBINED SOURCE TEXT FOR AI REVIEW ============================================================================== PURPOSE This file combines the separately uploaded source.py and the readable/text-based files from mattslocalhosting-newui0.1.zip. Each file is preceded by an explicit BEGIN FILE header with its original path. Treat each section as a separate original file; do not concatenate them into one executable program. AI REVIEW NOTES / CONTEXT - Intended purpose: a Windows desktop utility for launching Roblox Studio Team Test sessions as a host or client, with an optional UDP tunnel endpoint. The program starts RobloxStudioBeta.exe using command-line switches and relays UDP packets through a local 127.0.0.1 proxy. - The standalone source.py is a single-file Tkinter application that primarily uses Python's standard library. - The ZIP is a different, modular UI implementation: its app imports PySide6/Qt, and requirements.txt specifies PySide6 and PyInstaller. It organizes code into app/core, app/pages, app/ui, app/widgets, and app/styles. - The same-named source.py file is not present inside the ZIP. Several ideas are shared (especially UDP warm-up and proxy forwarding), but the ZIP is not simply the standalone file split mechanically; the UI framework and session/process handling changed. - Documentation inconsistency: ZIP README.md still says the app is built with Tkinter and has no pip dependencies, while the actual ZIP's Python files use PySide6 and requirements.txt declares PySide6>=6.11,<7 and pyinstaller>=6.6. Treat README installation/dependency statements as stale for this ZIP unless independently verified. - Static review observations, not runtime-tested findings: (1) app/core/studio.py writes a chosen place file to %LOCALAPPDATA%\Roblox\server.rbxl when use_runtime_place=True; this overwrites that path without a backup or cleanup in the shown code. (2) stop_all_roblox_processes() invokes Windows taskkill by process image name for RobloxStudioBeta.exe and RobloxPlayerBeta.exe, so the app's global stop/close path can terminate unrelated Studio/Player instances as well as this app's processes. (3) start_server_and_clients_hotkey() contains a PowerShell script launched with -ExecutionPolicy Bypass, but a static search found no call sites for that function in the included .py source. - A scan of the readable source found no obvious HTTP request, telemetry, or credential-upload implementation. The code does perform DNS resolution, sends UDP warm-up packets to the configured tunnel, forwards UDP traffic, launches subprocesses/PowerShell, and writes local settings. Static source inspection cannot prove that an independently distributed .exe is byte-for-byte or behaviorally identical to these files. - All non-cache Python source files in the ZIP passed Python syntax compilation checks in the inspection environment. This does not verify Windows behavior, PySide6 runtime imports, compatibility with Roblox Studio, or network connectivity. - Public release context checked: https://github.com/somematt/mattslocalhosting/releases . The beta 0.5 release note refers to warm-up and the last source.py commit; the newui beta 0.1 note describes a new UI, selectable place files, and additional settings. GitHub's source-code ZIP/tar.gz links on Releases are automatically generated snapshots of the repository at the corresponding tag, not necessarily a separately curated source package: https://docs.github.com/en/repositories/working-with-files/using-files/downloading-source-code-archives and https://docs.github.com/en/repositories/releasing-projects-on-github/about-releases . SOURCE A: standalone uploaded source.py (outside the ZIP) Original filename: source.py File size: 34881 bytes SHA256: 3a4bfbf26a8a97e6aa1f4c95fb479e60f7bf0b95ba766d4df86f88bacab9d233 ----- BEGIN FILE: source.py [standalone; not found as a same-named file inside the ZIP] ----- import tkinter as tk from tkinter import scrolledtext, messagebox import socket import threading import time import subprocess import uuid import os import atexit import json import math # ==================== CONSTANTS ==================== PROXY_PORT = 55555 DATA_FILE = "mattslocalhost_data.json" # Color palette — deep navy + electric cyan + neon accents BG_COLOR = "#0d1117" BG2_COLOR = "#161b22" CARD_COLOR = "#1c2333" BORDER_COLOR = "#30363d" GLOW_COLOR = "#00d4ff" BTN_CREATE = "#00c853" BTN_JOIN = "#00b4d8" BTN_DANGER = "#f44336" BTN_WARN = "#ff9800" BTN_BACK = "#3d4451" TEXT_COLOR = "#e6edf3" MUTED_COLOR = "#8b949e" DIM_COLOR = "#484f58" ACCENT_GREEN = "#39d353" ACCENT_CYAN = "#00d4ff" ACCENT_RED = "#f44336" FONT_TITLE = ("Consolas", 22, "bold") FONT_SUB = ("Consolas", 9) FONT_LABEL = ("Consolas", 10, "bold") FONT_LOG = ("Consolas", 9) FONT_BTN = ("Consolas", 10, "bold") FONT_SMALL = ("Consolas", 8) # ==================== PERSISTENCE ==================== def load_data() -> dict: defaults = { "user_id": "123456789", "host_tunnel": "", "join_tunnel": "", "server_port": "55555", } try: if os.path.exists(DATA_FILE): with open(DATA_FILE, "r", encoding="utf-8") as f: stored = json.load(f) return {**defaults, **stored} except Exception: pass return defaults def save_data(data: dict): try: with open(DATA_FILE, "w", encoding="utf-8") as f: json.dump(data, f, indent=2) except Exception: pass # ==================== GLOBAL PROXY STATE ==================== _proxy_running = threading.Event() _proxy_stopped = threading.Event() _udp_sockets = [] _proxy_lock = threading.Lock() _proxy_thread = None _active_port = None # ==================== HELPERS ==================== def get_studio_path() -> str: try: cmd = ( 'powershell -Command "' 'Get-ChildItem -Path $env:LOCALAPPDATA\\Roblox\\Versions ' '-Filter RobloxStudioBeta.exe -Recurse | ' 'Select-Object -First 1 -ExpandProperty FullName"' ) flags = 0 if hasattr(subprocess, "CREATE_NO_WINDOW"): flags = subprocess.CREATE_NO_WINDOW result = subprocess.check_output( cmd, shell=True, creationflags=flags ).decode(errors="ignore").strip() return result except Exception: return "" def generate_guid() -> str: return str(uuid.uuid4()).upper() def ts() -> str: return time.strftime("%H:%M:%S") def find_free_port(start_port: int, max_attempts: int = 100) -> int: for port in range(start_port, start_port + max_attempts): try: test_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) test_sock.bind(("127.0.0.1", port)) test_sock.close() return port except OSError: continue return -1 # ==================== UDP PROXY WARM-UP ==================== def warmup_udp_tunnel(dst_host: str, dst_port: int, log_fn, packets: int = 10, delay: float = 0.05): """ Send a handful of throwaway UDP packets to the tunnel endpoint so that any stateful NAT / proxy on the remote side learns the return path before Roblox Studio sends its first real packet. UDP has no handshake, so the first real packet can be silently dropped if the remote proxy hasn't recorded our source address yet. Priming the path with cheap dummy data gives it a valid mapping to work with. """ log_fn(f"Warming up tunnel {dst_host}:{dst_port} ({packets} packets)...") try: dst_ip = socket.gethostbyname(dst_host) sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.settimeout(0.5) # 64 bytes of zeros — small enough to be cheap, big enough to matter payload = b"\x00" * 64 for i in range(packets): try: sock.sendto(payload, (dst_ip, dst_port)) except OSError: pass time.sleep(delay) sock.close() log_fn("Tunnel warm-up done.") except Exception as e: log_fn(f"Warm-up warning (non-fatal): {e}") # ==================== UDP PROXY ==================== def start_udp_proxy(dst_host: str, dst_port: int, log_fn) -> tuple: global _proxy_thread, _active_port if _proxy_running.is_set(): stop_udp_proxy() _proxy_running.set() _proxy_stopped.clear() ready_event = threading.Event() error_box = [None] port_box = [None] def worker(): client_sessions: dict = {} local_sock = None bound_port = None try: dst_ip = socket.gethostbyname(dst_host) log_fn(f"Resolved {dst_host} → {dst_ip}") bound_port = find_free_port(PROXY_PORT) if bound_port == -1: raise OSError(f"No free ports starting from {PROXY_PORT}") port_box[0] = bound_port if bound_port != PROXY_PORT: log_fn(f"Port {PROXY_PORT} busy, using {bound_port}") local_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) local_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) local_sock.bind(("127.0.0.1", bound_port)) local_sock.settimeout(0.3) with _proxy_lock: _udp_sockets.append(local_sock) log_fn(f"UDP Proxy bound on 127.0.0.1:{bound_port}") ready_event.set() while _proxy_running.is_set(): try: data, addr = local_sock.recvfrom(65535) except socket.timeout: continue except OSError: break if addr not in client_sessions: log_fn(f"New session: {addr[0]}:{addr[1]}") s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.settimeout(0.3) client_sessions[addr] = s def _listen(sock, client_addr, _ls=local_sock): while _proxy_running.is_set() and client_addr in client_sessions: try: resp, _ = sock.recvfrom(65535) _ls.sendto(resp, client_addr) except socket.timeout: continue except OSError: break try: sock.close() except Exception: pass client_sessions.pop(client_addr, None) threading.Thread(target=_listen, args=(s, addr), daemon=True).start() try: client_sessions[addr].sendto(data, (dst_ip, dst_port)) except OSError as e: log_fn(f"Send error: {e}") except OSError as e: error_box[0] = str(e) ready_event.set() except Exception as e: error_box[0] = str(e) ready_event.set() finally: for s in list(client_sessions.values()): try: s.close() except Exception: pass client_sessions.clear() if local_sock: with _proxy_lock: try: _udp_sockets.remove(local_sock) except ValueError: pass try: local_sock.close() except Exception: pass log_fn("UDP Proxy stopped.") _proxy_stopped.set() _proxy_thread = threading.Thread(target=worker, daemon=True) _proxy_thread.start() ready_event.wait(timeout=5) if error_box[0]: log_fn(f"Proxy error: {error_box[0]}") _proxy_running.clear() return (False, -1) _active_port = port_box[0] return (True, port_box[0]) def stop_udp_proxy(wait: bool = True): global _proxy_thread, _active_port if not _proxy_running.is_set(): return _proxy_running.clear() with _proxy_lock: for s in _udp_sockets: try: s.close() except Exception: pass _udp_sockets.clear() if wait and _proxy_thread and _proxy_thread.is_alive(): _proxy_stopped.wait(timeout=3) _proxy_thread = None _active_port = None atexit.register(lambda: stop_udp_proxy(wait=False)) # ==================== STUDIO LAUNCHER ==================== def launch_server(studio, port, user_id, parent_guid, play_guid): subprocess.Popen([ studio, "-task", "StartServer", "-placeId", "0", "-universeId", "0", "-placeVersion", "0", "-port", port, "-creatorId", user_id, "-creatorType", "0", "-userid", user_id, "-numTestServerPlayersUponStartup", "0", "-parentSessionGuid", parent_guid, "-playTestSessionGuid", play_guid, "-instanceId", "StudioServer", ]) def launch_client(studio, server_ip, server_port, parent_guid, play_guid, instance_id): subprocess.Popen([ studio, "-task", "StartClient", "-placeId", "0", "-universeId", "0", "-placeVersion", "0", "-server", server_ip, "-port", server_port, "-parentSessionGuid", parent_guid, "-playTestSessionGuid", play_guid, "-instanceId", instance_id, ]) # ==================== COLOUR HELPERS ==================== def _hex_blend(c1: str, c2: str, t: float) -> str: r1,g1,b1 = int(c1[1:3],16), int(c1[3:5],16), int(c1[5:7],16) r2,g2,b2 = int(c2[1:3],16), int(c2[3:5],16), int(c2[5:7],16) return "#{:02x}{:02x}{:02x}".format( int(r1+(r2-r1)*t), int(g1+(g2-g1)*t), int(b1+(b2-b1)*t)) def _lighten(color: str, amount: float) -> str: return _hex_blend(color, "#ffffff", amount) def _darken(color: str, amount: float) -> str: return _hex_blend(color, "#000000", amount) # ==================== ANIMATED BUTTON (factory) ==================== def AnimButton(parent, text, color, command, width=160, height=40, font=FONT_BTN, **kw): normal_bg = color hover_bg = _lighten(color, 0.18) press_bg = _darken(color, 0.15) char_w = max(1, width // 8) btn = tk.Button( parent, text=text, command=command, bg=normal_bg, fg=TEXT_COLOR, activebackground=press_bg, activeforeground=TEXT_COLOR, font=font, relief="flat", bd=0, cursor="hand2", width=char_w, pady=max(4, height // 8), highlightthickness=1, highlightbackground=_lighten(color, 0.15), highlightcolor=_lighten(color, 0.4), **kw ) btn.bind("<Enter>", lambda e: btn.config(bg=hover_bg, highlightbackground=_lighten(color, 0.4))) btn.bind("<Leave>", lambda e: btn.config(bg=normal_bg, highlightbackground=_lighten(color, 0.15))) btn.bind("<ButtonPress-1>", lambda e: btn.config(bg=press_bg)) btn.bind("<ButtonRelease-1>", lambda e: btn.config(bg=hover_bg)) return btn # ==================== ANIMATED ENTRY (factory) ==================== def AnimEntry(parent, placeholder="", width=38, **kw): border = tk.Frame(parent, bg=BORDER_COLOR, padx=1, pady=1, **kw) entry = tk.Entry( border, width=width, font=FONT_SUB, bg="#0d1b2a", fg=TEXT_COLOR, insertbackground=ACCENT_CYAN, relief="flat", bd=6, highlightthickness=0, ) entry.pack(fill="x") entry.insert(0, placeholder) entry.bind("<FocusIn>", lambda e: border.config(bg=ACCENT_CYAN)) entry.bind("<FocusOut>", lambda e: border.config(bg=BORDER_COLOR)) border.get = entry.get return border # ==================== LOG WIDGET ==================== def make_log(parent, height=14): frm = tk.Frame(parent, bg=BORDER_COLOR, padx=1, pady=1) frm.pack(padx=16, fill="both", expand=True) log = scrolledtext.ScrolledText( frm, height=height, font=FONT_LOG, bg="#080d12", fg="#39d353", insertbackground=TEXT_COLOR, relief="flat", bd=0, state="normal", selectbackground=ACCENT_CYAN, ) log.pack(fill="both", expand=True) return log # ==================== SPLASH SCREEN ==================== class SplashScreen(tk.Toplevel): _DOT_FRAMES = ["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"] def __init__(self, parent: tk.Tk): super().__init__(parent) self.overrideredirect(True) self.configure(bg=BG_COLOR) self.attributes("-topmost", True) w, h = 400, 220 sw, sh = self.winfo_screenwidth(), self.winfo_screenheight() self.geometry(f"{w}x{h}+{(sw-w)//2}+{(sh-h)//2}") self._canvas = tk.Canvas(self, width=w, height=h, bg=BG_COLOR, highlightthickness=0) self._canvas.place(x=0, y=0) inner = tk.Frame(self, bg=BG_COLOR) inner.place(x=2, y=2, width=w-4, height=h-4) tk.Label(inner, text="MATT'S LOCALHOST", font=("Consolas", 16, "bold"), bg=BG_COLOR, fg=ACCENT_CYAN).pack(pady=(32, 2)) tk.Label(inner, text="Studio lan tool", font=("Consolas", 9), bg=BG_COLOR, fg=MUTED_COLOR).pack() spin_row = tk.Frame(inner, bg=BG_COLOR) spin_row.pack(pady=(22, 0)) self._spin_lbl = tk.Label(spin_row, text=self._DOT_FRAMES[0], font=("Consolas", 13), bg=BG_COLOR, fg=ACCENT_CYAN, width=2) self._spin_lbl.pack(side="left") self._status_lbl = tk.Label(spin_row, text="Locating Studio...", font=("Consolas", 9), bg=BG_COLOR, fg=MUTED_COLOR) self._status_lbl.pack(side="left", padx=(8, 0)) bar_bg = tk.Frame(inner, bg="#0d1b2a", height=3, width=340) bar_bg.pack(pady=(20, 0)) bar_bg.pack_propagate(False) self._bar = tk.Frame(bar_bg, bg=ACCENT_CYAN, height=3, width=0) self._bar.place(x=0, y=0, height=3) self._frame_idx = 0 self._bar_width = 0 self._bar_target = 0 self._border_t = 0 self._animating = True self._anim_border() self._anim() def _anim_border(self): if not self._animating: return c = self._canvas w, h = 400, 220 c.delete("border") t = self._border_t clr = f"#{int(0+80*(0.5+0.5*math.sin(t))):02x}{int(180+50*(0.5+0.5*math.sin(t+1))):02x}{int(200+55*(0.5+0.5*math.sin(t+2))):02x}" c.create_rectangle(0, 0, w-1, h-1, outline=clr, width=2, tags="border") self._border_t += 0.06 self.after(30, self._anim_border) def _anim(self): if not self._animating: return self._frame_idx = (self._frame_idx + 1) % len(self._DOT_FRAMES) self._spin_lbl.config(text=self._DOT_FRAMES[self._frame_idx]) diff = self._bar_target - self._bar_width step = max(1, int(diff * 0.1)) if diff > 0: self._bar_width = min(self._bar_width + step, self._bar_target) self._bar.place_configure(width=self._bar_width) self.after(80, self._anim) def set_status(self, text, progress=0): self._status_lbl.config(text=text) self._bar_target = progress def close(self): self._animating = False self.destroy() # ==================== TRANSITION ENGINE ==================== class TransitionManager: def __init__(self, root: tk.Tk): self._root = root self._frame = None self._busy = False def swap(self, builder, direction="right"): old_frame = self._frame w = self._root.winfo_width() or 560 new_frame = tk.Frame(self._root, bg=BG_COLOR) new_frame.place(x=w, y=0, relwidth=1, relheight=1) builder(new_frame) self._frame = new_frame if old_frame is None: new_frame.place(x=0, y=0) return steps = 12 offset = w if direction == "right" else -w dx_new = -offset / steps dx_old = offset / steps positions_new = [int(offset + dx_new * i) for i in range(1, steps + 1)] positions_old = [int(dx_old * i) for i in range(1, steps + 1)] def step(i): if i >= steps: new_frame.place(x=0, y=0) if old_frame.winfo_exists(): old_frame.destroy() return new_frame.place(x=positions_new[i]) if old_frame.winfo_exists(): old_frame.place(x=positions_old[i]) self._root.after(14, lambda: step(i + 1)) step(0) # ==================== MAIN APPLICATION ==================== class App(tk.Tk): def __init__(self): super().__init__() self.title("Matt's LocalHost") self.geometry("560x520") self.resizable(False, False) self.configure(bg=BG_COLOR) self.protocol("WM_DELETE_WINDOW", self._on_close) self.studio_path = "" self._data = load_data() self._tm = TransitionManager(self) self._show_splash() def _on_close(self): stop_udp_proxy(wait=True) self.destroy() def _update_title(self): if self.studio_path: self.title(f"Matt's LocalHost — Studio found: {self.studio_path}") else: self.title("Matt's LocalHost — Studio NOT found") # ────────────────────────────────────────────────────────── # SPLASH # ────────────────────────────────────────────────────────── def _show_splash(self): self.withdraw() splash = SplashScreen(self) def lookup(): splash.set_status("Running PowerShell query...", 100) path = get_studio_path() self.after(0, lambda: _done(path)) def _done(path): splash.set_status("Studio found!" if path else "Studio not found.", 340) self.studio_path = path self.after(700, lambda: _finish(path)) def _finish(path): splash.close() self.deiconify() self._update_title() if not path: messagebox.showwarning( "Studio Not Found", "RobloxStudioBeta.exe was not found.\n" "Make sure Studio is installed." ) self._show_welcome() threading.Thread(target=lookup, daemon=True).start() # ────────────────────────────────────────────────────────── # LOG HELPER # ────────────────────────────────────────────────────────── def _write_log(self, widget, msg): def _do(): widget.insert(tk.END, f"[{ts()}] {msg}\n") widget.see(tk.END) self.after(0, _do) # ────────────────────────────────────────────────────────── # HEADER WIDGET # ────────────────────────────────────────────────────────── def _make_header(self, parent, title, subtitle=""): hdr = tk.Frame(parent, bg=BG_COLOR) hdr.pack(fill="x", pady=(20, 0)) bar = tk.Frame(hdr, bg=ACCENT_CYAN, height=2) bar.pack(fill="x", padx=20) tk.Label(hdr, text=title, font=("Consolas", 16, "bold"), bg=BG_COLOR, fg=ACCENT_CYAN).pack(pady=(10, 0)) if subtitle: tk.Label(hdr, text=subtitle, font=("Consolas", 8), bg=BG_COLOR, fg=MUTED_COLOR).pack(pady=(2, 0)) bar2 = tk.Frame(hdr, bg=BORDER_COLOR, height=1) bar2.pack(fill="x", padx=20, pady=(10, 0)) # ────────────────────────────────────────────────────────── # WELCOME SCREEN # ────────────────────────────────────────────────────────── def _show_welcome(self): stop_udp_proxy(wait=False) def build(f): tk.Frame(f, bg=ACCENT_CYAN, height=2).pack(fill="x") title_area = tk.Frame(f, bg=BG_COLOR) title_area.pack(fill="x", pady=(30, 0)) tk.Label(title_area, text="MATT'S LOCALHOST", font=("Consolas", 24, "bold"), bg=BG_COLOR, fg=TEXT_COLOR).pack() tk.Label(title_area, text="▸ Studio LAN / Tunnel Tool", font=("Consolas", 9), bg=BG_COLOR, fg=MUTED_COLOR).pack(pady=(4, 0)) status_color = ACCENT_GREEN if self.studio_path else ACCENT_RED status_text = "● STUDIO READY" if self.studio_path else "● STUDIO NOT FOUND" pill = tk.Frame(f, bg=BG2_COLOR) pill.pack(pady=(16, 0)) tk.Label(pill, text=status_text, font=("Consolas", 8, "bold"), bg=BG2_COLOR, fg=status_color, padx=12, pady=4).pack() tk.Frame(f, bg=BORDER_COLOR, height=1).pack(fill="x", padx=40, pady=24) btn_row = tk.Frame(f, bg=BG_COLOR) btn_row.pack() AnimButton( btn_row, " ▶ CREATE SERVER", BTN_CREATE, self._show_host_menu, width=190, height=46 ).pack(side="left", padx=16) AnimButton( btn_row, " ▶ JOIN SERVER", BTN_JOIN, self._show_join_menu, width=190, height=46 ).pack(side="left", padx=16) tk.Frame(f, bg=BORDER_COLOR, height=1).pack(fill="x", padx=20, side="bottom", pady=(0, 4)) tk.Label(f, text="by @s0m3thing_matters • discord.gg/H3K2xeU96A", font=("Consolas", 12), bg=BG_COLOR, fg=DIM_COLOR).pack(side="bottom") self._tm.swap(build, direction="left") # ────────────────────────────────────────────────────────── # HOST / CREATE MENU # ────────────────────────────────────────────────────────── def _show_host_menu(self): def build(f): self._make_header(f, "CREATE SERVER", "host a local studio session") card = tk.Frame(f, bg=CARD_COLOR) card.pack(padx=30, pady=16, fill="x") tk.Frame(card, bg=ACCENT_CYAN, height=1).pack(fill="x") inner = tk.Frame(card, bg=CARD_COLOR, padx=20, pady=16) inner.pack(fill="x") def row(lbl, placeholder, key): tk.Label(inner, text=lbl, font=FONT_LABEL, bg=CARD_COLOR, fg=MUTED_COLOR, anchor="w").pack(fill="x", pady=(6, 1)) e = AnimEntry(inner, self._data.get(key, placeholder)) e.pack(fill="x") return e ent_uid = row("USER ID", "123456789", "user_id") ent_tunnel = row("TUNNEL ADDRESS (host:port, optional)", "", "host_tunnel") ent_port = row("TEAMTEST PORT", "55555", "server_port") btn_row = tk.Frame(f, bg=BG_COLOR) btn_row.pack(pady=18) def on_create(): uid = ent_uid.get().strip() tunnel = ent_tunnel.get().strip() port = ent_port.get().strip() if not uid or not port: messagebox.showwarning("Missing Fields", "User ID and Port are required.") return if not port.isdigit(): messagebox.showerror("Invalid Port", "Port must be a number.") return if not self.studio_path: messagebox.showerror("Studio Not Found", "Cannot locate RobloxStudioBeta.exe.") return self._data.update({"user_id": uid, "host_tunnel": tunnel, "server_port": port}) save_data(self._data) self._show_host_running(uid, tunnel, port) AnimButton(btn_row, "▶ CREATE", BTN_CREATE, on_create, width=140, height=40).pack(side="left", padx=8) AnimButton(btn_row, "← BACK", BTN_BACK, self._show_welcome, width=100, height=40).pack(side="left", padx=8) self._tm.swap(build, direction="right") # ────────────────────────────────────────────────────────── # HOST RUNNING SCREEN # ────────────────────────────────────────────────────────── def _show_host_running(self, user_id, tunnel_addr, port): p_guid = generate_guid() t_guid = generate_guid() def build(f): self._make_header(f, "SERVER CONSOLE") log_area = make_log(f, height=14) def log(msg): self._write_log(log_area, msg) status_var = tk.StringVar(value="● INITIALIZING...") sl = tk.Label(f, textvariable=status_var, font=("Consolas", 10, "bold"), bg=BG_COLOR, fg=MUTED_COLOR) sl.pack(pady=(6, 0)) btn_row = tk.Frame(f, bg=BG_COLOR) btn_row.pack(pady=10) join_btn = AnimButton( btn_row, "▶ JOIN (local)", BTN_WARN, lambda: self._join_local(port, p_guid, t_guid), width=170, height=38 ) AnimButton(btn_row, "← BACK", BTN_BACK, self._show_welcome, width=110, height=38).pack(side="left", padx=8) def launch(): log(f"Studio : {self.studio_path}") log(f"PGUID : {p_guid}") log(f"TGUID : {t_guid}") log(f"Port : {port}") log(f"UserID : {user_id}") if tunnel_addr: log(f"Tunnel : {tunnel_addr}") log("Launching server process...") try: launch_server(self.studio_path, port, user_id, p_guid, t_guid) log("Server started. Waiting ~5s for init...") time.sleep(5) self.after(0, lambda: [ status_var.set("● SERVER LIVE"), sl.config(fg=ACCENT_GREEN), join_btn.pack(side="left", padx=8) ]) log("Ready! Click JOIN to connect.") except Exception as e: log(f"ERROR: {e}") self.after(0, lambda: [ status_var.set("● LAUNCH FAILED"), sl.config(fg=ACCENT_RED) ]) threading.Thread(target=launch, daemon=True).start() self._tm.swap(build, direction="right") def _join_local(self, port, p_guid, t_guid): try: launch_client(self.studio_path, "127.0.0.1", port, p_guid, t_guid, "StudioPlayer_Host") except Exception as e: messagebox.showerror("Launch Error", str(e)) # ────────────────────────────────────────────────────────── # JOIN MENU # ────────────────────────────────────────────────────────── def _show_join_menu(self): def build(f): self._make_header(f, "JOIN SERVER", "connect via tunnel address") card = tk.Frame(f, bg=CARD_COLOR) card.pack(padx=30, pady=20, fill="x") tk.Frame(card, bg=BTN_JOIN, height=1).pack(fill="x") inner = tk.Frame(card, bg=CARD_COLOR, padx=20, pady=16) inner.pack(fill="x") tk.Label(inner, text="TUNNEL ADDRESS (host:port)", font=FONT_LABEL, bg=CARD_COLOR, fg=MUTED_COLOR, anchor="w").pack(fill="x", pady=(6, 1)) ent_addr = AnimEntry(inner, self._data.get("join_tunnel", "")) ent_addr.pack(fill="x") tk.Label(inner, text="e.g. my.tunnel.net:6767", font=("Consolas", 8), bg=CARD_COLOR, fg=DIM_COLOR).pack(anchor="w", pady=(2, 0)) btn_row = tk.Frame(f, bg=BG_COLOR) btn_row.pack(pady=20) def on_join(): raw = ent_addr.get().strip() if ":" not in raw: messagebox.showerror("Invalid Address", "Format: host:port") return if not self.studio_path: messagebox.showerror("Studio Not Found", "Cannot locate RobloxStudioBeta.exe.") return host, port_str = raw.rsplit(":", 1) if not port_str.isdigit(): messagebox.showerror("Invalid Port", "Port must be a number.") return self._data["join_tunnel"] = raw save_data(self._data) self._show_join_running(host, int(port_str)) AnimButton(btn_row, "⟶ JOIN", BTN_JOIN, on_join, width=140, height=40).pack(side="left", padx=8) AnimButton(btn_row, "← BACK", BTN_BACK, self._show_welcome, width=100, height=40).pack(side="left", padx=8) self._tm.swap(build, direction="right") # ────────────────────────────────────────────────────────── # JOIN RUNNING SCREEN # ────────────────────────────────────────────────────────── def _show_join_running(self, dst_host, dst_port): def build(f): self._make_header(f, "CONNECTION CONSOLE") log_area = make_log(f, height=14) def log(msg): self._write_log(log_area, msg) status_var = tk.StringVar(value="● CONNECTING...") sl = tk.Label(f, textvariable=status_var, font=("Consolas", 10, "bold"), bg=BG_COLOR, fg=MUTED_COLOR) sl.pack(pady=(6, 0)) btn_row = tk.Frame(f, bg=BG_COLOR) btn_row.pack(pady=10) def on_stop(): log("Disconnecting...") stop_udp_proxy(wait=True) log("Proxy stopped.") self.after(200, self._show_welcome) AnimButton(btn_row, "✕ DISCONNECT", BTN_DANGER, on_stop, width=160, height=38).pack() def run(): log(f"Target : {dst_host}:{dst_port}") # ── WARM-UP: prime the tunnel path before starting the proxy ── # UDP has no handshake, so the remote proxy won't know where to # route replies until it sees our first outbound packet. If that # first packet gets dropped (common on cheaper tunnel setups) the # whole session silently fails. Sending a few dummy packets first # gives the remote side a valid return mapping before Roblox's # real traffic arrives. warmup_udp_tunnel(dst_host, dst_port, log) # ───────────────────────────────────────────────────────────── log(f"Binding proxy from port {PROXY_PORT}...") success, actual_port = start_udp_proxy(dst_host, dst_port, log) if not success: self.after(0, lambda: [ status_var.set("● PROXY FAILED"), sl.config(fg=ACCENT_RED) ]) return log(f"Proxy active on 127.0.0.1:{actual_port}") log("Launching Studio client...") p_guid = generate_guid() t_guid = generate_guid() log(f"PGUID : {p_guid}") log(f"TGUID : {t_guid}") try: launch_client( self.studio_path, "127.0.0.1", str(actual_port), p_guid, t_guid, "StudioPlayer_Proxy" ) self.after(0, lambda: [ status_var.set(f"● CONNECTED — port {actual_port}"), sl.config(fg=ACCENT_GREEN) ]) except Exception as e: log(f"ERROR: {e}") self.after(0, lambda: [ status_var.set("● STUDIO LAUNCH FAILED"), sl.config(fg=ACCENT_RED) ]) stop_udp_proxy(wait=False) threading.Thread(target=run, daemon=True).start() self._tm.swap(build, direction="right") # ==================== ENTRY POINT ==================== if __name__ == "__main__": app = App() app.mainloop() stop_udp_proxy(wait=True) ----- END FILE: source.py ----- SOURCE B: readable files found in mattslocalhosting-newui0.1.zip ZIP filename: mattslocalhosting-newui0.1.zip ZIP size: 141133 bytes Readable files included: 51 Generated/binary files excluded: 30 Included file index: - mattslocalhosting-newui0.1/README.md (2928 bytes, 72 lines) - mattslocalhosting-newui0.1/LICENSE.md (19346 bytes, 407 lines) - mattslocalhosting-newui0.1/requirements.txt (33 bytes, 2 lines) - mattslocalhosting-newui0.1/app/__init__.py (49 bytes, 2 lines) - mattslocalhosting-newui0.1/app/assets/icons/arrow-left-right.svg (329 bytes, 16 lines) - mattslocalhosting-newui0.1/app/assets/icons/arrow-left.svg (276 bytes, 14 lines) - mattslocalhosting-newui0.1/app/assets/icons/arrow-right.svg (275 bytes, 14 lines) - mattslocalhosting-newui0.1/app/assets/icons/copy.svg (339 bytes, 14 lines) - mattslocalhosting-newui0.1/app/assets/icons/folder.svg (355 bytes, 13 lines) - mattslocalhosting-newui0.1/app/assets/icons/globe.svg (346 bytes, 15 lines) - mattslocalhosting-newui0.1/app/assets/icons/house.svg (397 bytes, 14 lines) - mattslocalhosting-newui0.1/app/assets/icons/minus.svg (245 bytes, 13 lines) - mattslocalhosting-newui0.1/app/assets/icons/network.svg (462 bytes, 17 lines) - mattslocalhosting-newui0.1/app/assets/icons/play.svg (319 bytes, 13 lines) - mattslocalhosting-newui0.1/app/assets/icons/plus.svg (270 bytes, 14 lines) - mattslocalhosting-newui0.1/app/assets/icons/refresh-cw.svg (408 bytes, 16 lines) - mattslocalhosting-newui0.1/app/assets/icons/search.svg (289 bytes, 14 lines) - mattslocalhosting-newui0.1/app/assets/icons/settings.svg (600 bytes, 14 lines) - mattslocalhosting-newui0.1/app/assets/icons/square.svg (274 bytes, 13 lines) - mattslocalhosting-newui0.1/app/assets/icons/user.svg (313 bytes, 14 lines) - mattslocalhosting-newui0.1/app/assets/icons/x.svg (274 bytes, 14 lines) - mattslocalhosting-newui0.1/app/core/__init__.py (38 bytes, 1 lines) - mattslocalhosting-newui0.1/app/core/config.py (365 bytes, 16 lines) - mattslocalhosting-newui0.1/app/core/proxy.py (6535 bytes, 178 lines) - mattslocalhosting-newui0.1/app/core/settings.py (1291 bytes, 47 lines) - mattslocalhosting-newui0.1/app/core/studio.py (12850 bytes, 407 lines) - mattslocalhosting-newui0.1/app/core/tasks.py (4808 bytes, 138 lines) - mattslocalhosting-newui0.1/app/main.py (1601 bytes, 54 lines) - mattslocalhosting-newui0.1/app/pages/__init__.py (33 bytes, 1 lines) - mattslocalhosting-newui0.1/app/pages/base.py (3948 bytes, 116 lines) - mattslocalhosting-newui0.1/app/pages/create.py (4128 bytes, 114 lines) - mattslocalhosting-newui0.1/app/pages/join.py (1896 bytes, 59 lines) - mattslocalhosting-newui0.1/app/pages/overview.py (4968 bytes, 125 lines) - mattslocalhosting-newui0.1/app/pages/session.py (7075 bytes, 177 lines) - mattslocalhosting-newui0.1/app/pages/settings.py (2729 bytes, 77 lines) - mattslocalhosting-newui0.1/app/pages/support.py (1629 bytes, 50 lines) - mattslocalhosting-newui0.1/app/styles/dark.qss (4854 bytes, 313 lines) - mattslocalhosting-newui0.1/app/styles/theme.py (363 bytes, 15 lines) - mattslocalhosting-newui0.1/app/ui/__init__.py (36 bytes, 1 lines) - mattslocalhosting-newui0.1/app/ui/sidebar.py (3330 bytes, 100 lines) - mattslocalhosting-newui0.1/app/ui/splash.py (3511 bytes, 113 lines) - mattslocalhosting-newui0.1/app/ui/title_bar.py (2113 bytes, 59 lines) - mattslocalhosting-newui0.1/app/ui/window.py (24324 bytes, 673 lines) - mattslocalhosting-newui0.1/app/widgets/__init__.py (27 bytes, 1 lines) - mattslocalhosting-newui0.1/app/widgets/buttons.py (1364 bytes, 41 lines) - mattslocalhosting-newui0.1/app/widgets/fields.py (3314 bytes, 105 lines) - mattslocalhosting-newui0.1/app/widgets/icons.py (1226 bytes, 51 lines) - mattslocalhosting-newui0.1/app/widgets/log_console.py (1219 bytes, 39 lines) - mattslocalhosting-newui0.1/app/widgets/status.py (568 bytes, 19 lines) - mattslocalhosting-newui0.1/app/widgets/toast.py (1190 bytes, 40 lines) - mattslocalhosting-newui0.1/main.py (84 bytes, 5 lines) Excluded archive entries (listed for transparency, content not embedded): - mattslocalhosting-newui0.1/app/__pycache__/__init__.cpython-314.pyc (212 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/__pycache__/main.cpython-314.pyc (2939 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/core/__pycache__/__init__.cpython-314.pyc (203 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/core/__pycache__/config.cpython-314.pyc (804 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/core/__pycache__/proxy.cpython-314.pyc (12668 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/core/__pycache__/settings.cpython-314.pyc (3449 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/core/__pycache__/studio.cpython-314.pyc (19042 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/core/__pycache__/tasks.cpython-314.pyc (9770 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/pages/__pycache__/__init__.cpython-314.pyc (199 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/pages/__pycache__/base.cpython-314.pyc (8124 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/pages/__pycache__/create.cpython-314.pyc (7755 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/pages/__pycache__/join.cpython-314.pyc (4077 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/pages/__pycache__/overview.cpython-314.pyc (7619 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/pages/__pycache__/session.cpython-314.pyc (13425 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/pages/__pycache__/settings.cpython-314.pyc (5032 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/pages/__pycache__/support.cpython-314.pyc (3185 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/styles/__pycache__/theme.cpython-314.pyc (1048 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/ui/__pycache__/__init__.cpython-314.pyc (199 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/ui/__pycache__/sidebar.cpython-314.pyc (7629 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/ui/__pycache__/splash.cpython-314.pyc (7461 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/ui/__pycache__/title_bar.cpython-314.pyc (4855 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/ui/__pycache__/window.cpython-314.pyc (45935 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/widgets/__pycache__/__init__.cpython-314.pyc (195 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/widgets/__pycache__/buttons.cpython-314.pyc (3369 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/widgets/__pycache__/fields.cpython-314.pyc (7248 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/widgets/__pycache__/icons.cpython-314.pyc (2667 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/widgets/__pycache__/log_console.cpython-314.pyc (3249 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/widgets/__pycache__/status.cpython-314.pyc (1783 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/app/widgets/__pycache__/toast.cpython-314.pyc (2927 bytes) — generated Python bytecode/cache; not source text - mattslocalhosting-newui0.1/icon.ico (4286 bytes) — binary/non-text file not usefully represented as readable source text ============================================================================== ----- BEGIN FILE: mattslocalhosting-newui0.1/README.md ----- # Matt's LocalHost A desktop application for hosting and joining Studio team test sessions over the internet using tunnels. Built with Python and Tkinter. --- ## Requirements - Windows 10 or later - Studio installed (the app locates it automatically) - A tunnel (required for remote play, not needed for local testing) Install Python dependencies (standard library only — no pip install required). --- ## Installation 1. Go to Releases and install last release .exe file 2. Run it On first launch, a loading screen will appear while the app searches for your Studio installation via PowerShell. This takes a few seconds. If Studio is not found, you will see a warning — verify that Roblox Studio is installed before proceeding. --- ## How to Use ### Hosting a Server This section is for the person who wants to create and share a game session. 1. On the welcome screen, click **Create Server**. 2. Fill in the following fields: - **User ID** — your numeric user ID. You can find it in your profile URL (`.com/users/XXXXXXXXXX/profile`). - **Tunnel Address** — the tunnel address provided by tunnel service in the format `hostname:port` (e.g. `ur-shit.tunnel.gg:6767`). Leave this blank if you only intend to test locally. - **TeamTest Server Port** — the port Studio will listen on. Default is `55555`(same as in your tunnel settings). Change this only if the port is already in use on your machine. 3. Click **Create**. The server console will open and Studio will launch automatically as a TeamTest server. 4. Wait approximately 5 seconds for Studio to initialize. Once the status reads **SERVER IS LIVE**, the server is ready. 5. To join the server yourself from the same machine, click **Join This Server (local)**. This launches a Studio client connected directly to your local server. Share your Tunnel tunnel address (the `hostname:port` string) with anyone who wants to join remotely. --- # How set up Tunnel ## simple guide PORT: 55555 PROTOCOL: UDP --- ### Joining a Server This section is for players connecting to someone else's hosted session. 1. On the welcome screen, click **Join Server**. 2. Enter the tunnel address provided by the host, in the format `hostname:port`. 3. Click **Join**. The connection console will open and the application will establish a connection to the remote server. 4. Studio will launch automatically as a client. Wait for it to connect — you will see incoming packets logged in the console once the session is active. 5. To disconnect, click **Disconnect & Back**. This cleanly shuts down the connection and returns you to the main menu. --- ## Credits Author: s0m3thing_matters Discord Server: https://discord.gg/H3K2xeU96A --- btw README was made by ai, yes if you are afraid that this file is a virus, check it with virustotal and other services. You can unpack it, the file was packed using pyinstaller, there is no obfuscation. ----- END FILE: mattslocalhosting-newui0.1/README.md ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/LICENSE.md ----- Attribution-NonCommercial 4.0 International ======================================================================= Creative Commons Corporation ("Creative Commons") is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an "as-is" basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. Using Creative Commons Public Licenses Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC- licensed material, or material used under an exception or limitation to copyright. More considerations for licensors: wiki.creativecommons.org/Considerations_for_licensors Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor's permission is not necessary for any reason--for example, because of any applicable exception or limitation to copyright--then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public: wiki.creativecommons.org/Considerations_for_licensees ======================================================================= Creative Commons Attribution-NonCommercial 4.0 International Public License By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. Section 1 -- Definitions. a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. c. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. d. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. e. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. f. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License. g. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. h. Licensor means the individual(s) or entity(ies) granting rights under this Public License. i. NonCommercial means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange. j. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. k. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. l. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. Section 2 -- Scope. a. License grant. 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: a. reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and b. produce, reproduce, and Share Adapted Material for NonCommercial purposes only. 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. 3. Term. The term of this Public License is specified in Section 6(a). 4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a) (4) never produces Adapted Material. 5. Downstream recipients. a. Offer from the Licensor -- Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. b. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. 6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). b. Other rights. 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. 2. Patent and trademark rights are not licensed under this Public License. 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes. Section 3 -- License Conditions. Your exercise of the Licensed Rights is expressly made subject to the following conditions. a. Attribution. 1. If You Share the Licensed Material (including in modified form), You must: a. retain the following if it is supplied by the Licensor with the Licensed Material: i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); ii. a copyright notice; iii. a notice that refers to this Public License; iv. a notice that refers to the disclaimer of warranties; v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; b. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and c. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. 4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License. Section 4 -- Sui Generis Database Rights. Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only; b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. Section 5 -- Disclaimer of Warranties and Limitation of Liability. a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. Section 6 -- Term and Termination. a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or 2. upon express reinstatement by the Licensor. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. Section 7 -- Other Terms and Conditions. a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. Section 8 -- Interpretation. a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. ======================================================================= Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” The text of the Creative Commons public licenses is dedicated to the public domain under the CC0 Public Domain Dedication. Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark "Creative Commons" or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. Creative Commons may be contacted at creativecommons.org. ----- END FILE: mattslocalhosting-newui0.1/LICENSE.md ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/requirements.txt ----- PySide6>=6.11,<7 pyinstaller>=6.6 ----- END FILE: mattslocalhosting-newui0.1/requirements.txt ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/__init__.py ----- __app_name__ = "LocalHost" __version__ = "2.0.0" ----- END FILE: mattslocalhosting-newui0.1/app/__init__.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/assets/icons/arrow-left-right.svg ----- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M8 3 4 7l4 4" /> <path d="M4 7h16" /> <path d="m16 21 4-4-4-4" /> <path d="M20 17H4" /> </svg> ----- END FILE: mattslocalhosting-newui0.1/app/assets/icons/arrow-left-right.svg ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/assets/icons/arrow-left.svg ----- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="m12 19-7-7 7-7" /> <path d="M19 12H5" /> </svg> ----- END FILE: mattslocalhosting-newui0.1/app/assets/icons/arrow-left.svg ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/assets/icons/arrow-right.svg ----- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M5 12h14" /> <path d="m12 5 7 7-7 7" /> </svg> ----- END FILE: mattslocalhosting-newui0.1/app/assets/icons/arrow-right.svg ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/assets/icons/copy.svg ----- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <rect width="14" height="14" x="8" y="8" rx="2" ry="2" /> <path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" /> </svg> ----- END FILE: mattslocalhosting-newui0.1/app/assets/icons/copy.svg ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/assets/icons/folder.svg ----- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z" /> </svg> ----- END FILE: mattslocalhosting-newui0.1/app/assets/icons/folder.svg ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/assets/icons/globe.svg ----- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <circle cx="12" cy="12" r="10" /> <path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20" /> <path d="M2 12h20" /> </svg> ----- END FILE: mattslocalhosting-newui0.1/app/assets/icons/globe.svg ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/assets/icons/house.svg ----- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8" /> <path d="M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" /> </svg> ----- END FILE: mattslocalhosting-newui0.1/app/assets/icons/house.svg ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/assets/icons/minus.svg ----- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M5 12h14" /> </svg> ----- END FILE: mattslocalhosting-newui0.1/app/assets/icons/minus.svg ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/assets/icons/network.svg ----- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <rect x="16" y="16" width="6" height="6" rx="1" /> <rect x="2" y="16" width="6" height="6" rx="1" /> <rect x="9" y="2" width="6" height="6" rx="1" /> <path d="M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3" /> <path d="M12 12V8" /> </svg> ----- END FILE: mattslocalhosting-newui0.1/app/assets/icons/network.svg ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/assets/icons/play.svg ----- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z" /> </svg> ----- END FILE: mattslocalhosting-newui0.1/app/assets/icons/play.svg ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/assets/icons/plus.svg ----- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M5 12h14" /> <path d="M12 5v14" /> </svg> ----- END FILE: mattslocalhosting-newui0.1/app/assets/icons/plus.svg ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/assets/icons/refresh-cw.svg ----- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8" /> <path d="M21 3v5h-5" /> <path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16" /> <path d="M8 16H3v5" /> </svg> ----- END FILE: mattslocalhosting-newui0.1/app/assets/icons/refresh-cw.svg ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/assets/icons/search.svg ----- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="m21 21-4.34-4.34" /> <circle cx="11" cy="11" r="8" /> </svg> ----- END FILE: mattslocalhosting-newui0.1/app/assets/icons/search.svg ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/assets/icons/settings.svg ----- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915" /> <circle cx="12" cy="12" r="3" /> </svg> ----- END FILE: mattslocalhosting-newui0.1/app/assets/icons/settings.svg ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/assets/icons/square.svg ----- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <rect width="18" height="18" x="3" y="3" rx="2" /> </svg> ----- END FILE: mattslocalhosting-newui0.1/app/assets/icons/square.svg ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/assets/icons/user.svg ----- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" /> <circle cx="12" cy="7" r="4" /> </svg> ----- END FILE: mattslocalhosting-newui0.1/app/assets/icons/user.svg ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/assets/icons/x.svg ----- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M18 6 6 18" /> <path d="m6 6 12 12" /> </svg> ----- END FILE: mattslocalhosting-newui0.1/app/assets/icons/x.svg ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/core/__init__.py ----- """Backend services for LocalHost.""" ----- END FILE: mattslocalhosting-newui0.1/app/core/__init__.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/core/config.py ----- from __future__ import annotations from pathlib import Path APP_NAME = "LocalHost" PROXY_PORT = 55555 WINDOW_W = 1080 WINDOW_H = 700 WINDOW_MIN_W = 780 WINDOW_MIN_H = 540 ROOT_DIR = Path(__file__).resolve().parents[2] DATA_FILE = ROOT_DIR / "mattslocalhost_data.json" ASSETS_DIR = Path(__file__).resolve().parents[1] / "assets" ICONS_DIR = ASSETS_DIR / "icons" ----- END FILE: mattslocalhosting-newui0.1/app/core/config.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/core/proxy.py ----- from __future__ import annotations import socket import threading import time from collections.abc import Callable from app.core.config import PROXY_PORT LogFn = Callable[[str, str], None] def find_free_port(start_port: int, max_attempts: int = 100) -> int: for port in range(start_port, start_port + max_attempts): with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock: try: sock.bind(("127.0.0.1", port)) return port except OSError: continue return -1 def warmup_udp_tunnel(dst_host: str, dst_port: int, log: LogFn, packets: int = 10, delay: float = 0.05) -> None: log(f"Warming tunnel {dst_host}:{dst_port} ({packets} packets)", "info") try: dst_ip = socket.gethostbyname(dst_host) with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock: sock.settimeout(0.5) payload = b"\x00" * 64 for _ in range(packets): try: sock.sendto(payload, (dst_ip, dst_port)) except OSError: pass time.sleep(delay) log("Tunnel warm-up complete", "success") except Exception as exc: log(f"Warm-up warning: {exc}", "warning") class UdpProxy: def __init__(self, base_port: int = PROXY_PORT) -> None: self.base_port = base_port self.active_port: int | None = None self._running = threading.Event() self._stopped = threading.Event() self._sockets: list[socket.socket] = [] self._lock = threading.Lock() self._thread: threading.Thread | None = None @property def is_running(self) -> bool: return self._running.is_set() def start(self, dst_host: str, dst_port: int, log: LogFn) -> tuple[bool, int]: if self.is_running: self.stop() self._running.set() self._stopped.clear() ready = threading.Event() error: list[str | None] = [None] port_box: list[int | None] = [None] def worker() -> None: sessions: dict[tuple[str, int], socket.socket] = {} local_sock: socket.socket | None = None try: dst_ip = socket.gethostbyname(dst_host) log(f"Resolved {dst_host} -> {dst_ip}", "info") bound_port = find_free_port(self.base_port) if bound_port == -1: raise OSError(f"No free UDP ports starting at {self.base_port}") port_box[0] = bound_port if bound_port != self.base_port: log(f"Port {self.base_port} busy, using {bound_port}", "warning") local_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) local_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) local_sock.bind(("127.0.0.1", bound_port)) local_sock.settimeout(0.3) with self._lock: self._sockets.append(local_sock) log(f"UDP proxy bound on 127.0.0.1:{bound_port}", "success") ready.set() while self._running.is_set(): try: data, addr = local_sock.recvfrom(65535) except socket.timeout: continue except OSError: break if addr not in sessions: log(f"New session: {addr[0]}:{addr[1]}", "info") session_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) session_sock.settimeout(0.3) sessions[addr] = session_sock def listen(sock: socket.socket, client_addr: tuple[str, int]) -> None: while self._running.is_set() and client_addr in sessions: try: resp, _ = sock.recvfrom(65535) local_sock.sendto(resp, client_addr) except socket.timeout: continue except OSError: break try: sock.close() except Exception: pass sessions.pop(client_addr, None) threading.Thread(target=listen, args=(session_sock, addr), daemon=True).start() try: sessions[addr].sendto(data, (dst_ip, dst_port)) except OSError as exc: log(f"Send error: {exc}", "error") except Exception as exc: error[0] = str(exc) ready.set() finally: for sock in list(sessions.values()): try: sock.close() except Exception: pass sessions.clear() if local_sock: with self._lock: try: self._sockets.remove(local_sock) except ValueError: pass try: local_sock.close() except Exception: pass self.active_port = None self._stopped.set() log("UDP proxy stopped", "info") self._thread = threading.Thread(target=worker, daemon=True) self._thread.start() ready.wait(timeout=5) if error[0]: log(f"Proxy error: {error[0]}", "error") self._running.clear() return False, -1 self.active_port = port_box[0] return True, port_box[0] or -1 def stop(self, wait: bool = True) -> None: if not self.is_running: return self._running.clear() with self._lock: for sock in list(self._sockets): try: sock.close() except Exception: pass self._sockets.clear() if wait and self._thread and self._thread.is_alive(): self._stopped.wait(timeout=3) self._thread = None self.active_port = None proxy = UdpProxy() ----- END FILE: mattslocalhosting-newui0.1/app/core/proxy.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/core/settings.py ----- from __future__ import annotations import json from dataclasses import asdict, dataclass from pathlib import Path from typing import Any from app.core.config import DATA_FILE @dataclass(slots=True) class AppSettings: user_id: str = "" host_tunnel: str = "" join_tunnel: str = "" server_port: str = "55555" place_path: str = "" studio_path: str = "" class SettingsStore: def __init__(self, path: Path = DATA_FILE) -> None: self.path = path def load(self) -> AppSettings: defaults = asdict(AppSettings()) try: if self.path.exists(): payload = json.loads(self.path.read_text(encoding="utf-8")) if isinstance(payload, dict): return AppSettings(**{**defaults, **payload}) except Exception: pass return AppSettings() def save(self, settings: AppSettings) -> None: self.path.write_text( json.dumps(asdict(settings), indent=2), encoding="utf-8", ) def update(self, settings: AppSettings, **values: Any) -> AppSettings: payload = asdict(settings) payload.update(values) next_settings = AppSettings(**payload) self.save(next_settings) return next_settings ----- END FILE: mattslocalhosting-newui0.1/app/core/settings.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/core/studio.py ----- from __future__ import annotations import os import shutil import subprocess import uuid from pathlib import Path from app.core.config import ROOT_DIR _roblox_processes: list[subprocess.Popen] = [] _roblox_processes_by_key: dict[str, list[subprocess.Popen]] = {} SERVER_PLACE_DIR = ROOT_DIR / ".localhost_cache" / "places" RUNTIME_SERVER_PLACE = Path(os.environ.get("LOCALAPPDATA", "")) / "Roblox" / "server.rbxl" def generate_guid() -> str: return str(uuid.uuid4()).upper() def validate_studio_path(studio: str) -> None: if not studio: raise FileNotFoundError("RobloxStudioBeta.exe path is empty.") if not Path(studio).is_file(): raise FileNotFoundError(f"RobloxStudioBeta.exe not found at: {studio}") def validate_place_path(place_path: str) -> str: if not place_path: return "" path = Path(place_path).expanduser() if not path.is_absolute(): path = ROOT_DIR / path path = path.resolve() if not path.is_file(): raise FileNotFoundError(f"Map file not found at: {path}") if path.suffix.lower() not in {".rbxl", ".rbxlx"}: raise ValueError("Map file must be a .rbxl or .rbxlx file.") return str(path) def open_place_file(place_path: str) -> None: path = validate_place_path(place_path) if os.name == "nt": subprocess.Popen( ["cmd", "/c", "start", "", path], shell=False, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) return subprocess.Popen([path]) def start_server_and_clients_hotkey() -> None: if os.name != "nt": raise RuntimeError("Server & Clients hotkey launch is only supported on Windows.") flags = subprocess.CREATE_NO_WINDOW if hasattr(subprocess, "CREATE_NO_WINDOW") else 0 script = r""" Add-Type @' using System; using System.Text; using System.Runtime.InteropServices; public class Win32Focus { public delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam); [DllImport("user32.dll")] public static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam); [DllImport("user32.dll")] public static extern bool IsWindowVisible(IntPtr hWnd); [DllImport("user32.dll")] public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount); [DllImport("user32.dll")] public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint processId); [DllImport("user32.dll")] public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect); [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); [DllImport("user32.dll")] public static extern bool SetForegroundWindow(IntPtr hWnd); [DllImport("user32.dll")] public static extern bool SetCursorPos(int X, int Y); [DllImport("user32.dll")] public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, UIntPtr dwExtraInfo); [StructLayout(LayoutKind.Sequential)] public struct RECT { public int Left; public int Top; public int Right; public int Bottom; } } '@ $ws = New-Object -ComObject WScript.Shell $MOUSEEVENTF_LEFTDOWN = 0x0002 $MOUSEEVENTF_LEFTUP = 0x0004 function Click-Point([int]$x, [int]$y) { [void][Win32Focus]::SetCursorPos($x, $y) Start-Sleep -Milliseconds 80 [Win32Focus]::mouse_event($MOUSEEVENTF_LEFTDOWN, 0, 0, 0, [UIntPtr]::Zero) Start-Sleep -Milliseconds 80 [Win32Focus]::mouse_event($MOUSEEVENTF_LEFTUP, 0, 0, 0, [UIntPtr]::Zero) } $deadline = (Get-Date).AddSeconds(45) while ((Get-Date) -lt $deadline) { $script:target = [IntPtr]::Zero [Win32Focus]::EnumWindows({ param($h, $l) if ([Win32Focus]::IsWindowVisible($h)) { $sb = New-Object System.Text.StringBuilder 512 [void][Win32Focus]::GetWindowText($h, $sb, $sb.Capacity) $title = $sb.ToString() [uint32]$pidValue = 0 [void][Win32Focus]::GetWindowThreadProcessId($h, [ref]$pidValue) $procName = '' try { $procName = (Get-Process -Id $pidValue -ErrorAction Stop).ProcessName } catch {} if ( $procName -eq 'RobloxStudioBeta' -or $title -like '*Roblox Studio*' -or $title -like '*.rbxl*' -or $title -like '*.rbxlx*' ) { $script:target = $h return $false } } return $true }, [IntPtr]::Zero) | Out-Null if ($script:target -ne [IntPtr]::Zero) { [void][Win32Focus]::ShowWindow($script:target, 9) [void][Win32Focus]::SetForegroundWindow($script:target) Start-Sleep -Milliseconds 800 $rect = New-Object Win32Focus+RECT if (-not [Win32Focus]::GetWindowRect($script:target, [ref]$rect)) { $ws.SendKeys('{F7}') exit 0 } # Roblox Studio starts Server & Clients only when that test mode is selected. # The mode selector and Play button sit at fixed offsets in Studio's top-left mezzanine. Click-Point ($rect.Left + 42) ($rect.Top + 29) Start-Sleep -Milliseconds 450 Click-Point ($rect.Left + 64) ($rect.Top + 137) Start-Sleep -Milliseconds 550 Click-Point ($rect.Left + 105) ($rect.Top + 29) Start-Sleep -Milliseconds 500 $ws.SendKeys('{F7}') exit 0 } Start-Sleep -Milliseconds 500 } exit 1 """ result = subprocess.run( ["powershell", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", script], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, creationflags=flags, ) if result.returncode != 0: raise RuntimeError("Could not focus Roblox Studio to start Server & Clients.") def prepare_server_place_file(place_path: str) -> str: source = Path(validate_place_path(place_path)) SERVER_PLACE_DIR.mkdir(parents=True, exist_ok=True) target = SERVER_PLACE_DIR / f"server_launch_{uuid.uuid4().hex}.rbxl" shutil.copyfile(source, target) return str(target.resolve()) def prepare_runtime_server_place_file(place_path: str) -> str: source = Path(validate_place_path(place_path)) if not RUNTIME_SERVER_PLACE.parent.is_dir(): RUNTIME_SERVER_PLACE.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(source, RUNTIME_SERVER_PLACE) return str(RUNTIME_SERVER_PLACE.resolve()) def get_studio_path() -> str: candidates: list[str] = [] local = os.environ.get("LOCALAPPDATA", "") roots = [] if local: roots.append(Path(local) / "Roblox" / "Versions") roots.extend([Path(r"C:\Program Files (x86)\Roblox"), Path(r"C:\Program Files\Roblox")]) for base in roots: if base.is_dir(): for path in base.rglob("RobloxStudioBeta.exe"): candidates.append(str(path)) for path in candidates: if Path(path).is_file(): return path if os.name == "nt": try: flags = subprocess.CREATE_NO_WINDOW if hasattr(subprocess, "CREATE_NO_WINDOW") else 0 result = subprocess.check_output( [ "powershell", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", ( "Get-ChildItem -Path $env:LOCALAPPDATA\\Roblox\\Versions " "-Filter RobloxStudioBeta.exe -Recurse -ErrorAction SilentlyContinue | " "Select-Object -First 1 -ExpandProperty FullName" ), ], creationflags=flags, ).decode(errors="ignore").strip() if result and Path(result).is_file(): return result except Exception: pass return "" def _studio_command(studio: str) -> list[str]: validate_studio_path(studio) return [studio] def build_server_command( studio: str, port: str, user_id: str, parent_guid: str, play_guid: str, place_path: str = "", startup_players: int = 0, use_runtime_place: bool = False, ) -> list[str]: command = _studio_command(studio) selected_place = "" if use_runtime_place else (prepare_server_place_file(place_path) if place_path else "") if use_runtime_place and place_path: prepare_runtime_server_place_file(place_path) command.extend(["-task", "StartServer"]) if selected_place: command.extend(["-localPlaceFile", selected_place, "-port", str(port)]) return command else: command.extend(["-placeId", "0", "-universeId", "0", "-placeVersion", "0"]) command.extend( [ "-port", str(port), "-creatorId", str(user_id), "-creatorType", "0", "-userid", str(user_id), "-numTestServerPlayersUponStartup", str(startup_players), "-parentSessionGuid", parent_guid, "-playTestSessionGuid", play_guid, "-instanceId", "StudioServer", ] ) return command def launch_server( studio: str, port: str, user_id: str, parent_guid: str, play_guid: str, place_path: str = "", startup_players: int = 0, use_runtime_place: bool = False, session_key: str | None = None, ) -> subprocess.Popen: command = build_server_command( studio, port, user_id, parent_guid, play_guid, place_path, startup_players=startup_players, use_runtime_place=use_runtime_place, ) return launch_server_command(studio, command, session_key=session_key) def launch_server_command( studio: str, command: list[str], session_key: str | None = None, ) -> subprocess.Popen: proc = subprocess.Popen( command, ) _track_roblox_process(proc, session_key) return proc def launch_client( studio: str, server_ip: str, server_port: str | int, parent_guid: str, play_guid: str, instance_id: str, session_key: str | None = None, ) -> subprocess.Popen: command = _studio_command(studio) command.extend( [ "-task", "StartClient", "-placeId", "0", "-universeId", "0", "-placeVersion", "0", "-server", server_ip, "-port", str(server_port), "-parentSessionGuid", parent_guid, "-playTestSessionGuid", play_guid, "-instanceId", instance_id, ] ) proc = subprocess.Popen( command ) _track_roblox_process(proc, session_key) return proc def _track_roblox_process(proc: subprocess.Popen, session_key: str | None = None) -> None: _roblox_processes.append(proc) if session_key: _roblox_processes_by_key.setdefault(session_key, []).append(proc) def _kill_process_tree(proc: subprocess.Popen) -> bool: try: if proc.poll() is not None: return False if os.name == "nt": flags = subprocess.CREATE_NO_WINDOW if hasattr(subprocess, "CREATE_NO_WINDOW") else 0 result = subprocess.run( ["taskkill", "/F", "/T", "/PID", str(proc.pid)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, creationflags=flags, ) return result.returncode == 0 proc.kill() return True except Exception: return False def stop_roblox_processes(session_key: str) -> int: killed = 0 procs = _roblox_processes_by_key.pop(session_key, []) for proc in list(procs): if _kill_process_tree(proc): killed += 1 try: _roblox_processes.remove(proc) except ValueError: pass return killed def has_running_processes() -> bool: for proc in list(_roblox_processes): try: if proc.poll() is None: return True except Exception: pass return False def stop_all_roblox_processes() -> int: killed = 0 for proc in list(_roblox_processes): if _kill_process_tree(proc): killed += 1 _roblox_processes.clear() _roblox_processes_by_key.clear() if os.name == "nt": flags = subprocess.CREATE_NO_WINDOW if hasattr(subprocess, "CREATE_NO_WINDOW") else 0 for target in ("RobloxStudioBeta.exe", "RobloxPlayerBeta.exe"): try: result = subprocess.run( ["taskkill", "/F", "/T", "/IM", target], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, creationflags=flags, ) if result.returncode == 0: killed += 1 except Exception: pass return killed ----- END FILE: mattslocalhosting-newui0.1/app/core/studio.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/core/tasks.py ----- from __future__ import annotations import time import shiboken6 from PySide6.QtCore import QObject, Signal, Slot from app.core.config import PROXY_PORT from app.core.proxy import proxy, warmup_udp_tunnel from app.core.studio import generate_guid, launch_client, launch_server SETUP_WAIT_SECONDS = 20 class HostSessionWorker(QObject): log = Signal(str, str) status = Signal(str, str) progress = Signal(int, str) finished = Signal() def __init__(self, studio: str, user_id: str, port: str, place_path: str = "") -> None: super().__init__() self.studio = studio self.user_id = user_id self.port = port self.place_path = place_path self.parent_guid = generate_guid() self.play_guid = generate_guid() self._cancelled = False @Slot() def run(self) -> None: try: self.status.emit("Setting up", "warn") self.progress.emit(5, "Preparing") if self.place_path: self.log.emit(f"Selected map: {self.place_path}", "info") self.log.emit("Copying map to Roblox local server runtime", "info") self.progress.emit(30, "Starting local server") launch_server( self.studio, self.port, self.user_id, self.parent_guid, self.play_guid, self.place_path, startup_players=1, use_runtime_place=bool(self.place_path), session_key="create", ) self.log.emit(f"Local server + 1 client start command sent on port {self.port}", "info") for step in range(180): if self._cancelled: self.finished.emit() return time.sleep(0.1) self.progress.emit(30 + int((step / 179) * 65), "Initializing server and client") self.status.emit("Server live", "ok") self.status.emit("Server + client live", "ok") self.progress.emit(100, "Server and clients launched") self.log.emit("Server and client launched", "success") except Exception as exc: self.status.emit("Launch failed", "err") self.progress.emit(100, "Erreur") self.log.emit(f"ERROR: {exc}", "error") finally: self.finished.emit() @Slot() def stop(self) -> None: self._cancelled = True class JoinSessionWorker(QObject): log = Signal(str, str) status = Signal(str, str) info_changed = Signal(str, str) finished = Signal() def __init__(self, studio: str, dst_host: str, dst_port: int) -> None: super().__init__() self.studio = studio self.dst_host = dst_host self.dst_port = dst_port self.parent_guid = generate_guid() self.play_guid = generate_guid() self._cancelled = False @Slot() def run(self) -> None: try: self.log.emit("Preparing tunnel connection", "info") warmup_udp_tunnel(self.dst_host, self.dst_port, self._emit_log) if self._cancelled: self.finished.emit() return self.log.emit(f"Binding proxy from port {PROXY_PORT}", "info") success, actual_port = proxy.start(self.dst_host, self.dst_port, self._emit_log) if not success: self.status.emit("Proxy failed", "err") self.log.emit("Proxy failed to bind. Aborting", "error") return self.info_changed.emit("Local proxy", f"127.0.0.1:{actual_port}") self.info_changed.emit("Status", "Proxy active") self.log.emit(f"Proxy active on 127.0.0.1:{actual_port}", "success") self.log.emit("Launching Studio client", "info") launch_client( self.studio, "127.0.0.1", actual_port, self.parent_guid, self.play_guid, "StudioPlayer_Proxy", session_key="join", ) self.status.emit(f"Connected :{actual_port}", "ok") self.log.emit("Studio client launched", "success") except Exception as exc: proxy.stop(wait=False) self.status.emit("Client failed", "err") self.log.emit(f"ERROR: {exc}", "error") finally: self.finished.emit() def _emit_log(self, message: str, level: str = "info") -> None: try: if shiboken6.isValid(self): self.log.emit(message, level) except RuntimeError: pass @Slot() def stop(self) -> None: self._cancelled = True proxy.stop(wait=False) ----- END FILE: mattslocalhosting-newui0.1/app/core/tasks.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/main.py ----- from __future__ import annotations import sys from PySide6.QtCore import Qt from PySide6.QtWidgets import QApplication from app.core.settings import SettingsStore from app.core.studio import generate_guid, get_studio_path, launch_server from app.styles.theme import apply_theme from app.ui.splash import StartupSplash from app.ui.window import MainWindow def main() -> int: if len(sys.argv) > 1 and sys.argv[1].lower().endswith((".rbxl", ".rbxlx")): settings = SettingsStore().load() studio = settings.studio_path if settings.studio_path else get_studio_path() parent_guid = generate_guid() play_guid = generate_guid() launch_server( studio, settings.server_port, settings.user_id, parent_guid, play_guid, sys.argv[1], startup_players=1, use_runtime_place=True, ) return 0 QApplication.setHighDpiScaleFactorRoundingPolicy( Qt.HighDpiScaleFactorRoundingPolicy.PassThrough ) qt_app = QApplication(sys.argv) qt_app.setApplicationName("LocalHost") qt_app.setOrganizationName("LocalHost") apply_theme(qt_app) state: dict[str, MainWindow | StartupSplash | None] = {"window": None, "splash": None} splash = StartupSplash() state["splash"] = splash def show_main() -> None: window = MainWindow() state["window"] = window window.show() splash.close() state["splash"] = None splash.finished.connect(show_main) splash.start() return qt_app.exec() ----- END FILE: mattslocalhosting-newui0.1/app/main.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/pages/__init__.py ----- """Stacked application pages.""" ----- END FILE: mattslocalhosting-newui0.1/app/pages/__init__.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/pages/base.py ----- from __future__ import annotations from PySide6.QtCore import Qt from PySide6.QtWidgets import QFrame, QHBoxLayout, QLabel, QVBoxLayout, QWidget from app.widgets.buttons import IconButton def divider() -> QFrame: line = QFrame() line.setObjectName("divider") return line class Page(QWidget): def __init__(self) -> None: super().__init__() self.root = QVBoxLayout(self) self.root.setContentsMargins(32, 24, 32, 24) self.root.setSpacing(18) def add_header(self, title: str, subtitle: str = "", actions: QHBoxLayout | None = None) -> None: row = QHBoxLayout() row.setContentsMargins(0, 0, 0, 0) left = QVBoxLayout() left.setContentsMargins(0, 0, 0, 0) left.setSpacing(4) title_label = QLabel(title) title_label.setObjectName("pageTitle") left.addWidget(title_label) if subtitle: sub = QLabel(subtitle) sub.setObjectName("pageSubtitle") sub.setWordWrap(True) left.addWidget(sub) row.addLayout(left, 1) if actions: row.addLayout(actions) self.root.addLayout(row) self.root.addWidget(divider()) class Metric(QFrame): def __init__(self, label: str, value: str, hint: str, value_color: str = "#ededed") -> None: super().__init__() self.setObjectName("metric") layout = QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(3) label_w = QLabel(label) label_w.setObjectName("metricLabel") value_w = QLabel(value) value_w.setObjectName("metricValue") value_w.setStyleSheet(f"color: {value_color};") hint_w = QLabel(hint) hint_w.setObjectName("metricHint") hint_w.setWordWrap(True) layout.addWidget(label_w) layout.addWidget(value_w) layout.addWidget(hint_w) layout.addStretch() class InfoRows(QWidget): def __init__(self, rows: list[tuple[str, str]]) -> None: super().__init__() self.labels: dict[str, QLabel] = {} self.row_layouts: dict[str, QVBoxLayout] = {} layout = QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(10) heading = QLabel("Session") heading.setObjectName("sectionTitle") layout.addWidget(heading) for key, value in rows: row = QVBoxLayout() row.setContentsMargins(0, 0, 0, 0) row.setSpacing(2) key_label = QLabel(key) key_label.setObjectName("metricLabel") value_label = QLabel(value) value_label.setTextInteractionFlags(Qt.TextInteractionFlag.TextSelectableByMouse) value_label.setObjectName("pathLabel") value_label.setWordWrap(True) row.addWidget(key_label) row.addWidget(value_label) layout.addLayout(row) self.labels[key] = value_label self.row_layouts[key] = row layout.addStretch() def set_value(self, key: str, value: str, color: str | None = None) -> None: label = self.labels.get(key) if not label: return label.setText(value) if color: label.setStyleSheet(f"color: {color};") def add_inline_action(self, key: str, icon: str, tooltip: str, callback) -> None: label = self.labels.get(key) if not label: return row_layout = self.row_layouts.get(key) if not row_layout: return row_layout.removeWidget(label) value_row = QHBoxLayout() value_row.setContentsMargins(0, 0, 0, 0) value_row.setSpacing(6) value_row.addWidget(label, 1) button = IconButton(icon, tooltip, "inline") button.clicked.connect(callback) value_row.addWidget(button) row_layout.addLayout(value_row) ----- END FILE: mattslocalhosting-newui0.1/app/pages/base.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/pages/create.py ----- from __future__ import annotations from pathlib import Path from PySide6.QtWidgets import QFileDialog from PySide6.QtWidgets import QHBoxLayout, QVBoxLayout from app.core.config import ROOT_DIR from app.pages.base import Page from app.widgets.buttons import AppButton from app.widgets.fields import FormField class CreatePage(Page): def __init__(self, window) -> None: super().__init__() self.window = window self.add_header( "Create session", "Launch a local Studio server. Other clients can connect locally or through a tunnel.", ) form = QVBoxLayout() form.setSpacing(16) self.user_id = FormField( "User ID", window.settings.user_id, "Creator ID used to authenticate the local session.", icon="user", validator=lambda v: None if v.isdigit() else "Must be numeric", ) self.tunnel = FormField( "Tunnel address", window.settings.host_tunnel, "Optional. Format host:port, e.g. your.tunnel.gg:1234.", icon="globe", ) self.port = FormField( "TeamTest port", window.settings.server_port, "Local port the Studio server will listen on.", icon="network", validator=lambda v: None if v.isdigit() and 1 <= int(v) <= 65535 else "Invalid port", ) self.place_path = FormField( "Map file", window.settings.place_path, "Local .rbxl or .rbxlx file to load when creating the session.", icon="folder", validator=self._validate_place_path, ) form.addWidget(self.user_id) form.addWidget(self.tunnel) form.addWidget(self.port) place_row = QHBoxLayout() place_row.setSpacing(10) browse = AppButton("Choose map", "folder", "secondary") browse.clicked.connect(self._browse_place) place_row.addWidget(self.place_path, 1) place_row.addWidget(browse) form.addLayout(place_row) form.addStretch() self.root.addLayout(form, 1) actions = QHBoxLayout() back = AppButton("Back", "back", "ghost") create = AppButton("Launch server", "play", "primary") back.clicked.connect(lambda: window.navigate("overview")) create.clicked.connect(self._create) actions.addWidget(back) actions.addStretch() actions.addWidget(create) self.root.addLayout(actions) def _create(self) -> None: valid = self.user_id.validate() and self.port.validate() and self.place_path.validate() if not self.user_id.value() or not self.port.value(): self.window.toast("User ID and port are required.", "warning") return if not valid: self.window.toast("Fix the highlighted fields.", "error") return self.window.create_session(self.user_id.value(), self.tunnel.value(), self.port.value(), self.place_path.value()) def _browse_place(self) -> None: current = Path(self.place_path.value()) if self.place_path.value() else ROOT_DIR if not current.is_absolute(): current = ROOT_DIR / current condo_dir = ROOT_DIR.parent if current.is_file(): start_dir = str(current.parent) elif condo_dir.is_dir(): start_dir = str(condo_dir) else: start_dir = str(ROOT_DIR) path, _ = QFileDialog.getOpenFileName( self, "Choose map", start_dir, "Place (*.rbxl *.rbxlx);;All files (*.*)", ) if path: self.place_path.edit.setText(path) self._create() def _validate_place_path(self, value: str) -> str | None: path = Path(value) if not path.is_absolute(): path = ROOT_DIR / path if not path.is_file(): return "File not found" if path.suffix.lower() not in {".rbxl", ".rbxlx"}: return "Use .rbxl/.rbxlx" return None ----- END FILE: mattslocalhosting-newui0.1/app/pages/create.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/pages/join.py ----- from __future__ import annotations from PySide6.QtWidgets import QHBoxLayout, QVBoxLayout from app.pages.base import Page from app.widgets.buttons import AppButton from app.widgets.fields import FormField def validate_tunnel(value: str) -> str | None: if ":" not in value: return "Format must be host:port" host, port = value.rsplit(":", 1) if not host: return "Missing host" if not port.isdigit(): return "Port must be numeric" return None class JoinPage(Page): def __init__(self, window) -> None: super().__init__() self.window = window self.add_header( "Join tunnel", "Open a UDP proxy locally and launch a Studio client through the tunnel address.", ) form = QVBoxLayout() self.tunnel = FormField( "Tunnel address", window.settings.join_tunnel, "Format host:port, e.g. therefore-protocol.tunnel.gg:2842.", placeholder="therefore-protocol.tunnel.gg:2842", icon="globe", validator=validate_tunnel, ) form.addWidget(self.tunnel) form.addStretch() self.root.addLayout(form, 1) actions = QHBoxLayout() back = AppButton("Back", "back", "ghost") join = AppButton("Join tunnel", "next", "primary") back.clicked.connect(lambda: window.navigate("overview")) join.clicked.connect(self._join) actions.addWidget(back) actions.addStretch() actions.addWidget(join) self.root.addLayout(actions) def _join(self) -> None: if not self.tunnel.validate() or not self.tunnel.value(): self.window.toast("Fix the tunnel address.", "error") return host, port = self.tunnel.value().rsplit(":", 1) self.window.join_session(host, int(port), self.tunnel.value()) ----- END FILE: mattslocalhosting-newui0.1/app/pages/join.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/pages/overview.py ----- from __future__ import annotations from pathlib import Path from PySide6.QtWidgets import QFrame, QGridLayout, QHBoxLayout, QLabel, QVBoxLayout from app.core.config import PROXY_PORT from app.pages.base import Metric, Page, divider from app.widgets.buttons import AppButton from app.widgets.status import StatusDot class OverviewPage(Page): def __init__(self, window) -> None: super().__init__() self.window = window active = window.session_active() server_active = "create" in getattr(window, "active_modes", set()) connection_active = "join" in getattr(window, "active_modes", set()) actions = QHBoxLayout() actions.setSpacing(8) create_text = "Open server" if server_active else "New server" join_text = "Open connection" if connection_active else "Join" create = AppButton(create_text, "play" if server_active else "create", "primary") join = AppButton(join_text, "join", "secondary") create.clicked.connect(lambda: window.navigate("create")) join.clicked.connect(lambda: window.navigate("join")) actions.addWidget(create) actions.addWidget(join) self.add_header("Overview", "TeamTest launcher and tunnel proxy.", actions) metrics = QGridLayout() metrics.setHorizontalSpacing(24) metrics.setVerticalSpacing(12) if server_active and connection_active: session_value = "Server + Tunnel" elif server_active: session_value = "Server" elif connection_active: session_value = "Tunnel" else: session_value = "Idle" session_hint = "Open the active panel from the sidebar" if active else "No Studio process managed by LocalHost" metrics.addWidget( Metric( "Session", session_value, session_hint, "#4ade80" if active else "#6e6e6e", ), 0, 0, ) studio_name = Path(window.studio_path).name if window.studio_path else "Missing" metrics.addWidget( Metric( "Studio", "Ready" if window.studio_path else "Missing", studio_name, "#ededed" if window.studio_path else "#eab308", ), 0, 1, ) metrics.addWidget(Metric("Proxy", f"UDP {PROXY_PORT}", "127.0.0.1", "#ededed"), 0, 2) metrics.setColumnStretch(0, 1) metrics.setColumnStretch(1, 1) metrics.setColumnStretch(2, 1) self.root.addLayout(metrics) self.root.addWidget(divider()) body = QGridLayout() body.setHorizontalSpacing(34) body.setColumnStretch(0, 2) body.setColumnStretch(1, 1) activity = QVBoxLayout() heading = QLabel("System") heading.setObjectName("sectionTitle") activity.addWidget(heading) rows = [ ("#4ade80" if window.studio_path else "#eab308", "Studio configured" if window.studio_path else "Studio path required"), ("#6e6e6e", f"Proxy base port {PROXY_PORT}"), ("#4ade80" if active else "#6e6e6e", "Session is running" if active else "Ready to create or join"), ] for color, text in rows: row = QHBoxLayout() row.setSpacing(8) row.addWidget(StatusDot(color, 6)) label = QLabel(text) label.setObjectName("pageSubtitle") row.addWidget(label) row.addStretch() activity.addLayout(row) activity.addStretch() action_shell = QFrame() action_shell.setObjectName("overviewActions") quick = QVBoxLayout() quick.setContentsMargins(18, 0, 0, 0) quick.setSpacing(10) action_shell.setLayout(quick) quick_title = QLabel("Actions") quick_title.setObjectName("sectionTitle") quick.addWidget(quick_title) quick.addSpacing(4) quick_create = AppButton(create_text, "play" if server_active else "create", "secondary") quick_join = AppButton(join_text, "join", "secondary") quick_settings = AppButton("Configure", "settings", "ghost") quick_create.clicked.connect(lambda: window.navigate("create")) quick_join.clicked.connect(lambda: window.navigate("join")) quick_settings.clicked.connect(lambda: window.navigate("settings")) quick.addWidget(quick_create) quick.addWidget(quick_join) if active: quick_stop = AppButton("Stop all sessions", "stop", "danger") quick_stop.clicked.connect(window.stop_everything) quick.addWidget(quick_stop) quick.addSpacing(6) quick.addWidget(quick_settings) quick.addStretch() body.addLayout(activity, 0, 0) body.addWidget(action_shell, 0, 1) self.root.addLayout(body, 1) ----- END FILE: mattslocalhosting-newui0.1/app/pages/overview.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/pages/session.py ----- from __future__ import annotations from PySide6.QtCore import Qt from PySide6.QtWidgets import QGridLayout, QHBoxLayout, QLabel, QProgressBar, QStackedLayout, QVBoxLayout, QWidget from app.pages.base import InfoRows, Page from app.widgets.buttons import AppButton from app.widgets.log_console import LogConsole from app.widgets.status import StatusDot class SessionPage(Page): def __init__( self, window, title: str, subtitle: str, info_pairs: list[tuple[str, str]], stop_callback=None, ) -> None: super().__init__() self.window = window self.stop_callback = stop_callback or window.stop_everything self.info_rows: InfoRows | None = None self.local_join_button: AppButton | None = None self.loading_visible = False status = QHBoxLayout() status.setSpacing(8) self.status_dot = StatusDot("#6e6e6e", 8) self.status_label = QLabel("Initializing") self.status_label.setObjectName("pageSubtitle") status.addWidget(self.status_dot) status.addWidget(self.status_label) self.add_header(title, subtitle, status) self.content_stack = QStackedLayout() self.content_stack.setContentsMargins(0, 0, 0, 0) self.content_stack.setStackingMode(QStackedLayout.StackingMode.StackOne) self.loader_page = QWidget() loader = QVBoxLayout(self.loader_page) loader.setContentsMargins(0, 0, 0, 0) loader.setSpacing(14) loader.addStretch() self.loader_title = QLabel("Setting up") self.loader_title.setObjectName("loaderTitle") self.loader_title.setAlignment(Qt.AlignmentFlag.AlignCenter) self.loader_status = QLabel("Preparing") self.loader_status.setObjectName("loaderStatus") self.loader_status.setAlignment(Qt.AlignmentFlag.AlignCenter) self.loader_progress = QProgressBar() self.loader_progress.setObjectName("loaderProgress") self.loader_progress.setRange(0, 100) self.loader_progress.setValue(0) self.loader_progress.setTextVisible(False) loader.addWidget(self.loader_title) loader.addWidget(self.loader_status) loader.addWidget(self.loader_progress, 0, Qt.AlignmentFlag.AlignCenter) loader.addStretch() loader_actions = QHBoxLayout() loader_actions.addStretch() loader_stop = AppButton("Stop session", "stop", "danger") loader_stop.clicked.connect(self.stop_callback) loader_actions.addWidget(loader_stop) loader.addLayout(loader_actions) self.session_view = QWidget() session_root = QVBoxLayout(self.session_view) session_root.setContentsMargins(0, 0, 0, 0) session_root.setSpacing(18) body = QGridLayout() body.setHorizontalSpacing(28) body.setColumnMinimumWidth(0, 260) body.setColumnStretch(0, 0) body.setColumnStretch(1, 1) left = QVBoxLayout() self.info_rows = InfoRows(info_pairs) left.addWidget(self.info_rows) self.progress_panel = QWidget() progress_layout = QVBoxLayout(self.progress_panel) progress_layout.setContentsMargins(0, 0, 0, 0) progress_layout.setSpacing(6) progress_label = QLabel("Setup") progress_label.setObjectName("sectionTitle") self.progress_status = QLabel("Waiting") self.progress_status.setObjectName("fieldHint") self.progress = QProgressBar() self.progress.setObjectName("sessionProgress") self.progress.setRange(0, 100) self.progress.setValue(0) self.progress.setTextVisible(False) progress_layout.addWidget(progress_label) progress_layout.addWidget(self.progress_status) progress_layout.addWidget(self.progress) self.progress_panel.setVisible(False) left.addWidget(self.progress_panel) self.post_actions = QVBoxLayout() self.post_actions.setSpacing(8) left.addLayout(self.post_actions) left.addStretch() self.console_area = QWidget() right = QVBoxLayout(self.console_area) right.setContentsMargins(0, 0, 0, 0) header = QHBoxLayout() console_label = QLabel("Console") console_label.setObjectName("sectionTitle") header.addWidget(console_label) header.addStretch() header.addWidget(StatusDot("#4ade80", 6)) streaming = QLabel("Streaming") streaming.setObjectName("fieldHint") header.addWidget(streaming) right.addLayout(header) self.console = LogConsole() right.addWidget(self.console, 1) body.addLayout(left, 0, 0) body.addWidget(self.console_area, 0, 1) session_root.addLayout(body, 1) actions = QHBoxLayout() back = AppButton("Back", "back", "ghost") stop = AppButton("Stop session", "stop", "danger") back.clicked.connect(lambda: window.navigate("overview")) stop.clicked.connect(self.stop_callback) actions.addWidget(back) actions.addStretch() actions.addWidget(stop) session_root.addLayout(actions) self.content_stack.addWidget(self.loader_page) self.content_stack.addWidget(self.session_view) self.content_stack.setCurrentWidget(self.session_view) self.root.addLayout(self.content_stack, 1) def append_log(self, message: str, level: str = "info") -> None: self.console.append_log(message, level) def set_status(self, text: str, tone: str) -> None: colors = {"ok": "#4ade80", "info": "#6e6e6e", "warn": "#eab308", "err": "#f87171"} self.status_dot.set_color(colors.get(tone, "#6e6e6e")) self.status_label.setText(text) def set_info(self, key: str, value: str, color: str | None = None) -> None: if self.info_rows: self.info_rows.set_value(key, value, color) def set_progress(self, value: int, text: str) -> None: safe_value = max(0, min(100, value)) self.progress.setValue(safe_value) self.loader_progress.setValue(safe_value) self.progress_status.setText(text) self.loader_status.setText(text) def set_console_visible(self, visible: bool) -> None: self.console_area.setVisible(visible) def set_loading_visible(self, visible: bool) -> None: self.loading_visible = visible self.content_stack.setCurrentWidget(self.loader_page if visible else self.session_view) self.progress_panel.setVisible(False) def add_local_join(self, callback) -> None: if self.local_join_button: return self.local_join_button = AppButton("Join local server", "play", "primary") self.local_join_button.clicked.connect(callback) self.post_actions.addWidget(self.local_join_button) def add_copy_tunnel(self, callback) -> None: if self.info_rows: self.info_rows.add_inline_action("Tunnel", "copy", "Copy tunnel", callback) ----- END FILE: mattslocalhosting-newui0.1/app/pages/session.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/pages/settings.py ----- from __future__ import annotations import os from pathlib import Path from PySide6.QtWidgets import QFileDialog, QHBoxLayout, QLabel, QVBoxLayout from app.pages.base import Page from app.widgets.buttons import AppButton from app.widgets.fields import ReadOnlyPath class SettingsPage(Page): def __init__(self, window) -> None: super().__init__() self.window = window self.add_header("Settings", "Configure the launcher.") form = QVBoxLayout() form.setSpacing(10) label = QLabel("Studio executable") label.setObjectName("fieldLabel") form.addWidget(label) form.addWidget(ReadOnlyPath(window.studio_path)) file_name = Path(window.studio_path).name if window.studio_path else "Not selected" status = QLabel(f"Selected file: {file_name}") status.setObjectName("settingsStatusOk" if file_name == "RobloxStudioBeta.exe" else "settingsStatusWarn") form.addWidget(status) hint = QLabel( "Choose the Studio binary named RobloxStudioBeta.exe. " "It is usually inside AppData\\Local\\Roblox\\Versions\\version-*." ) hint.setObjectName("fieldHint") hint.setWordWrap(True) form.addWidget(hint) path_actions = QHBoxLayout() detect = AppButton("Detect automatically", "refresh", "secondary") browse = AppButton("Choose file", "folder", "primary") clear = AppButton("Clear", "close", "ghost") detect.clicked.connect(window.auto_detect_studio) browse.clicked.connect(self._browse) path_actions.addWidget(browse) path_actions.addWidget(detect) path_actions.addWidget(clear) clear.clicked.connect(window.clear_studio_path) path_actions.addStretch() form.addLayout(path_actions) form.addStretch() self.root.addLayout(form, 1) actions = QHBoxLayout() back = AppButton("Back", "back", "ghost") back.clicked.connect(lambda: window.navigate("overview")) actions.addWidget(back) actions.addStretch() self.root.addLayout(actions) def _browse(self) -> None: start_dir = "" local_appdata = os.environ.get("LOCALAPPDATA", "") versions_dir = Path(local_appdata) / "Roblox" / "Versions" if local_appdata else None if versions_dir and versions_dir.is_dir(): start_dir = str(versions_dir) path, _ = QFileDialog.getOpenFileName( self, "Choose RobloxStudioBeta.exe", start_dir, "Studio executable (RobloxStudioBeta.exe);;Executable (*.exe)", ) if path: self.window.set_studio_path(path) ----- END FILE: mattslocalhosting-newui0.1/app/pages/settings.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/pages/support.py ----- from __future__ import annotations from PySide6.QtCore import Qt, QUrl from PySide6.QtGui import QDesktopServices from PySide6.QtWidgets import QHBoxLayout, QLabel, QVBoxLayout from app.pages.base import Page, divider from app.widgets.buttons import AppButton CREATOR_NAME = "s0m3thing_matters" DISCORD_URL = "https://discord.gg/H3K2xeU96A" class SupportPage(Page): def __init__(self, window) -> None: super().__init__() self.window = window self.add_header("Support", "Contact, credits, and community links.") content = QVBoxLayout() content.setSpacing(14) creator_title = QLabel("Creator") creator_title.setObjectName("sectionTitle") content.addWidget(creator_title) creator = QLabel(CREATOR_NAME) creator.setObjectName("supportName") content.addWidget(creator) content.addWidget(divider()) discord_title = QLabel("Discord") discord_title.setObjectName("sectionTitle") content.addWidget(discord_title) discord_link = QLabel(DISCORD_URL) discord_link.setObjectName("supportLink") discord_link.setTextInteractionFlags(Qt.TextInteractionFlag.TextSelectableByMouse) content.addWidget(discord_link) actions = QHBoxLayout() open_discord = AppButton("Open Discord", "globe", "primary") open_discord.clicked.connect(lambda: QDesktopServices.openUrl(QUrl(DISCORD_URL))) actions.addWidget(open_discord) actions.addStretch() content.addLayout(actions) content.addStretch() self.root.addLayout(content, 1) ----- END FILE: mattslocalhosting-newui0.1/app/pages/support.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/styles/dark.qss ----- * { color: #ededed; font-family: "Segoe UI"; letter-spacing: 0; } QMainWindow, QWidget#root, QWidget#contentRoot { background: #0e0e0e; } QWidget#titleBar { background: #0a0a0a; border-bottom: 1px solid #1f1f1f; } QLabel#windowTitle { color: #ededed; font-weight: 600; font-size: 10pt; } QLabel#muted, QLabel#fieldHint, QLabel#sidebarCaption { color: #6e6e6e; } QLabel#fieldLabel, QLabel#sectionTitle { color: #a1a1a1; font-weight: 500; } QLabel#pageTitle { color: #ededed; font-size: 20pt; font-weight: 650; } QLabel#pageSubtitle { color: #a1a1a1; } QLabel#fieldError { color: #f87171; font-size: 9pt; } QLabel#settingsStatusOk { color: #4ade80; font-size: 9pt; } QLabel#settingsStatusWarn { color: #eab308; font-size: 9pt; } QFrame#sidebar { background: #0e0e0e; border-right: 1px solid #1f1f1f; } QPushButton { border: 0; border-radius: 6px; padding: 6px 12px; min-height: 20px; text-align: center; } QPushButton[variant="primary"] { color: #0a0a0a; background: #ededed; } QPushButton[variant="primary"]:hover { background: #fafafa; } QPushButton[variant="secondary"] { color: #ededed; background: #131313; border: 1px solid #2a2a2a; } QPushButton[variant="secondary"]:hover { background: #1a1a1a; border-color: #3f3f46; } QPushButton[variant="ghost"] { color: #a1a1a1; background: transparent; } QPushButton[variant="ghost"]:hover { color: #ededed; background: #1a1a1a; } QPushButton[variant="danger"] { color: #f87171; background: #131313; border: 1px solid #3a1e1e; } QPushButton[variant="danger"]:hover { background: #1a0e0e; } QPushButton[variant="chrome"] { background: transparent; border-radius: 0; padding: 0; } QPushButton[variant="chrome"]:hover { background: #252525; } QPushButton[variant="chromeDanger"] { background: transparent; border-radius: 0; padding: 0; } QPushButton[variant="chromeDanger"]:hover { background: #7a2222; } QPushButton[variant="inline"] { background: transparent; border-radius: 5px; padding: 0; } QPushButton[variant="inline"]:hover { background: #1a1a1a; } QPushButton[nav="true"] { color: #a1a1a1; background: transparent; text-align: left; padding: 7px 9px; } QPushButton[nav="true"]:hover { color: #ededed; background: #131313; } QPushButton[nav="true"][active="true"] { color: #ededed; background: #1f1f1f; } QFrame#inputShell { background: #131313; border: 1px solid #2a2a2a; border-radius: 6px; min-height: 38px; } QFrame#inputShell[error="true"] { border-color: #f87171; } QLineEdit#lineEdit { background: transparent; color: #ededed; border: 0; padding: 0; selection-background-color: #3f3f46; } QLineEdit#lineEdit:focus { color: #ffffff; } QLabel#pathLabel { color: #ededed; font-family: "Cascadia Mono"; font-size: 9pt; } QFrame#divider { background: #1f1f1f; min-height: 1px; max-height: 1px; } QFrame#metric { background: transparent; } QFrame#overviewActions { border-left: 1px solid #1f1f1f; } QLabel#metricLabel { color: #6e6e6e; font-size: 9pt; } QLabel#metricValue { color: #ededed; font-size: 22pt; font-weight: 400; } QLabel#metricHint { color: #6e6e6e; font-size: 9pt; } QLabel#supportName { color: #ededed; font-size: 15pt; font-weight: 600; } QLabel#supportLink { color: #a1a1a1; font-family: "Cascadia Mono"; font-size: 9pt; } QTextEdit#logConsole { background: #070707; border: 1px solid #1f1f1f; border-radius: 6px; padding: 12px; selection-background-color: #2a2a2a; } QProgressBar#sessionProgress { background: #131313; border: 1px solid #2a2a2a; border-radius: 5px; min-height: 8px; max-height: 8px; } QProgressBar#sessionProgress::chunk { background: #ededed; border-radius: 4px; } QLabel#loaderTitle { color: #ededed; font-size: 18pt; font-weight: 650; } QLabel#loaderStatus { color: #a1a1a1; font-size: 10pt; } QProgressBar#loaderProgress { background: #131313; border: 1px solid #2a2a2a; border-radius: 5px; min-height: 10px; max-height: 10px; min-width: 360px; max-width: 520px; } QProgressBar#loaderProgress::chunk { background: #ededed; border-radius: 4px; } QScrollBar:vertical, QScrollBar:horizontal { background: transparent; border: 0; margin: 2px; } QScrollBar:vertical { width: 10px; } QScrollBar:horizontal { height: 10px; } QScrollBar::handle { background: #2a2a2a; border-radius: 5px; min-height: 28px; } QScrollBar::handle:hover { background: #3f3f46; } QScrollBar::add-line, QScrollBar::sub-line, QScrollBar::add-page, QScrollBar::sub-page { width: 0; height: 0; background: transparent; } QFrame#toast { background: #131313; border: 1px solid #2a2a2a; border-radius: 7px; } QLabel#toastLabel { color: #ededed; font-size: 9pt; } ----- END FILE: mattslocalhosting-newui0.1/app/styles/dark.qss ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/styles/theme.py ----- from __future__ import annotations from pathlib import Path from PySide6.QtGui import QFont from PySide6.QtWidgets import QApplication STYLE_PATH = Path(__file__).with_name("dark.qss") def apply_theme(app: QApplication) -> None: app.setStyle("Fusion") app.setFont(QFont("Segoe UI", 10)) app.setStyleSheet(STYLE_PATH.read_text(encoding="utf-8")) ----- END FILE: mattslocalhosting-newui0.1/app/styles/theme.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/ui/__init__.py ----- """Application shell and chrome.""" ----- END FILE: mattslocalhosting-newui0.1/app/ui/__init__.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/ui/sidebar.py ----- from __future__ import annotations from PySide6.QtCore import Signal, QSize from PySide6.QtWidgets import QFrame, QLabel, QPushButton, QVBoxLayout from app.widgets.icons import app_icon class NavButton(QPushButton): def __init__(self, key: str, text: str, icon: str) -> None: super().__init__(text) self.key = key self.icon_name = icon self.default_text = text self.default_icon = icon self.setProperty("nav", True) self.setProperty("active", False) self.setIcon(app_icon(icon, "#a1a1a1")) self.setIconSize(QSize(15, 15)) self.setMinimumHeight(32) def set_active(self, active: bool) -> None: self.setProperty("active", active) self.setIcon(app_icon(self.icon_name, "#ededed" if active else "#a1a1a1")) self.style().unpolish(self) self.style().polish(self) def set_content(self, text: str, icon: str) -> None: self.icon_name = icon self.setText(text) self.setIcon(app_icon(icon, "#ededed" if self.property("active") else "#a1a1a1")) def reset_content(self) -> None: self.set_content(self.default_text, self.default_icon) class Sidebar(QFrame): navigate = Signal(str) def __init__(self) -> None: super().__init__() self.setObjectName("sidebar") self.setFixedWidth(220) self._buttons: dict[str, NavButton] = {} root = QVBoxLayout(self) root.setContentsMargins(12, 16, 12, 12) root.setSpacing(4) caption = QLabel("Workspace") caption.setObjectName("sidebarCaption") root.addWidget(caption) title = QLabel("LocalHost") title.setObjectName("windowTitle") root.addWidget(title) root.addSpacing(12) for key, label, icon in ( ("overview", "Overview", "home"), ("create", "Create", "create"), ("join", "Join", "join"), ): self._add_nav(root, key, label, icon) divider = QFrame() divider.setObjectName("divider") root.addSpacing(12) root.addWidget(divider) root.addSpacing(8) self._add_nav(root, "settings", "Settings", "settings") self._add_nav(root, "support", "Support", "globe") root.addStretch() self.set_session(False) def _add_nav(self, layout: QVBoxLayout, key: str, label: str, icon: str) -> None: button = NavButton(key, label, icon) button.clicked.connect(lambda checked=False, k=key: self.navigate.emit(k)) self._buttons[key] = button layout.addWidget(button) def set_current(self, key: str) -> None: for nav_key, button in self._buttons.items(): button.set_active(nav_key == key) def set_session( self, active: bool, text: str = "No session", mode: str | None = None, active_modes: set[str] | None = None, ) -> None: self._buttons["create"].reset_content() self._buttons["join"].reset_content() modes = active_modes or ({mode} if mode else set()) if active and "create" in modes: self._buttons["create"].set_content("Server", "play") if active and "join" in modes: self._buttons["join"].set_content("Connection", "join") ----- END FILE: mattslocalhosting-newui0.1/app/ui/sidebar.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/ui/splash.py ----- from __future__ import annotations from PySide6.QtCore import QEasingCurve, QPropertyAnimation, Qt, QTimer, Signal from PySide6.QtWidgets import QLabel, QProgressBar, QVBoxLayout, QWidget class StartupSplash(QWidget): finished = Signal() def __init__(self) -> None: super().__init__() self.setWindowFlags( Qt.WindowType.FramelessWindowHint | Qt.WindowType.WindowStaysOnTopHint | Qt.WindowType.Tool ) self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground) self.setFixedSize(380, 170) self._value = 0 self.panel = QWidget(self) self.panel.setObjectName("splashPanel") self.panel.setGeometry(0, 0, self.width(), self.height()) layout = QVBoxLayout(self.panel) layout.setContentsMargins(28, 24, 28, 24) layout.setSpacing(12) title = QLabel("LocalHost") title.setObjectName("splashTitle") status = QLabel("Loading workspace") status.setObjectName("splashStatus") self.progress = QProgressBar() self.progress.setRange(0, 100) self.progress.setTextVisible(False) self.progress.setObjectName("splashProgress") layout.addStretch() layout.addWidget(title) layout.addWidget(status) layout.addWidget(self.progress) layout.addStretch() self.setStyleSheet( """ QWidget#splashPanel { background: #0e0e0e; border: 1px solid #2a2a2a; border-radius: 8px; } QLabel#splashTitle { color: #ededed; font-family: "Segoe UI"; font-size: 20pt; font-weight: 650; } QLabel#splashStatus { color: #a1a1a1; font-family: "Segoe UI"; font-size: 9pt; } QProgressBar#splashProgress { background: #171717; border: 1px solid #2a2a2a; border-radius: 5px; min-height: 8px; max-height: 8px; } QProgressBar#splashProgress::chunk { background: #ededed; border-radius: 4px; } """ ) self.timer = QTimer(self) self.timer.timeout.connect(self._tick) def start(self) -> None: self._center() self.show() self.timer.start(24) def _center(self) -> None: screen = self.screen() if not screen: return geo = screen.availableGeometry() self.move( geo.x() + (geo.width() - self.width()) // 2, geo.y() + (geo.height() - self.height()) // 2, ) def _tick(self) -> None: if self._value < 72: self._value += 4 elif self._value < 94: self._value += 2 else: self._value += 1 self.progress.setValue(min(self._value, 100)) if self._value >= 100: self.timer.stop() self._fade_out() def _fade_out(self) -> None: self.anim = QPropertyAnimation(self, b"windowOpacity", self) self.anim.setDuration(160) self.anim.setStartValue(1.0) self.anim.setEndValue(0.0) self.anim.setEasingCurve(QEasingCurve.Type.OutCubic) self.anim.finished.connect(self.finished.emit) self.anim.start(QPropertyAnimation.DeletionPolicy.DeleteWhenStopped) ----- END FILE: mattslocalhosting-newui0.1/app/ui/splash.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/ui/title_bar.py ----- from __future__ import annotations from PySide6.QtCore import Signal, Qt from PySide6.QtWidgets import QHBoxLayout, QLabel, QWidget from app.widgets.buttons import IconButton from app.widgets.status import StatusDot class TitleBar(QWidget): minimize_requested = Signal() maximize_requested = Signal() close_requested = Signal() def __init__(self) -> None: super().__init__() self.setObjectName("titleBar") self.setFixedHeight(36) layout = QHBoxLayout(self) layout.setContentsMargins(16, 0, 0, 0) layout.setSpacing(12) title = QLabel("LocalHost") title.setObjectName("windowTitle") layout.addWidget(title) self.status_dot = StatusDot("#6e6e6e", 6) layout.addWidget(self.status_dot) self.status_label = QLabel("Idle") self.status_label.setObjectName("muted") layout.addWidget(self.status_label) layout.addStretch() self.min_button = IconButton("minimize", "Minimize") self.max_button = IconButton("square", "Maximize") self.close_button = IconButton("close", "Close", "chromeDanger") layout.addWidget(self.min_button) layout.addWidget(self.max_button) layout.addWidget(self.close_button) self.min_button.clicked.connect(self.minimize_requested) self.max_button.clicked.connect(self.maximize_requested) self.close_button.clicked.connect(self.close_requested) def set_status(self, text: str, color: str, strong: bool = False) -> None: self.status_dot.set_color(color) self.status_label.setText(text) self.status_label.setStyleSheet(f"color: {'#ededed' if strong else '#a1a1a1'};") def is_control_at(self, global_pos) -> bool: widget = self.childAt(self.mapFromGlobal(global_pos)) return widget in {self.min_button, self.max_button, self.close_button} def mouseDoubleClickEvent(self, event) -> None: if event.button() == Qt.MouseButton.LeftButton: self.maximize_requested.emit() super().mouseDoubleClickEvent(event) ----- END FILE: mattslocalhosting-newui0.1/app/ui/title_bar.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/ui/window.py ----- from __future__ import annotations import ctypes import os from pathlib import Path from ctypes import wintypes import shiboken6 from PySide6.QtCore import QMetaObject, QPoint, Qt, QThread, Slot from PySide6.QtGui import QCloseEvent from PySide6.QtWidgets import ( QApplication, QFileDialog, QHBoxLayout, QMainWindow, QMessageBox, QStackedWidget, QVBoxLayout, QWidget, ) from app.core.config import WINDOW_H, WINDOW_MIN_H, WINDOW_MIN_W, WINDOW_W from app.core.proxy import proxy from app.core.settings import AppSettings, SettingsStore from app.core.studio import ( get_studio_path, has_running_processes, launch_client, open_place_file, stop_all_roblox_processes, stop_roblox_processes, ) from app.core.tasks import HostSessionWorker, JoinSessionWorker from app.pages.create import CreatePage from app.pages.join import JoinPage from app.pages.overview import OverviewPage from app.pages.session import SessionPage from app.pages.settings import SettingsPage from app.pages.support import SupportPage from app.ui.sidebar import Sidebar from app.ui.title_bar import TitleBar from app.widgets.toast import Toast class MainWindow(QMainWindow): BORDER = 8 def __init__(self) -> None: super().__init__() self.setWindowTitle("LocalHost") self.resize(WINDOW_W, WINDOW_H) self.setMinimumSize(WINDOW_MIN_W, WINDOW_MIN_H) self.setWindowFlags( Qt.WindowType.Window | Qt.WindowType.FramelessWindowHint | Qt.WindowType.WindowMinimizeButtonHint | Qt.WindowType.WindowMaximizeButtonHint ) self.setAttribute(Qt.WidgetAttribute.WA_NativeWindow) self.store = SettingsStore() self.settings: AppSettings = self.store.load() self.studio_path = self._initial_studio_path() self.mode: str | None = None self.running = False self.current_key = "overview" self.active_modes: set[str] = set() self.session_pages: dict[str, SessionPage] = {} self.host_session_guids: tuple[str, str] | None = None self.workers: dict[str, object] = {} self.worker_threads: dict[str, QThread] = {} self._toast: Toast | None = None self._build_shell() self.navigate("overview") self.update_session_status() def _build_shell(self) -> None: root = QWidget() root.setObjectName("root") self.setCentralWidget(root) outer = QVBoxLayout(root) outer.setContentsMargins(0, 0, 0, 0) outer.setSpacing(0) self.title_bar = TitleBar() self.title_bar.minimize_requested.connect(self.showMinimized) self.title_bar.maximize_requested.connect(self.toggle_maximize) self.title_bar.close_requested.connect(self.close) outer.addWidget(self.title_bar) body = QWidget() body.setObjectName("contentRoot") body_layout = QHBoxLayout(body) body_layout.setContentsMargins(0, 0, 0, 0) body_layout.setSpacing(0) self.sidebar = Sidebar() self.sidebar.navigate.connect(self.navigate) body_layout.addWidget(self.sidebar) self.stack = QStackedWidget() body_layout.addWidget(self.stack, 1) outer.addWidget(body, 1) def showEvent(self, event) -> None: super().showEvent(event) self._enable_windows_backdrop() def _initial_studio_path(self) -> str: saved = self.settings.studio_path if saved and Path(saved).is_file(): return saved path = get_studio_path() if path: self.settings = self.store.update(self.settings, studio_path=path) return path def navigate(self, key: str) -> None: if key == "create" and key in self.session_pages: self._show_session_page(key) return if key == "join" and key in self.session_pages: self._show_session_page(key) return self.current_key = key self.sidebar.set_current(key) builders = { "overview": lambda: OverviewPage(self), "create": lambda: CreatePage(self), "join": lambda: JoinPage(self), "settings": lambda: SettingsPage(self), "support": lambda: SupportPage(self), } builder = builders.get(key, builders["overview"]) self._set_page(builder()) def _set_page(self, page: QWidget) -> None: old = self.stack.currentWidget() if self.stack.indexOf(page) == -1: self.stack.addWidget(page) self.stack.setCurrentWidget(page) if old and old not in self.session_pages.values(): self.stack.removeWidget(old) old.deleteLater() def _show_session_page(self, nav_key: str) -> None: page = self.session_pages.get(nav_key) if not page: return self.current_key = nav_key self.sidebar.set_current(nav_key) self._set_page(page) def update_session_status(self) -> None: active = self.session_active() if active: if {"create", "join"}.issubset(self.active_modes): text = "Server + proxy active" elif "create" in self.active_modes: text = "Server live" elif "join" in self.active_modes: text = "Proxy active" else: text = "Active" self.title_bar.set_status(text, "#4ade80", True) self.sidebar.set_session(True, text, self.mode, self.active_modes) elif self.studio_path and Path(self.studio_path).is_file(): self.title_bar.set_status("Ready", "#6e6e6e") self.sidebar.set_session(False, mode=self.mode) else: self.title_bar.set_status("Studio not configured", "#eab308") self.sidebar.set_session(False, mode=self.mode) def session_active(self) -> bool: return bool(self.active_modes) or proxy.is_running or has_running_processes() def ensure_studio_path(self) -> str: if self.studio_path and Path(self.studio_path).is_file(): return self.studio_path path = get_studio_path() if not path: path, _ = QFileDialog.getOpenFileName( self, "Select RobloxStudioBeta.exe", "", "Studio (RobloxStudioBeta.exe);;Executable (*.exe);;All files (*.*)", ) if path and Path(path).is_file(): self.set_studio_path(path, navigate=False) return path return "" def set_studio_path(self, path: str, navigate: bool = True) -> None: candidate = Path(path) if not candidate.is_file(): self.toast("Selected Studio path does not exist.", "error") return if candidate.name.lower() != "robloxstudiobeta.exe": self.toast("Choose RobloxStudioBeta.exe, not another executable.", "error") return self.studio_path = str(candidate) self.settings = self.store.update(self.settings, studio_path=str(candidate)) self.toast("Studio path saved.", "success") self.update_session_status() if navigate: self.navigate("settings") def clear_studio_path(self) -> None: self.studio_path = "" self.settings = self.store.update(self.settings, studio_path="") self.toast("Studio path cleared.", "info") self.update_session_status() self.navigate("settings") def auto_detect_studio(self) -> None: path = get_studio_path() if path: self.set_studio_path(path) else: self.toast("Studio not found. Use Browse instead.", "warning") def create_session(self, user_id: str, tunnel: str, port: str, place_path: str = "") -> None: if "create" in self.session_pages: self.toast("Server is already active.", "warning") return studio = self.ensure_studio_path() if not studio: self.toast("Cannot locate RobloxStudioBeta.exe.", "error") return self.settings = self.store.update( self.settings, user_id=user_id, host_tunnel=tunnel, server_port=port, place_path=place_path, ) self.mode = "create" self.running = True self.active_modes.add("create") info = [ ("Mode", "Server (host)"), ("User ID", user_id), ("Port", port), ("Tunnel", tunnel or "-"), ("Map", Path(place_path).name if place_path else "-"), ] page = SessionPage(self, "Server", "Local Studio server.", info, lambda: self.stop_session("create")) self.session_pages["create"] = page page.set_loading_visible(True) page.set_console_visible(False) self._set_page(page) if tunnel: page.add_copy_tunnel( lambda checked=False, value=tunnel: self.copy_to_clipboard(value, "Tunnel copied.") ) self.sidebar.set_current("create") self.update_session_status() worker = HostSessionWorker( studio, user_id, port, place_path, ) self.host_session_guids = (worker.parent_guid, worker.play_guid) worker.log.connect(self._worker_log) worker.status.connect(self._worker_status) worker.progress.connect(self._worker_progress) self._start_worker("create", worker) def open_place_file(self, place_path: str) -> None: try: open_place_file(place_path) self.settings = self.store.update(self.settings, place_path=place_path) self.toast("Map launched in Roblox Studio.", "success") except Exception as exc: self.toast(f"Map launch failed: {exc}", "error") def join_session(self, host: str, port: int, raw: str) -> None: if "join" in self.session_pages: self.toast("Connection is already active.", "warning") return studio = self.ensure_studio_path() if not studio: self.toast("Cannot locate RobloxStudioBeta.exe.", "error") return self.settings = self.store.update(self.settings, join_tunnel=raw) if self._matches_active_host_tunnel(host, port, raw): self._join_active_host_locally(studio, raw) return self.mode = "join" self.running = True self.active_modes.add("join") info = [ ("Mode", "Client (join)"), ("Target host", host), ("Target port", str(port)), ("Local proxy", "127.0.0.1:pending"), ("Status", "Initializing"), ] page = SessionPage(self, "Connection", "UDP proxy and Studio client.", info, lambda: self.stop_session("join")) self.session_pages["join"] = page self._set_page(page) self.sidebar.set_current("join") self.update_session_status() worker = JoinSessionWorker(studio, host, port) worker.log.connect(self._worker_log) worker.status.connect(self._worker_status) worker.info_changed.connect(self._worker_info) self._start_worker("join", worker) def _matches_active_host_tunnel(self, host: str, port: int, raw: str) -> bool: if "create" not in self.active_modes or not self.host_session_guids: return False host_tunnel = self.settings.host_tunnel.strip() if not host_tunnel: return False if raw.strip().lower() == host_tunnel.lower(): return True if ":" not in host_tunnel: return False active_host, active_port = host_tunnel.rsplit(":", 1) return host.strip().lower() == active_host.strip().lower() and str(port) == active_port.strip() def _join_active_host_locally(self, studio: str, raw: str) -> None: if not self.host_session_guids: self.toast("Local server session is not ready.", "error") return parent_guid, play_guid = self.host_session_guids server_port = self.settings.server_port self.mode = "join" self.running = True self.active_modes.add("join") info = [ ("Mode", "Client (local host)"), ("Target host", "127.0.0.1"), ("Target port", server_port), ("Local proxy", "not used"), ("Status", "Launching"), ] page = SessionPage( self, "Connection", "Direct client to active local server.", info, lambda: self.stop_session("join"), ) self.session_pages["join"] = page self._set_page(page) self.sidebar.set_current("join") self.update_session_status() try: page.append_log(f"Detected active host tunnel {raw}; using local server", "info") launch_client( studio, "127.0.0.1", server_port, parent_guid, play_guid, "StudioPlayer_Host", session_key="join", ) page.set_info("Status", "Connected locally", "#4ade80") page.set_status("Connected locally", "ok") page.append_log("Studio client launched", "success") self.toast("Local client launched.", "success") except Exception as exc: self.active_modes.discard("join") self.session_pages.pop("join", None) self.stack.removeWidget(page) page.deleteLater() self.update_session_status() self.toast(f"Launch error: {exc}", "error") def _start_worker(self, mode: str, worker) -> None: existing = self.worker_threads.get(mode) if existing and shiboken6.isValid(existing): existing.quit() existing.wait(500) self.worker_threads.pop(mode, None) self.workers.pop(mode, None) thread = QThread(self) thread.setProperty("sessionMode", mode) worker.setProperty("sessionMode", mode) worker.moveToThread(thread) thread.started.connect(worker.run) worker.finished.connect(thread.quit) worker.finished.connect(worker.deleteLater) thread.finished.connect(self._worker_thread_finished) thread.finished.connect(thread.deleteLater) thread.start() self.workers[mode] = worker self.worker_threads[mode] = thread @Slot() def _worker_thread_finished(self, mode: str | None = None) -> None: if not mode: mode = self._sender_mode() if not mode: return page = self.session_pages.get(mode) if page and page.loading_visible: page.set_progress(100, "Ready") page.set_loading_visible(False) page.set_console_visible(True) self.worker_threads.pop(mode, None) self.workers.pop(mode, None) def _sender_mode(self) -> str | None: sender = self.sender() if sender is None: return None mode = sender.property("sessionMode") return str(mode) if mode else None @Slot(str, str) def _worker_log(self, message: str, level: str) -> None: mode = self._sender_mode() if mode: self._session_log(mode, message, level) @Slot(str, str) def _worker_status(self, text: str, tone: str) -> None: mode = self._sender_mode() if mode: self._session_status(mode, text, tone) @Slot(str, str) def _worker_info(self, key: str, value: str) -> None: mode = self._sender_mode() if mode: self._session_info(mode, key, value) @Slot(int, str) def _worker_progress(self, value: int, text: str) -> None: mode = self._sender_mode() if mode: self._session_progress(mode, value, text) def _session_log(self, mode: str, message: str, level: str) -> None: page = self.session_pages.get(mode) if page: page.append_log(message, level) def _session_status(self, mode: str, text: str, tone: str) -> None: if tone == "err": self.active_modes.discard(mode) if mode == "create": self.host_session_guids = None if not self.active_modes: self.running = False page = self.session_pages.get(mode) if page: page.set_status(text, tone) if tone in {"ok", "err"} and page.loading_visible: page.set_progress(100, text) page.set_loading_visible(False) page.set_console_visible(True) self.update_session_status() def _session_info(self, mode: str, key: str, value: str) -> None: page = self.session_pages.get(mode) if page: page.set_info(key, value, "#4ade80" if key == "Status" else None) def _session_progress(self, mode: str, value: int, text: str) -> None: page = self.session_pages.get(mode) if page: page.set_progress(value, text) if value >= 100: page.set_loading_visible(False) page.set_console_visible(True) def _add_local_join(self, port: str, parent_guid: str, play_guid: str) -> None: page = self.session_pages.get("create") if page: page.add_local_join(lambda: self.join_local(port, parent_guid, play_guid)) def join_local(self, port: str, parent_guid: str, play_guid: str) -> None: try: studio = self.ensure_studio_path() if not studio: self.toast("Cannot locate RobloxStudioBeta.exe.", "error") return launch_client( studio, "127.0.0.1", port, parent_guid, play_guid, "StudioPlayer_Host", session_key="create", ) self.toast("Local client launched.", "success") except Exception as exc: self.toast(f"Launch error: {exc}", "error") def stop_session(self, mode: str) -> None: worker = self.workers.get(mode) if worker and shiboken6.isValid(worker) and hasattr(worker, "stop"): QMetaObject.invokeMethod(worker, "stop", Qt.ConnectionType.QueuedConnection) if mode == "join": proxy.stop(wait=False) if mode == "create": self.host_session_guids = None killed = stop_roblox_processes(mode) self.active_modes.discard(mode) self.running = bool(self.active_modes) self.mode = next(iter(self.active_modes), None) page = self.session_pages.pop(mode, None) if page: self.stack.removeWidget(page) page.deleteLater() self.toast(f"Session stopped. {killed} process(es) terminated.", "success") self.update_session_status() next_mode = next(iter(self.active_modes), None) if next_mode and next_mode in self.session_pages: self._show_session_page(next_mode) else: self.navigate("overview") def stop_everything(self) -> None: for worker in list(self.workers.values()): if shiboken6.isValid(worker) and hasattr(worker, "stop"): QMetaObject.invokeMethod(worker, "stop", Qt.ConnectionType.QueuedConnection) proxy.stop(wait=False) killed = stop_all_roblox_processes() self.running = False self.mode = None self.active_modes.clear() self.host_session_guids = None for page in list(self.session_pages.values()): self.stack.removeWidget(page) page.deleteLater() self.session_pages.clear() self.toast(f"Session stopped. {killed} process(es) terminated.", "success") self.update_session_status() self.navigate("overview") def toast(self, text: str, tone: str = "info") -> None: if self._toast: try: self._toast.deleteLater() except RuntimeError: pass self._toast = None self._toast = Toast(text, tone, self) toast = self._toast toast.destroyed.connect(lambda: self._clear_toast_ref(toast)) self._position_toast() self._toast.show_animated() def copy_to_clipboard(self, text: str, message: str = "Copied.") -> None: QApplication.clipboard().setText(text) self.toast(message, "success") def _clear_toast_ref(self, toast: Toast) -> None: if self._toast is toast: self._toast = None def resizeEvent(self, event) -> None: super().resizeEvent(event) self._position_toast() def _position_toast(self) -> None: if not self._toast: return self._toast.adjustSize() x = (self.width() - self._toast.width()) // 2 y = self.height() - self._toast.height() - 22 self._toast.move(max(12, x), max(12, y)) def toggle_maximize(self) -> None: if self.isMaximized(): self.showNormal() else: self.showMaximized() def nativeEvent(self, event_type, message): if os.name != "nt": return False, 0 if event_type not in (b"windows_generic_MSG", "windows_generic_MSG"): return False, 0 msg = wintypes.MSG.from_address(int(message)) WM_NCHITTEST = 0x0084 if msg.message != WM_NCHITTEST: return False, 0 x = ctypes.c_short(msg.lParam & 0xFFFF).value y = ctypes.c_short((msg.lParam >> 16) & 0xFFFF).value pos = self.mapFromGlobal(QPoint(x, y)) width = self.width() height = self.height() border = 0 if self.isMaximized() else self.BORDER HTCLIENT = 1 HTCAPTION = 2 HTLEFT = 10 HTRIGHT = 11 HTTOP = 12 HTTOPLEFT = 13 HTTOPRIGHT = 14 HTBOTTOM = 15 HTBOTTOMLEFT = 16 HTBOTTOMRIGHT = 17 if border: left = pos.x() < border right = pos.x() >= width - border top = pos.y() < border bottom = pos.y() >= height - border if top and left: return True, HTTOPLEFT if top and right: return True, HTTOPRIGHT if bottom and left: return True, HTBOTTOMLEFT if bottom and right: return True, HTBOTTOMRIGHT if left: return True, HTLEFT if right: return True, HTRIGHT if top: return True, HTTOP if bottom: return True, HTBOTTOM if 0 <= pos.y() <= self.title_bar.height() and not self.title_bar.is_control_at(QPoint(x, y)): return True, HTCAPTION return False, HTCLIENT def _enable_windows_backdrop(self) -> None: if os.name != "nt": return try: hwnd = int(self.winId()) dwm = ctypes.windll.dwmapi value = ctypes.c_int(1) for attr in (20, 19): dwm.DwmSetWindowAttribute(hwnd, attr, ctypes.byref(value), ctypes.sizeof(value)) backdrop = ctypes.c_int(2) dwm.DwmSetWindowAttribute(hwnd, 38, ctypes.byref(backdrop), ctypes.sizeof(backdrop)) except Exception: pass def closeEvent(self, event: QCloseEvent) -> None: if self.session_active(): reply = QMessageBox.question( self, "Quit LocalHost", "Stop active sessions and quit?", QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No, QMessageBox.StandardButton.Yes, ) if reply != QMessageBox.StandardButton.Yes: event.ignore() return proxy.stop(wait=False) stop_all_roblox_processes() event.accept() ----- END FILE: mattslocalhosting-newui0.1/app/ui/window.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/widgets/__init__.py ----- """Reusable Qt widgets.""" ----- END FILE: mattslocalhosting-newui0.1/app/widgets/__init__.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/widgets/buttons.py ----- from __future__ import annotations from PySide6.QtCore import QSize from PySide6.QtWidgets import QPushButton from app.widgets.icons import app_icon class AppButton(QPushButton): def __init__(self, text: str, icon: str | None = None, variant: str = "secondary") -> None: super().__init__(text) self.setProperty("variant", variant) self.setCursor(QtCursor.pointing_hand()) self.setMinimumHeight(32) if icon: color = { "primary": "#0a0a0a", "danger": "#f87171", "ghost": "#a1a1a1", }.get(variant, "#ededed") self.setIcon(app_icon(icon, color)) self.setIconSize(QSize(15, 15)) class IconButton(QPushButton): def __init__(self, icon: str, tooltip: str, variant: str = "chrome") -> None: super().__init__() self.setProperty("variant", variant) self.setCursor(QtCursor.pointing_hand()) self.setIcon(app_icon(icon, "#ededed" if variant == "chromeDanger" else "#a1a1a1")) self.setIconSize(QSize(13, 13)) self.setToolTip(tooltip) self.setFixedSize(28 if variant == "inline" else 42, 28 if variant == "inline" else 34) class QtCursor: @staticmethod def pointing_hand(): from PySide6.QtCore import Qt return Qt.CursorShape.PointingHandCursor ----- END FILE: mattslocalhosting-newui0.1/app/widgets/buttons.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/widgets/fields.py ----- from __future__ import annotations from collections.abc import Callable from PySide6.QtCore import Qt from PySide6.QtWidgets import QFrame, QHBoxLayout, QLabel, QLineEdit, QVBoxLayout from app.widgets.icons import app_icon Validator = Callable[[str], str | None] class FormField(QFrame): def __init__( self, label: str, value: str = "", hint: str = "", placeholder: str = "", icon: str | None = None, validator: Validator | None = None, ) -> None: super().__init__() self.validator = validator self.setObjectName("formField") root = QVBoxLayout(self) root.setContentsMargins(0, 0, 0, 0) root.setSpacing(7) head = QHBoxLayout() head.setContentsMargins(0, 0, 0, 0) self.label = QLabel(label) self.label.setObjectName("fieldLabel") self.error = QLabel("") self.error.setObjectName("fieldError") head.addWidget(self.label) head.addStretch() head.addWidget(self.error) root.addLayout(head) self.input_shell = QFrame() self.input_shell.setObjectName("inputShell") input_layout = QHBoxLayout(self.input_shell) input_layout.setContentsMargins(12, 0, 12, 0) input_layout.setSpacing(9) if icon: icon_label = QLabel() icon_label.setPixmap(app_icon(icon, "#6e6e6e").pixmap(15, 15)) icon_label.setObjectName("fieldIcon") input_layout.addWidget(icon_label) self.edit = QLineEdit() self.edit.setText(value) self.edit.setPlaceholderText(placeholder) self.edit.setObjectName("lineEdit") self.edit.textChanged.connect(lambda _: self.validate()) input_layout.addWidget(self.edit) root.addWidget(self.input_shell) if hint: hint_label = QLabel(hint) hint_label.setObjectName("fieldHint") hint_label.setWordWrap(True) root.addWidget(hint_label) def value(self) -> str: return self.edit.text().strip() def validate(self) -> bool: if not self.validator: self._set_error("") return True value = self.value() if not value: self._set_error("") return True error = self.validator(value) self._set_error(error or "") return error is None def _set_error(self, text: str) -> None: self.error.setText(text) self.input_shell.setProperty("error", bool(text)) self.input_shell.style().unpolish(self.input_shell) self.input_shell.style().polish(self.input_shell) class ReadOnlyPath(QFrame): def __init__(self, path: str, icon: str = "folder") -> None: super().__init__() self.setObjectName("inputShell") layout = QHBoxLayout(self) layout.setContentsMargins(12, 0, 12, 0) layout.setSpacing(9) icon_label = QLabel() icon_label.setPixmap(app_icon(icon, "#6e6e6e").pixmap(15, 15)) layout.addWidget(icon_label) label = QLabel(path or "Not configured") label.setTextInteractionFlags(Qt.TextInteractionFlag.TextSelectableByMouse) label.setObjectName("pathLabel") layout.addWidget(label, 1) ----- END FILE: mattslocalhosting-newui0.1/app/widgets/fields.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/widgets/icons.py ----- from __future__ import annotations from pathlib import Path from PySide6.QtCore import QSize from PySide6.QtGui import QIcon, QPixmap from app.core.config import ICONS_DIR ICON_MAP = { "home": "house", "create": "plus", "join": "arrow-left-right", "settings": "settings", "play": "play", "stop": "square", "back": "arrow-left", "next": "arrow-right", "minimize": "minus", "close": "x", "folder": "folder", "copy": "copy", "refresh": "refresh-cw", "user": "user", "globe": "globe", "network": "network", "search": "search", } def icon_path(name: str) -> Path: filename = ICON_MAP.get(name, name) return ICONS_DIR / f"{filename}.svg" def app_icon(name: str, color: str = "#a1a1a1", size: int = 20) -> QIcon: path = icon_path(name) if not path.exists(): return QIcon() try: svg = path.read_text(encoding="utf-8").replace("currentColor", color) pixmap = QPixmap() if pixmap.loadFromData(svg.encode("utf-8"), "SVG"): return QIcon(pixmap.scaled(size, size)) except Exception: pass return QIcon(str(path)) def icon_size(size: int = 16) -> QSize: return QSize(size, size) ----- END FILE: mattslocalhosting-newui0.1/app/widgets/icons.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/widgets/log_console.py ----- from __future__ import annotations import time from PySide6.QtGui import QTextCharFormat, QColor, QTextCursor, QFont from PySide6.QtWidgets import QTextEdit class LogConsole(QTextEdit): COLORS = { "info": "#a1a1a1", "success": "#4ade80", "warning": "#eab308", "error": "#f87171", "ts": "#4a4a4a", } def __init__(self) -> None: super().__init__() self.setReadOnly(True) self.setObjectName("logConsole") self.setLineWrapMode(QTextEdit.LineWrapMode.NoWrap) self.setFont(QFont("Cascadia Mono", 9)) def append_log(self, message: str, level: str = "info") -> None: cursor = self.textCursor() cursor.movePosition(QTextCursor.MoveOperation.End) self.setTextCursor(cursor) self._insert(f"[{time.strftime('%H:%M:%S')}] ", "ts") self._insert(f"{message}\n", level) self.moveCursor(QTextCursor.MoveOperation.End) def _insert(self, text: str, level: str) -> None: fmt = QTextCharFormat() fmt.setForeground(QColor(self.COLORS.get(level, self.COLORS["info"]))) cursor = self.textCursor() cursor.setCharFormat(fmt) cursor.insertText(text) ----- END FILE: mattslocalhosting-newui0.1/app/widgets/log_console.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/widgets/status.py ----- from __future__ import annotations from PySide6.QtCore import QSize from PySide6.QtWidgets import QLabel class StatusDot(QLabel): def __init__(self, color: str = "#6e6e6e", size: int = 8) -> None: super().__init__() self._size = size self.setFixedSize(QSize(size, size)) self.set_color(color) def set_color(self, color: str) -> None: radius = self._size // 2 self.setStyleSheet( f"background: {color}; border-radius: {radius}px; min-width: {self._size}px; min-height: {self._size}px;" ) ----- END FILE: mattslocalhosting-newui0.1/app/widgets/status.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/app/widgets/toast.py ----- from __future__ import annotations from PySide6.QtCore import QTimer, Qt from PySide6.QtWidgets import QHBoxLayout, QLabel, QFrame from app.widgets.status import StatusDot class Toast(QFrame): COLORS = { "info": "#ededed", "success": "#4ade80", "warning": "#eab308", "error": "#f87171", } def __init__(self, text: str, tone: str = "info", parent=None) -> None: super().__init__(parent) self.setObjectName("toast") self.setAttribute(Qt.WidgetAttribute.WA_TransparentForMouseEvents) layout = QHBoxLayout(self) layout.setContentsMargins(12, 8, 14, 8) layout.setSpacing(8) layout.addWidget(StatusDot(self.COLORS.get(tone, self.COLORS["info"]), 7)) label = QLabel(text) label.setObjectName("toastLabel") layout.addWidget(label) self._dismiss_started = False def show_animated(self, duration: int = 2800) -> None: self.show() QTimer.singleShot(duration, self.dismiss) def dismiss(self) -> None: if self._dismiss_started: return self._dismiss_started = True self.hide() self.deleteLater() ----- END FILE: mattslocalhosting-newui0.1/app/widgets/toast.py ----- ----- BEGIN FILE: mattslocalhosting-newui0.1/main.py ----- from app.main import main if __name__ == "__main__": raise SystemExit(main()) ----- END FILE: mattslocalhosting-newui0.1/main.py -----

Suy nghĩ

Planning the implementation map

I’m treating the supplied code as the complete source material and will produce a Markdown artifact that explains architecture, data flow, state transitions, UI behavior, networking assumptions, and reimplementation details without relying on hidden context.

Planned the implementation map

Trả lời

I’ll treat the standalone Tkinter app and the modular PySide6 app as two related implementations of the same product concept, then derive a language-neutral specification from both. I’ll also separate “what the tool actually does” from assumptions implied by the UI/README, because that distinction is central to reimplementing it correctly.

Suy nghĩ

Auditing proxy behavior

I’m identifying runtime risks: stale closure references, unrestricted peer acceptance, unbounded sessions, oversized datagrams, and warmup traffic that may not establish mappings for later sockets.

Audited proxy behavior

Searched 4 websites

Trả lời

The core architecture is already clear: this is not a tunnel service or a VPN. It is an orchestrator plus an asymmetric UDP bridge—the host launches Studio’s local multiplayer server and relies on an external UDP tunnel, while the joiner makes Studio talk to 127.0.0.1 and transparently relays those datagrams to the tunnel endpoint. The “host tunnel address” is mostly metadata; the program does not provision or operate that external tunnel.

Suy nghĩ

Searched 5 websites

Trả lời

Two especially important design findings will be called out prominently in the document. First, the Studio launch path depends on several internal/undocumented command-line arguments, which Roblox explicitly says may change without notice; second, the “UDP warm-up” is not a general NAT guarantee because it uses a different UDP socket/source port from the actual forwarding sessions.

I’ve also found multiple state/lifecycle defects in the new UI, including a cancellation mechanism that can be delayed by the worker thread’s own blocking run() method, plus cleanup paths that can terminate unrelated Roblox processes. Qt’s own worker-thread guidance supports changing that cancellation design.

Suy nghĩ

Analyzed Matt's LocalHost implementation

Trả lời

The draft is now a full language-neutral specification rather than a code walkthrough: it includes the actual topology, both implementations’ state/lifecycle behavior, command construction, place-file semantics, proxy mapping algorithm, failure races, and a hardened reimplementation architecture. I’ve ranked the destructive issues separately from ordinary maintainability problems so the redesign priorities are unambiguous.

Suy nghĩ

Reviewed QA structure and document sections

Worked for 7m 1s

Trả lời

Completed the full analysis and reimplementation specification:

[Download matts_localhost_full_logic_analysis.md]

It is about 104 KB / 2,976 lines and covers both implementations end-to-end: design philosophy, actual network topology, Studio command construction, UDP session mapping, place-file behavior, process ownership, persistence, UI/control logic, complete state models, concurrency, cancellation, shutdown, packet filtering, failure modes, security boundaries, compatibility risks, and a language-neutral replacement architecture.

The most consequential conclusions are:

  • The tool is fundamentally an asymmetric UDP bridge plus Studio process orchestrator, not a tunnel implementation.
  • Several Studio switches it relies on are internal/undocumented. Roblox explicitly warns that undocumented CLI arguments can change without notice, so the document isolates them behind a proposed versioned StudioAdapter. (create.roblox.com)
  • The UDP warm-up does not generically establish the mapping used by real proxy traffic, because it sends from a separate UDP socket/source port. UDP NAT mapping behavior is tied to address/port tuples. (www.rfc-editor.org)
  • Source B's global taskkill /IM cleanup can kill unrelated Roblox Studio/Player processes; Microsoft's documentation confirms /IM targets by image name, whereas /PID can scope termination to an owned process. (learn.microsoft.com)
  • Source B has a serious worker-generation race: a stopped-but-still-running worker can later send create/join signals into a replacement session and even remove references to the replacement worker. Its queued cancellation mechanism is also ineffective while the worker's long run() slot blocks its own thread event loop. Qt's thread-affinity/event-loop documentation supports that analysis. (doc.qt.io doc.qt.io)
  • The document also treats the unbacked-up %LOCALAPPDATA%\Roblox\server.rbxl replacement, false readiness/connection states, upstream UDP source filtering, session resource limits, stale proxy state, and host/client dependency handling as first-class redesign requirements.

I deliberately distinguish confirmed source behavior from inferred Roblox semantics, since I did not runtime-test these commands against Roblox Studio.

Chia sẻ Q&A này