From 794b83a0db45cb394b7ff31af0cffcdd95dfe4a3 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 13 Oct 2026 01:19:42 +0700 Subject: [PATCH] Sharing: the default server is a build-time setting FIGCRAFT_DEFAULT_SERVER, set when compiling, names another server or, set to nothing, ships a build with no default: online sharing then stays off until the user enters a server in Preferences. Normal builds and the release workflow are unchanged. --- README.md | 3 ++- crates/engine/src/live.rs | 9 ++++++++- crates/engine/src/live_share_tests.rs | 6 +++++- docs/releasing.md | 16 ++++++++++++++++ docs/server.md | 3 ++- 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5831f18..4d9266c 100644 --- a/README.md +++ b/README.md @@ -269,7 +269,8 @@ share or join a file. Live sessions are a **preview**. Before you share anything know what sharing does: - **Share ▸ Online uploads the file to a server.** By default that is the public server at - `collab.craftapps.dev`; you can set another one, or your own, in Preferences. The file stays on + `collab.craftapps.dev`; you can set another one, or your own, in Preferences (and a build can + ship without it: [`docs/releasing.md`](docs/releasing.md#the-default-server)). The file stays on the server after you stop sharing, until you remove it (Share ▸ Advanced ▸ Remove from server…) or nobody has opened it for 30 days, when a public server deletes it. - **It is not end-to-end encrypted.** The connection to the server is encrypted (TLS), but the diff --git a/crates/engine/src/live.rs b/crates/engine/src/live.rs index ff726cc..09c5831 100644 --- a/crates/engine/src/live.rs +++ b/crates/engine/src/live.rs @@ -61,7 +61,14 @@ use crate::{DocState, EngineError, Result, Session, TextEdit, ViewState, bad, sp /// The server files are shared through online unless Preferences name another: the only place /// its address is written. -pub const DEFAULT_SERVER: &str = "wss://collab.craftapps.dev/"; +/// +/// A build can ship another one, or none: set `FIGCRAFT_DEFAULT_SERVER` when compiling to a +/// server's address (`wss://host/`), or to nothing (`FIGCRAFT_DEFAULT_SERVER=`) for a build whose +/// online sharing stays off until the user enters a server in Preferences. +pub const DEFAULT_SERVER: &str = match option_env!("FIGCRAFT_DEFAULT_SERVER") { + Some(server) => server, + None => "wss://collab.craftapps.dev/", +}; /// Most selected ids one presence update carries (the rest aren't shown to others). pub const MAX_SELECTION: usize = 10_000; diff --git a/crates/engine/src/live_share_tests.rs b/crates/engine/src/live_share_tests.rs index 286c8c8..c52e1cc 100644 --- a/crates/engine/src/live_share_tests.rs +++ b/crates/engine/src/live_share_tests.rs @@ -164,7 +164,11 @@ fn on_the_server_unshared(s: &mut Session, script: &Arc>) { fn the_built_in_server_is_the_default_and_can_be_changed_or_turned_off() { let (mut s, _) = session(); assert_eq!(s.prefs.publish_server, DEFAULT_SERVER); - assert!(DEFAULT_SERVER.starts_with("wss://") && DEFAULT_SERVER.ends_with('/'), "TLS, and an address the preference itself accepts"); + // A build may ship without one (`FIGCRAFT_DEFAULT_SERVER=`); any it ships is TLS. + assert!( + DEFAULT_SERVER.is_empty() || (DEFAULT_SERVER.starts_with("wss://") && DEFAULT_SERVER.ends_with('/')), + "TLS, and an address the preference itself accepts" + ); assert_eq!(ex(&mut s, "pref.publishServer", json!({"url": DEFAULT_SERVER}))["url"], DEFAULT_SERVER); // Another server; back to the built-in one; off. assert_eq!(ex(&mut s, "pref.publishServer", json!({"url": "wss://share.example/"}))["url"], "wss://share.example/"); diff --git a/docs/releasing.md b/docs/releasing.md index c6740ee..49b3bb6 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -52,6 +52,22 @@ Windows and draft-release jobs declare `environment: release`; off the `release` environment refuses them (0 steps) and no release is created. The `version` input is applied with `xtask version set` before building, so the binaries report it too. +## The default server + +Share ▸ Online uses the server in Preferences, which starts as the public one built into the app +(`figcraft_engine::live::DEFAULT_SERVER`). Distributions that would rather not ship that default +set `FIGCRAFT_DEFAULT_SERVER` when building: to their own server's address (`wss://host/`), or to +nothing for a build with no default, where online sharing stays off until the user enters a +server (sharing on the local network works either way): + +```sh +FIGCRAFT_DEFAULT_SERVER= cargo build --release -p figcraft # no default server +FIGCRAFT_DEFAULT_SERVER=wss://design.example.org/ cargo build --release -p figcraft +``` + +The release workflow leaves it unset. The public server's terms are in +[`online-sharing-terms.md`](online-sharing-terms.md). + ## What gets built | Platform | Artifacts | Built on | diff --git a/docs/server.md b/docs/server.md index 6f0402e..88d9992 100644 --- a/docs/server.md +++ b/docs/server.md @@ -728,7 +728,8 @@ sudo systemctl start figcraft-server the server; on the server they are stored unencrypted, so the operator and anyone who can read the data directory can read every file. Tell the people who publish to your server so (the README's [Privacy and online sharing](../README.md#privacy-and-online-sharing) says it for the - default public server, whose terms are [online-sharing-terms.md](online-sharing-terms.md): a + default public server, which a build can replace or leave out with `FIGCRAFT_DEFAULT_SERVER` + ([releasing](releasing.md#the-default-server)), and whose terms are [online-sharing-terms.md](online-sharing-terms.md): a starting point for your own), and set `operator_contact` and `terms_url` on a public one. - **Access** is a share link (128-bit random token) per file and access level, an owner token (128-bit) per file published without the key, or the server key (128-bit) for managing files.