diff --git a/README.md b/README.md
index f15d330..fd4e09c 100644
--- a/README.md
+++ b/README.md
@@ -201,7 +201,8 @@ All optional; add them under `environment:` in your compose override next to `PO
| `STORE_DATA_FILE` | `store-themes.json` in the container's working dir | Where submitted themes (including screenshots) are stored. Mount a volume over this path if they should survive a container recreate. |
| `STORE_ALLOWED_ORIGIN` | `*` | CORS origin allowed to call the store endpoint, if you want to restrict it to your own frontend's origin. |
| `STORE_ADMIN_TOKEN` | unset | Bearer token for moderation. New submissions wait as "pending" until approved on the review page at `/api/store/admin` (enter the token there); the token holder's own submissions and the reserved author name(s) skip the queue. Without it, nothing ever gets published. Submitted CSS is also checked server-side: no `@import`/`@font-face`, no external `url()` — only inline `data:` images. |
-| `ALLOWED_SERVERS` | unset (any server) | Comma-separated list of server addresses this gateway is allowed to connect to (e.g. `ts.example.com,*.example.net`). A port is matched separately from the host, so listing `ts.example.com` allows any port on it. An entry starting with `*.` matches any subdomain (`*.example.com` allows `ts.example.com`, not `example.com` itself - list that separately too if it should also be reachable). Locks a self-hosted instance down to specific server(s) instead of acting as a general "connect anywhere" client; a rejected `connect` gets an error back before any connector process is even spawned. |
+| `ALLOWED_SERVERS` | unset (any server) | Comma-separated list of server addresses this gateway is allowed to connect to (e.g. `ts.example.com,*.example.net`). A port is matched separately from the host, so listing `ts.example.com` allows any port on it. An entry starting with `*.` matches any subdomain (`*.example.com` allows `ts.example.com`, not `example.com` itself - list that separately too if it should also be reachable). Locks a self-hosted instance down to specific server(s) instead of acting as a general "connect anywhere" client; a rejected `connect` gets an error back before any connector process is even spawned. An entry may carry a port (`ts.example.com:9988`): it still allows every port, but that's the address the connect dialog offers (see `SERVER_PICKER`). |
+| `SERVER_PICKER` | on | With `ALLOWED_SERVERS` set (and no `*.` entries in it), the connect dialog's address field becomes a dropdown of those servers, or a locked field if there's only one. Set to `0` for the plain text field instead. Only works when the gateway serves the web client itself (the Docker image does). |
| `ALLOW_PRIVATE_TARGETS` | off | By default the gateway refuses to connect to private/internal addresses (loopback, `10.x`, `192.168.x`, CGNAT, link-local, …), no matter how they were reached (IP, DNS, SRV, TSDNS, nickname, file-transfer redirect), so it can't be abused to probe the network it runs in. **If your TeamSpeak server is on the same LAN as the gateway, set this to `1`.** |
| `TURN_URLS` | unset | Comma-separated TURN URLs (e.g. `turn:turn.example.com:3478`) offered to browsers for screen streams, for viewers or publishers behind NATs where direct P2P fails. Pair with `TURN_SECRET` (coturn's `use-auth-secret`; each browser gets its own credential valid for 24 h) or with static `TURN_USERNAME` / `TURN_CREDENTIAL`, which every visitor can read. |
| `ALLOWED_ORIGINS` | unset (any origin) | Comma-separated list of web origins allowed to open `/ws` (e.g. `https://client.example.com`). Stops other websites from silently using your gateway as their relay. |
diff --git a/gateway/src/index.ts b/gateway/src/index.ts
index 79872eb..6a5c0ce 100644
--- a/gateway/src/index.ts
+++ b/gateway/src/index.ts
@@ -54,8 +54,8 @@ function isServerAllowed(host: unknown): boolean {
return ALLOWED_SERVERS.some((entry) => {
// "*.example.com" matches any subdomain (TLS-wildcard-style: not the
// bare apex itself - list that separately if it should be allowed too).
- if (entry.startsWith("*.")) return target.endsWith(entry.slice(1));
- return target === entry;
+ if (entry.startsWith("*.")) return target.endsWith(stripPort(entry).slice(1));
+ return target === stripPort(entry);
});
}
@@ -134,9 +134,17 @@ function turnServers() {
// issue #12): set on the container, these end up in the served index.html as
// tags the client reads at startup, so changing them needs no rebuild.
// Meta tags rather than an inline script, which CONTENT_SECURITY_POLICY forbids.
+// The allowlist goes along so the client can offer it as a dropdown (or a
+// locked field for a single entry) instead of a free-text address; not with
+// wildcards, which can't be listed, nor with SERVER_PICKER=0.
+const SERVER_PICKER =
+ process.env.SERVER_PICKER !== "0" && !ALLOWED_SERVERS.some((e) => e.startsWith("*."))
+ ? ALLOWED_SERVERS.join(",")
+ : undefined;
const RUNTIME_CONFIG_META = Object.entries({
"webspeak3-default-server": process.env.DEFAULT_SERVER,
"webspeak3-default-channel": process.env.DEFAULT_CHANNEL,
+ "webspeak3-allowed-servers": SERVER_PICKER,
})
.flatMap(([name, value]) =>
value ? [`]/g, (c) => `${c.charCodeAt(0)};`)}">`] : [],
diff --git a/web/src/App.tsx b/web/src/App.tsx
index 9b628f9..0adffdd 100644
--- a/web/src/App.tsx
+++ b/web/src/App.tsx
@@ -257,6 +257,9 @@ const runtimeConfig = (name: string) =>
document.querySelector(`meta[name="webspeak3-${name}"]`)?.content;
const DEFAULT_SERVER = runtimeConfig("default-server") || import.meta.env.VITE_DEFAULT_SERVER || null;
const DEFAULT_CHANNEL = runtimeConfig("default-channel") || import.meta.env.VITE_DEFAULT_CHANNEL || "";
+// The gateway admin's ALLOWED_SERVERS (unless SERVER_PICKER=0): one server
+// locks the address field to it, several turn it into a dropdown.
+const SERVER_CHOICES = runtimeConfig("allowed-servers")?.split(",").filter(Boolean) ?? [];
// Terms of use, own-hosted instance only (see TODO.md #2/#7.1). Versioned so
// a rule change can re-surface the modal: bump TOS_VERSION and everyone who
@@ -1656,7 +1659,20 @@ function ConnectDialog({