From e3f847451cb52e165bede2566dcd3e127d5b2a5e Mon Sep 17 00:00:00 2001 From: gall-levi-tech Date: Fri, 21 Aug 2026 11:02:48 -0500 Subject: [PATCH] Add frame.local discovery and gallery support links --- CHANGELOG.md | 1 + README.md | 14 +- apps/frame-setup/README.md | 3 +- apps/frame-setup/src-tauri/src/lib.rs | 57 ++++++ apps/frame-setup/src-tauri/tauri.conf.json | 4 +- docs/TODO.md | 2 +- docs/adr/0004-frame-edge-routing.md | 3 +- docs/adr/0005-hybrid-public-gateway.md | 3 +- docs/adr/0013-trusted-home-lan-http.md | 39 ++++ docs/schemas/gallery-api.schema.json | 18 +- docs/spec/v1.1.md | 25 ++- installer/README.md | 7 + installer/stack.ps1 | 183 +++++++++++++++++- installer/stack.sh | 62 +++++- services/frame-gallery/public/admin.css | 2 + services/frame-gallery/public/admin.html | 33 +++- services/frame-gallery/public/admin.js | 151 ++++++++++++++- services/frame-gallery/public/gallery.js | 94 +++++++-- services/frame-gallery/public/index.html | 24 ++- services/frame-gallery/public/socials.js | 99 ++++++++-- services/frame-gallery/public/styles.css | 13 ++ services/frame-gallery/public/support.js | 79 ++++++++ services/frame-gallery/src/theme.ts | 104 +++++++++- services/frame-gallery/tests/gallery.test.mjs | 22 ++- services/frame-gallery/tests/socials.test.mjs | 9 +- services/frame-gallery/tests/support.test.mjs | 16 ++ tests/frame-contract.test.mjs | 12 ++ 27 files changed, 1006 insertions(+), 73 deletions(-) create mode 100644 docs/adr/0013-trusted-home-lan-http.md create mode 100644 services/frame-gallery/public/support.js create mode 100644 services/frame-gallery/tests/support.test.mjs diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b08e47..ecfeafe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- Added host-level mDNS discovery for `http://frame.local`, tied to the FRAME stack lifecycle. - Added staged Hybrid installation, a pinned Cloudflare Tunnel connector, and an internal-only public gateway that enforces generated capability-aware route allowlists. - Added safe public Audio Monitor listener APIs and separate LAN capture/public listener base URLs. diff --git a/README.md b/README.md index 869e9c6..dbd30c7 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,16 @@ Open the Portal: http://localhost/dashboard ``` +From another device on the same LAN, open: + +```text +http://frame.local +``` + +FRAME advertises this address when the host provides mDNS/Bonjour. On Windows, the launcher keeps +the advertisement active after sign-in and restores it when FRAME Edge returns. The host's LAN IP +remains the fallback on networks that filter multicast discovery. + Useful first pages: - Portal: `http://localhost/dashboard` @@ -98,7 +108,7 @@ Stop the stack: - Choose **Stop stack** from the menu. On Linux/macOS, run `chmod +x stack.sh` once, then run `./stack.sh` without arguments to open the -same menu. +same menu. macOS provides the required mDNS publisher; Linux uses `avahi-publish` when available. ## Optional Setup @@ -272,7 +282,7 @@ The public-facing backlog for the alpha release line: **Installer / Platform** - Add host-port conflict preflight detection. -- Add LAN HTTPS and optional Cloudflare Access policy automation. +- Add optional Cloudflare Access policy automation. **Photo Workflow** diff --git a/apps/frame-setup/README.md b/apps/frame-setup/README.md index e2ddb02..57ef657 100644 --- a/apps/frame-setup/README.md +++ b/apps/frame-setup/README.md @@ -15,7 +15,8 @@ selected data folders, generate the capability-aware stack config and tunnel ing `docker compose config --quiet`, start the stack with `docker compose up -d --build --remove-orphans`, and open `http://localhost/setup`. During install, the UI streams progress from the native backend and waits for the FRAME web edge to -accept connections before launching the browser. +accept connections before launching the browser. It also enables the shared mDNS launcher when +available so other LAN devices can open `http://frame.local`; on Windows this resumes after sign-in. The packaged installer bundles the current FRAME stack resources and copies them into the selected install root before running Docker Compose. diff --git a/apps/frame-setup/src-tauri/src/lib.rs b/apps/frame-setup/src-tauri/src/lib.rs index a177324..19ac78f 100644 --- a/apps/frame-setup/src-tauri/src/lib.rs +++ b/apps/frame-setup/src-tauri/src/lib.rs @@ -338,6 +338,18 @@ fn apply_install_plan(app: AppHandle, plan: InstallPlan) -> Result push_install_log( + &app, + &mut logs, + "FRAME LAN discovery is enabled at http://frame.local.", + ), + Err(error) => push_install_log( + &app, + &mut logs, + format!("FRAME started, but frame.local discovery is unavailable: {error}"), + ), + } Ok(ApplyResult { path: saved.path, @@ -384,6 +396,14 @@ fn prepare_stack_workspace( .join("templates") .join("docker-compose.yml"); copy_file(&template_source, &template_target)?; + copy_file( + &source.join("installer").join("stack.ps1"), + &workspace.join("installer").join("stack.ps1"), + )?; + copy_file( + &source.join("installer").join("stack.sh"), + &workspace.join("installer").join("stack.sh"), + )?; Ok(()) } @@ -474,6 +494,43 @@ fn wait_for_web_setup(app: &AppHandle, logs: &mut Vec, port: u16) -> Res } } +#[cfg(windows)] +fn start_frame_discovery( + app: &AppHandle, + workspace: &Path, + logs: &mut Vec, +) -> Result<(), String> { + run_logged_command( + app, + workspace, + logs, + "powershell.exe", + &[ + "-NoProfile", + "-ExecutionPolicy", + "Bypass", + "-File", + "installer\\stack.ps1", + "discovery-start", + ], + ) +} + +#[cfg(not(windows))] +fn start_frame_discovery( + app: &AppHandle, + workspace: &Path, + logs: &mut Vec, +) -> Result<(), String> { + run_logged_command( + app, + workspace, + logs, + "sh", + &["installer/stack.sh", "discovery-start"], + ) +} + fn save_install_plan_inner(plan: &InstallPlan) -> Result { validate_install_plan(plan)?; let root = storage_root(plan)?; diff --git a/apps/frame-setup/src-tauri/tauri.conf.json b/apps/frame-setup/src-tauri/tauri.conf.json index 259d3a6..000f922 100644 --- a/apps/frame-setup/src-tauri/tauri.conf.json +++ b/apps/frame-setup/src-tauri/tauri.conf.json @@ -33,7 +33,9 @@ "resources": { "../../../services/": "frame-stack/services", "../../../config/": "frame-stack/config", - "../../../installer/templates/docker-compose.yml": "frame-stack/installer/templates/docker-compose.yml" + "../../../installer/templates/docker-compose.yml": "frame-stack/installer/templates/docker-compose.yml", + "../../../installer/stack.ps1": "frame-stack/installer/stack.ps1", + "../../../installer/stack.sh": "frame-stack/installer/stack.sh" } } } diff --git a/docs/TODO.md b/docs/TODO.md index 75a989a..16222a4 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -41,7 +41,7 @@ removed. - Add API integration tests for implemented HTTP services. - Split installer environment/state responsibilities out of `frame-installer.mjs`. - Add host-port conflict preflight detection. -- Add LAN HTTPS and optional Cloudflare Access policy automation. +- Add optional Cloudflare Access policy automation. - [x] Add a canonical service/capability registry with dependency and profile activation tests. - [x] Add a root `stack verify` command and GitHub verification workflow. - [x] Decide that `frame-pipeline-photos` is an internal service activated by photo capabilities. diff --git a/docs/adr/0004-frame-edge-routing.md b/docs/adr/0004-frame-edge-routing.md index 818b894..12540b7 100644 --- a/docs/adr/0004-frame-edge-routing.md +++ b/docs/adr/0004-frame-edge-routing.md @@ -27,4 +27,5 @@ restricted `frame-docker-proxy`. - New services can attach a route by adding labels and keeping browser requests inside that prefix. - The socket proxy also permits the read-only Docker events, network, ping, and version endpoints required by Traefik discovery. -- The first implementation is LAN HTTP only. HTTPS and HYBRID tunnel exposure remain follow-up work. +- LAN HTTP is the intended direct-access model; FRAME-owned LAN TLS is out of scope per ADR 0013. + HYBRID tunnel exposure is defined separately in ADR 0005. diff --git a/docs/adr/0005-hybrid-public-gateway.md b/docs/adr/0005-hybrid-public-gateway.md index 378790f..4025eff 100644 --- a/docs/adr/0005-hybrid-public-gateway.md +++ b/docs/adr/0005-hybrid-public-gateway.md @@ -45,4 +45,5 @@ The installer stages Hybrid mode without starting it. Startup validation require - The tunnel token is not exposed through container environment inspection. - Cloudflare account API credentials are not required by FRAME. - Creating the tunnel and Published application remains an explicit Cloudflare dashboard step. -- Cloudflare Access policy automation and LAN HTTPS remain separate follow-up work. +- Cloudflare Access policy automation remains a separate follow-up. FRAME-owned LAN HTTPS is out of + scope per ADR 0013. diff --git a/docs/adr/0013-trusted-home-lan-http.md b/docs/adr/0013-trusted-home-lan-http.md new file mode 100644 index 0000000..6c22efe --- /dev/null +++ b/docs/adr/0013-trusted-home-lan-http.md @@ -0,0 +1,39 @@ +# ADR 0013: Keep direct LAN access on HTTP + +- **Status:** Accepted +- **Date:** 2026-08-14 + +## Context + +FRAME is designed for an operator-controlled home or production LAN. Public routes use Cloudflare +Tunnel, which provides browser-facing HTTPS without exposing the LAN edge. Adding HTTPS directly to +the LAN edge would require operators to provide a trusted DNS name and certificate or install a +FRAME-owned certificate authority on every client device. + +## Decision + +`frame-edge` remains an HTTP-only LAN entry point. LAN security, segmentation, and access policy are +the operator's responsibility. FRAME does not generate self-signed certificates, distribute a local +certificate authority, or automate LAN TLS. + +When the host provides a standard mDNS publisher, FRAME advertises its LAN edge as `frame.local` +and the `_http._tcp` service named `FRAME`. Discovery starts and stops with the stack; on Windows, +a per-user watchdog restores it after sign-in and follows Edge availability. This is a friendly +alias rather than a security boundary; the host's LAN address and configured Edge port +remain valid fallbacks. + +Hybrid/public routes continue to use HTTPS at Cloudflare and the capability-aware +`frame-public-gateway`. The internal `cloudflared` to public-gateway hop remains HTTP on the private +Docker network. + +Browser features that require a secure context should use `localhost` when running on the FRAME host +or a configured Cloudflare HTTPS route when used from another device. FRAME must document such +requirements rather than presenting an untrusted LAN certificate. + +## Consequences + +- A default install has no certificate, DNS, or client trust-enrollment workflow. +- Supported LAN clients can open `http://frame.local` without finding the host IP first. +- Direct LAN traffic is not encrypted by FRAME. +- Operators who require LAN encryption may place FRAME behind infrastructure they manage. +- Cloudflare Access policy automation remains an optional, separate future enhancement. diff --git a/docs/schemas/gallery-api.schema.json b/docs/schemas/gallery-api.schema.json index 6ec6573..bd751be 100644 --- a/docs/schemas/gallery-api.schema.json +++ b/docs/schemas/gallery-api.schema.json @@ -130,13 +130,27 @@ "id": { "type": "string", "pattern": "^[A-Za-z0-9_-]{1,64}$" }, "platform": { "type": "string", - "enum": ["website", "instagram", "tiktok", "youtube", "twitch", "facebook", "x", "threads", "bluesky", "discord", "linkedin", "reddit", "snapchat", "flickr"] + "enum": ["website", "fivehundredpx", "applemusic", "bandcamp", "behance", "bluesky", "cara", "discord", "facebook", "flickr", "github", "instagram", "kick", "linkhub", "linkedin", "mastodon", "medium", "pinterest", "pixelfed", "reddit", "snapchat", "soundcloud", "spotify", "substack", "telegram", "threads", "tiktok", "twitch", "vimeo", "whatsapp", "x", "youtube"] }, "label": { "type": "string", "minLength": 1, "maxLength": 60 }, "url": { "type": "string", "maxLength": 2048, "pattern": "^https?://" }, "graphic": { "$ref": "#/$defs/socialGraphic" } } }, + "support": { + "type": "object", + "additionalProperties": false, + "required": ["id", "platform", "url"], + "properties": { + "id": { "type": "string", "pattern": "^[A-Za-z0-9_-]{1,64}$" }, + "platform": { + "type": "string", + "enum": ["custom", "buymeacoffee", "gofundme", "justgiving", "kofi", "monzo", "patreon", "paypal", "revolut", "square", "starling", "stripe", "sumup", "tide", "venmo", "wise"] + }, + "label": { "type": "string", "minLength": 1, "maxLength": 60 }, + "url": { "type": "string", "maxLength": 2048, "pattern": "^https?://" } + } + }, "branding": { "type": "object", "additionalProperties": false, @@ -148,6 +162,7 @@ "profile_id", "custom_profiles", "socials", + "supports", "logo", "updated_at", "active_profile", @@ -161,6 +176,7 @@ "profile_id": { "type": "string", "pattern": "^[a-z0-9-]+$" }, "custom_profiles": { "type": "array", "items": { "$ref": "#/$defs/profile" } }, "socials": { "type": "array", "maxItems": 32, "items": { "$ref": "#/$defs/social" } }, + "supports": { "type": "array", "maxItems": 32, "items": { "$ref": "#/$defs/support" } }, "logo": { "$ref": "#/$defs/logo" }, "updated_at": { "type": "string", "format": "date-time" }, "active_profile": { "$ref": "#/$defs/profile" }, diff --git a/docs/spec/v1.1.md b/docs/spec/v1.1.md index 964dc29..54921f9 100644 --- a/docs/spec/v1.1.md +++ b/docs/spec/v1.1.md @@ -225,7 +225,7 @@ This section defines the **modules** of Syronius’ Frame and how they map to ** | Container | Holds These Modules | Notes | | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- | -| **frame-edge** | Traefik reverse proxy, LAN HTTPS termination, internal routing | Single HTTP edge for all web UIs | +| **frame-edge** | Traefik reverse proxy and LAN HTTP routing | Single HTTP edge for all web UIs | | **frame-portal** | Portal shell (dashboard + nav), `/status` (or status links), capability-aware menu | Links to other UIs (no iframes) | | **frame-ingest-video** | OpenIRL `srtla-receiver` ingest + stats | UDP ingest + stats endpoint | | **frame-streams** | FRAME-owned stream profile management UI against the OpenIRL receiver API | Requires `frame-ingest-video` | @@ -1303,8 +1303,9 @@ Implementation note (2026-06-11): the unified installer deploys the implemented Edge, Portal, Discord Audio Bridge, Audio Monitor, Video Relay, Stream Management, and Overlay services. It supports staged HYBRID deployment through a remotely managed Cloudflare Tunnel and a separate generated public-route gateway. Hybrid startup is refused until its hostname, tunnel -token, and Portal credentials are configured. LAN HTTPS and Cloudflare Access policy automation -remain follow-up work. +token, and Portal credentials are configured. Direct LAN access intentionally remains HTTP under +the operator's trusted-network policy; see ADR 0013. Cloudflare Access policy automation remains a +follow-up. Fresh installs enable only FRAME Edge and Portal. Every optional capability is opt-in, including the Discord Audio Bridge, because it requires external credentials and joins live Discord voice @@ -1336,12 +1337,20 @@ The following were resolved during pre-build spec review: - **Audio transport internals** — MediaRecorder chunks over WebSocket → ffmpeg → HLS. See §2.0-I. - **Retention defaults** — Manual operator process in V1; no automated cleanup. See §7.0-E. -Remaining open items: +The remaining pre-build items were resolved as follows: -- Overlay Wizard detailed UX flow -- Manual Upload UI UX (accepted file types, size limits, progress feedback) -- Traefik LAN HTTPS / TLS strategy (self-signed, mkcert, or other) -- Photo pipeline implementation language / runtime +- **Overlay Wizard detailed UX flow** - Implemented as a guided source-first flow with stable OBS + URLs, live preview, immutable templates, reusable presets, and source editing. See ADR 0011. +- **Manual Upload UI UX** - Implemented with configurable file and session limits, multiple-file + selection, per-file progress, and accepted/failed feedback. +- **Traefik LAN HTTPS / TLS strategy** - FRAME intentionally keeps direct LAN access on HTTP and + relies on Cloudflare for public HTTPS. See ADR 0013. +- **Photo pipeline implementation language / runtime** - TypeScript on Node.js 22 in the + `frame-pipeline-photos` container. + +Remaining open item: + +- Optional Cloudflare Access policy automation. --- diff --git a/installer/README.md b/installer/README.md index 9eeb697..39e83d8 100644 --- a/installer/README.md +++ b/installer/README.md @@ -34,6 +34,13 @@ Cloudflare Tunnel and a separate internal FRAME Public Gateway. The public gatew the generated capability-aware allowlist; LAN-only admin, capture, ingest, and management routes remain unavailable through the tunnel. +Direct LAN access intentionally remains HTTP for operator-controlled networks. FRAME does not manage +LAN certificates or client trust; public HYBRID routes receive browser-facing HTTPS from Cloudflare. +When the host provides `dns-sd` or `avahi-publish`, starting FRAME also advertises the Edge as +`http://frame.local`; stopping or resetting FRAME removes that advertisement. On Windows, a hidden +per-user watchdog resumes it after sign-in and follows FRAME Edge availability. A custom Edge port +is advertised as `http://frame.local:`. + FRAME Edge also denies known LAN-only management routes when requests arrive through the configured public hostname or Cloudflare headers. This defense-in-depth protects the stack if a remotely managed Cloudflare Published application is accidentally pointed at FRAME Edge instead of diff --git a/installer/stack.ps1 b/installer/stack.ps1 index 1bbc6ee..d97154c 100644 --- a/installer/stack.ps1 +++ b/installer/stack.ps1 @@ -226,6 +226,170 @@ function Test-LanIPv4Candidate { return $Address -match "^(10\.|192\.168\.|172\.(1[6-9]|2[0-9]|3[0-1])\.)" } +function Get-FrameDiscoveryStatePath { + $env = Get-EnvMap + $dataRoot = "./data" + if ($env.FRAME_DATA_ROOT) { $dataRoot = $env.FRAME_DATA_ROOT } + $stateDir = Join-Path (Resolve-FrameDataPath $dataRoot) "state" + New-Item -ItemType Directory -Force -Path $stateDir | Out-Null + return Join-Path $stateDir "frame-mdns.json" +} + +function Get-FrameDiscoveryWatchStatePath { + return Join-Path (Split-Path -Parent (Get-FrameDiscoveryStatePath)) "frame-mdns-watch.json" +} + +function Get-FrameDiscoveryStartupPath { + if (-not $env:APPDATA) { return $null } + $startupDir = Join-Path $env:APPDATA "Microsoft\Windows\Start Menu\Programs\Startup" + New-Item -ItemType Directory -Force -Path $startupDir | Out-Null + return Join-Path $startupDir "Syronius FRAME Discovery.cmd" +} + +function Get-FrameDiscoveryProcess { + $statePath = Get-FrameDiscoveryStatePath + if (-not (Test-Path $statePath)) { return $null } + try { + $state = Get-Content $statePath -Raw | ConvertFrom-Json + $processId = [int]$state.pid + $process = Get-CimInstance Win32_Process -Filter "ProcessId = $processId" -ErrorAction SilentlyContinue + if ($process -and $process.Name -eq "dns-sd.exe" -and $process.CommandLine -like "*frame.local*") { + return $process + } + } catch {} + Remove-Item -LiteralPath $statePath -Force -ErrorAction SilentlyContinue + return $null +} + +function Stop-FrameDiscoveryPublisher { + param([switch]$Quiet) + $statePath = Get-FrameDiscoveryStatePath + if (-not (Test-Path $statePath)) { return } + try { + $process = Get-FrameDiscoveryProcess + if ($process) { + Stop-Process -Id $process.ProcessId -Force -ErrorAction SilentlyContinue + if (-not $Quiet) { Write-Host "Stopped frame.local discovery." -ForegroundColor DarkGray } + } + } catch { + if (-not $Quiet) { Write-Host "Could not inspect the previous frame.local publisher." -ForegroundColor Yellow } + } finally { + Remove-Item -LiteralPath $statePath -Force -ErrorAction SilentlyContinue + } +} + +function Start-FrameDiscovery { + param([switch]$PublisherOnly) + Stop-FrameDiscoveryPublisher -Quiet + $publisher = Get-Command dns-sd.exe -ErrorAction SilentlyContinue + if (-not $publisher) { + Write-Host "FRAME is running, but this computer does not provide dns-sd for frame.local discovery." -ForegroundColor Yellow + return + } + $addresses = @(Get-HostLanIPv4Candidates) + if ($addresses.Count -eq 0) { + Write-Host "FRAME is running, but no private LAN address was found for frame.local discovery." -ForegroundColor Yellow + return + } + $env = Get-EnvMap + $port = 80 + if ($env.EDGE_HTTP_PORT) { $port = [int]$env.EDGE_HTTP_PORT } + $address = $addresses[0] + $process = Start-Process -FilePath $publisher.Source -ArgumentList @( + "-P", "FRAME", "_http._tcp", "local", "$port", "frame.local", $address, "path=/dashboard" + ) -WindowStyle Hidden -PassThru + Start-Sleep -Milliseconds 250 + if ($process.HasExited) { + Write-Host "FRAME is running, but frame.local discovery could not start." -ForegroundColor Yellow + return + } + [pscustomobject]@{ + pid = $process.Id + address = $address + port = $port + startedAt = [DateTime]::UtcNow.ToString("o") + } | ConvertTo-Json | Set-Content -LiteralPath (Get-FrameDiscoveryStatePath) -Encoding UTF8 + $url = "http://frame.local" + if ($port -ne 80) { $url = "http://frame.local:$port" } + Write-Host "FRAME is available on the LAN at $url" -ForegroundColor Green + if (-not $PublisherOnly) { Enable-FrameDiscoveryWatch } +} + +function Test-FrameEdgeReachable { + $env = Get-EnvMap + $port = 80 + if ($env.EDGE_HTTP_PORT) { $port = [int]$env.EDGE_HTTP_PORT } + $client = New-Object System.Net.Sockets.TcpClient + try { + $connection = $client.ConnectAsync("127.0.0.1", $port) + return $connection.Wait(1000) -and $client.Connected + } catch { + return $false + } finally { + $client.Dispose() + } +} + +function Test-FrameDiscoveryWatchRunning { + $statePath = Get-FrameDiscoveryWatchStatePath + if (-not (Test-Path $statePath)) { return $false } + try { + $state = Get-Content $statePath -Raw | ConvertFrom-Json + $processId = [int]$state.pid + $process = Get-CimInstance Win32_Process -Filter "ProcessId = $processId" -ErrorAction SilentlyContinue + return [bool]($process -and $process.Name -eq "powershell.exe" -and $process.CommandLine -like "*stack.ps1*discovery-watch*") + } catch { + Remove-Item -LiteralPath $statePath -Force -ErrorAction SilentlyContinue + return $false + } +} + +function Enable-FrameDiscoveryWatch { + $startupPath = Get-FrameDiscoveryStartupPath + if ($startupPath) { + $command = '@start "" /min powershell.exe -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File "{0}" discovery-watch' -f $PSCommandPath + Set-Content -LiteralPath $startupPath -Value $command -Encoding ASCII + } + if (-not (Test-FrameDiscoveryWatchRunning)) { + Start-Process -FilePath "powershell.exe" -ArgumentList @( + "-NoProfile", "-WindowStyle", "Hidden", "-ExecutionPolicy", "Bypass", "-File", ('"{0}"' -f $PSCommandPath), "discovery-watch" + ) -WindowStyle Hidden | Out-Null + } +} + +function Watch-FrameDiscovery { + $statePath = Get-FrameDiscoveryWatchStatePath + [pscustomobject]@{ + pid = $PID + startedAt = [DateTime]::UtcNow.ToString("o") + } | ConvertTo-Json | Set-Content -LiteralPath $statePath -Encoding UTF8 + try { + while ($true) { + if (Test-FrameEdgeReachable) { + if (-not (Get-FrameDiscoveryProcess)) { Start-FrameDiscovery -PublisherOnly } + } elseif (Get-FrameDiscoveryProcess) { + Stop-FrameDiscoveryPublisher -Quiet + } + Start-Sleep -Seconds 10 + } + } finally { + Remove-Item -LiteralPath $statePath -Force -ErrorAction SilentlyContinue + } +} + +function Stop-FrameDiscovery { + param([switch]$Quiet) + $watchStatePath = Get-FrameDiscoveryWatchStatePath + if (Test-FrameDiscoveryWatchRunning) { + $state = Get-Content $watchStatePath -Raw | ConvertFrom-Json + Stop-Process -Id ([int]$state.pid) -Force -ErrorAction SilentlyContinue + } + Remove-Item -LiteralPath $watchStatePath -Force -ErrorAction SilentlyContinue + $startupPath = Get-FrameDiscoveryStartupPath + if ($startupPath) { Remove-Item -LiteralPath $startupPath -Force -ErrorAction SilentlyContinue } + Stop-FrameDiscoveryPublisher -Quiet:$Quiet +} + function Get-PhotoFtpPassiveHostDefault { param([hashtable]$Env) $current = "" @@ -345,6 +509,7 @@ function Invoke-StartStack { if ($currentEnv.FRAME_MODE -eq "HYBRID") { Invoke-Compose @("up", "-d", "--force-recreate", "--no-deps", "--wait", "--wait-timeout", "60", "frame-public-gateway") } + Start-FrameDiscovery Write-Host "FRAME stack reconciliation completed." -ForegroundColor Green } @@ -708,11 +873,12 @@ function Invoke-InteractiveMenu { } Wait-ForMenu } - "9" { if (Read-YesNo "Stop the complete FRAME stack?") { Invoke-Compose @("down") }; Wait-ForMenu } + "9" { if (Read-YesNo "Stop the complete FRAME stack?") { Stop-FrameDiscovery; Invoke-Compose @("down") }; Wait-ForMenu } "10" { Configure-AdvancedSetting; Invoke-ReadinessFlow; Wait-ForMenu } "11" { $answer = Read-Host "Reset removes FRAME's generated config and data. Type RESET to continue" if ($answer -ceq "RESET") { + Stop-FrameDiscovery if (Test-Path (Join-Path $Root "docker-compose.yml")) { Invoke-Compose @("down", "--remove-orphans") } Invoke-Runtime @("reset", "--yes") } @@ -727,7 +893,9 @@ function Invoke-InteractiveMenu { } } -Assert-Docker +if ($Command -notin @("discovery-start", "discovery-stop", "discovery-watch")) { + Assert-Docker +} switch ($Command) { "menu" { @@ -776,7 +944,17 @@ switch ($Command) { "start" { Invoke-StartStack } + "discovery-start" { + Start-FrameDiscovery + } + "discovery-stop" { + Stop-FrameDiscovery + } + "discovery-watch" { + Watch-FrameDiscovery + } "stop" { + Stop-FrameDiscovery Invoke-Compose @("down") } "status" { @@ -796,6 +974,7 @@ switch ($Command) { Write-Host "Reset cancelled." exit 1 } + Stop-FrameDiscovery if (Test-Path (Join-Path $Root "docker-compose.yml")) { Invoke-Compose @("down", "--remove-orphans") } diff --git a/installer/stack.sh b/installer/stack.sh index 901d61b..61cfdfe 100644 --- a/installer/stack.sh +++ b/installer/stack.sh @@ -177,6 +177,56 @@ photo_ftp_passive_host_default() { printf "%s" "$current" } +frame_discovery_state_path() { + data_root=$(host_data_path "$(env_value FRAME_DATA_ROOT ./data)") + printf "%s/state/frame-mdns.pid" "$data_root" +} + +stop_frame_discovery() { + state_path=$(frame_discovery_state_path) + [ -f "$state_path" ] || return 0 + while IFS= read -r pid; do + case "$pid" in + *[!0-9]*|'') continue ;; + esac + command_line=$(ps -p "$pid" -o command= 2>/dev/null || true) + case "$command_line" in + *frame.local*dns-sd*|*dns-sd*frame.local*|*frame.local*avahi-publish*|*avahi-publish*frame.local*) kill "$pid" 2>/dev/null || true ;; + esac + done < "$state_path" + rm -f "$state_path" +} + +start_frame_discovery() { + stop_frame_discovery + address=$(lan_ipv4_candidates | awk 'NR == 1 { print; exit }') + if [ -z "$address" ]; then + echo "FRAME is running, but no private LAN address was found for frame.local discovery." >&2 + return 0 + fi + port=$(env_value EDGE_HTTP_PORT 80) + state_path=$(frame_discovery_state_path) + state_dir=${state_path%/*} + mkdir -p "$state_dir" + log_path="$state_dir/frame-mdns.log" + : > "$state_path" + if command -v dns-sd >/dev/null 2>&1; then + nohup dns-sd -P FRAME _http._tcp local "$port" frame.local "$address" path=/dashboard >"$log_path" 2>&1 & + printf "%s\n" "$!" > "$state_path" + elif command -v avahi-publish >/dev/null 2>&1; then + nohup avahi-publish -a frame.local "$address" >"$log_path" 2>&1 & + printf "%s\n" "$!" > "$state_path" + nohup avahi-publish -s FRAME _http._tcp "$port" path=/dashboard >>"$log_path" 2>&1 & + printf "%s\n" "$!" >> "$state_path" + else + rm -f "$state_path" + echo "FRAME is running, but dns-sd/avahi-publish is unavailable; frame.local was not advertised." >&2 + return 0 + fi + if [ "$port" = "80" ]; then url=http://frame.local; else url="http://frame.local:$port"; fi + echo "FRAME is available on the LAN at $url" +} + read_photo_ftp_passive_host() { default=$(photo_ftp_passive_host_default) detected=$(lan_ipv4_candidates | awk '!seen[$0]++' | paste -sd ', ' -) @@ -335,6 +385,7 @@ start_stack() { if [ "$(env_value FRAME_MODE LAN)" = "HYBRID" ]; then compose up -d --force-recreate --no-deps --wait --wait-timeout 60 frame-public-gateway fi + start_frame_discovery echo "FRAME stack reconciliation completed." } @@ -673,12 +724,13 @@ interactive_menu() { fi pause_menu ;; - 9) if yes_no "Stop the complete FRAME stack?"; then compose down; fi; pause_menu ;; + 9) if yes_no "Stop the complete FRAME stack?"; then stop_frame_discovery; compose down; fi; pause_menu ;; 10) advanced_setting; readiness_flow; pause_menu ;; 11) printf "Reset removes FRAME's generated config and data. Type RESET to continue: " read -r answer if [ "$answer" = "RESET" ]; then + stop_frame_discovery [ ! -f "$ROOT_DIR/docker-compose.yml" ] || compose down --remove-orphans runtime reset --yes fi @@ -751,7 +803,14 @@ case "$COMMAND" in start) start_stack ;; + discovery-start) + start_frame_discovery + ;; + discovery-stop) + stop_frame_discovery + ;; stop) + stop_frame_discovery compose down ;; status) @@ -774,6 +833,7 @@ case "$COMMAND" in exit 1 } fi + stop_frame_discovery [ ! -f "$ROOT_DIR/docker-compose.yml" ] || compose down --remove-orphans runtime reset --yes ;; diff --git a/services/frame-gallery/public/admin.css b/services/frame-gallery/public/admin.css index f85a5d2..b9434df 100644 --- a/services/frame-gallery/public/admin.css +++ b/services/frame-gallery/public/admin.css @@ -230,6 +230,8 @@ h1, h2 { margin: 2px 0; } min-width: 0; display: grid; grid-template-columns: 32px 56px minmax(0, 1fr) 42px; align-items: center; gap: 10px; padding: 0 0 12px; border-bottom: 1px solid var(--border); } +.support-admin-item .social-order-controls { min-height: 56px; } +.support-admin-item .support-admin-icon { cursor: default; } .social-admin-item:last-child { padding-bottom: 0; border-bottom: 0; } .social-admin-item.is-dragging { opacity: .45; } .social-admin-item.is-drag-target { box-shadow: inset 3px 0 var(--accent); } diff --git a/services/frame-gallery/public/admin.html b/services/frame-gallery/public/admin.html index 8733f30..9408b05 100644 --- a/services/frame-gallery/public/admin.html +++ b/services/frame-gallery/public/admin.html @@ -29,7 +29,7 @@ })(); - +
@@ -60,6 +60,7 @@

Gallery Admin

+
@@ -151,7 +152,7 @@

Gallery Admin

-
Add a socialPaste a profile URL, or enter a handle and choose its platform.
+
Add a socialPaste a link and FRAME will usually find the platform automatically. You can also choose one or enter a supported handle.
+ +