| 1 | # tailscale_tunnel.py DOX |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | - Own the `tailscale_tunnel.py` helper module. |
| 6 | - This module implements Tailscale tunnel install and provider lifecycle behavior. |
| 7 | - Keep this file-level DOX profile synchronized with `tailscale_tunnel.py` because this directory is intentionally flat. |
| 8 | |
| 9 | ## Ownership |
| 10 | |
| 11 | - `tailscale_tunnel.py` owns the runtime implementation. |
| 12 | - `tailscale_tunnel.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation. |
| 13 | - Classes: |
| 14 | - `TailscaleTunnel` (`CliTunnelHelper`) |
| 15 | - `stop(self)` |
| 16 | - Top-level functions: |
| 17 | - `tailscale_arch()` |
| 18 | - `tailscale_archive_url()` |
| 19 | - `install_tailscale(notify=...)` |
| 20 | - `resolve_tailscaled_binary(binary_path)` |
| 21 | - `notify_info(notify, message, data=...)` |
| 22 | - `tailscale_socket_args(socket_path=...)` |
| 23 | - `tailscale_command(binary_path, args, socket_path=...)` |
| 24 | - `tailscale_status(binary_path, socket_path=...)` |
| 25 | - `tailscale_funnel_help(binary_path, socket_path=...)` |
| 26 | - `compact_output(lines)` |
| 27 | - `tailscale_daemon_hint(output)` |
| 28 | - `tailscale_daemon_ready(binary_path, socket_path)` |
| 29 | - `read_recent_tailscaled_log()` |
| 30 | - `start_tailscaled(binary_path, notify=...)` |
| 31 | - `stop_managed_tailscaled()` |
| 32 | - `tailscale_up_failure_message(output, timed_out=...)` |
| 33 | - `run_tailscale_up(binary_path, notify=..., timeout=..., socket_path=...)` |
| 34 | - `ensure_tailscale_funnel_command(binary_path, socket_path=...)` |
| 35 | - `ensure_tailscale_ready(binary_path, notify=...)` |
| 36 | - Notable constants/configuration names: `TAILSCALE_URL_RE`, `TAILSCALE_LOGIN_URL_RE`, `TAILSCALE_STABLE_PACKAGES_URL`, `TAILSCALE_UP_TIMEOUT`, `TAILSCALE_FUNNEL_TIMEOUT`, `TAILSCALE_FUNNEL_HTTPS_PORT`, `TAILSCALE_DAEMON_START_TIMEOUT`, `TAILSCALE_RUNTIME_DIR`, `TAILSCALE_STATE_DIR`, `TAILSCALE_SOCKET_PATH`, `TAILSCALE_DAEMON_LOG_PATH`, `TAILSCALE_DAEMON_PID_PATH`. |
| 37 | |
| 38 | ## Runtime Contracts |
| 39 | |
| 40 | - Helper modules own reusable framework APIs and must preserve public callers unless all callers, tests, and docs are updated together. |
| 41 | - Update this file whenever public functions, classes, persistence behavior, path/security assumptions, side effects, or cross-module contracts change. |
| 42 | - Observed side-effect areas: filesystem reads, filesystem writes, filesystem deletion, network calls, subprocess/runtime control, WebSocket state, settings/state persistence, tunnel state. |
| 43 | - Imported dependency areas include: `collections`, `flaredantic`, `helpers`, `helpers.cli_tunnel`, `json`, `os`, `pathlib`, `queue`, `re`, `shutil`, `subprocess`, `threading`, `time`, `urllib.parse`, `urllib.request`. |
| 44 | |
| 45 | ## Key Concepts |
| 46 | |
| 47 | - Important called helpers/classes observed in the source: `re.compile`, `Path`, `files.get_abs_path`, `cli_tunnel.platform_parts`, `tailscale_arch`, `pattern.search`, `urllib.parse.urljoin`, `shutil.which`, `tailscale_archive_url`, `cli_tunnel.download_file`, `Path.with_name`, `sibling.exists`, `callable`, `subprocess.run`, `join`, `output.lower`, `tailscale_status`, `compact_output`, `resolve_tailscaled_binary`, `tailscale_daemon_ready`. |
| 48 | - Keep request/response, tool, or helper semantics documented here at the same time as source changes. |
| 49 | |
| 50 | ## Work Guidance |
| 51 | |
| 52 | - Preserve public helper APIs used by core code and plugins unless every caller is updated. |
| 53 | - Keep path, auth, secret, persistence, network, and subprocess behavior explicit and bounded. |
| 54 | - Prefer adding cohesive helper functions here only when behavior is reused across modules. |
| 55 | |
| 56 | ## Verification |
| 57 | |
| 58 | - Run targeted tests for changed helper behavior; run security regressions for auth, filesystem, WebSocket, tunnel, upload, or secret-handling helpers. |
| 59 | - Related tests observed by source search: |
| 60 | - `tests/test_tunnel_remote_link.py` |
| 61 | |
| 62 | ## Child DOX Index |
| 63 | |
| 64 | No child DOX files. |