chiark / gitweb /
public_url config
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 13 Nov 2020 21:34:12 +0000 (21:34 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 13 Nov 2020 21:34:12 +0000 (21:34 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
server.toml
src/config.rs
src/global.rs

index 316bca4cd0ad74b305fb8271b077dcd881a00049..3fe1a513ead4e053205f9b2645a0f099b8902c60 100644 (file)
@@ -7,6 +7,8 @@
 
 # USER=rustcargo target/debug/otter --config ~ian/Rustup/Game/server/server.toml --scope-server reset --reset-table ~ian/Rustup/Game/server/demo/test.table.toml dummy  ~ian/Rustup/Game/server/demo/test.game.toml
 
+public_url = "http://localhost:8000"
+
 save_directory = "/home/rustcargo/Rustup/Game/server"
 template_dir = "/home/ian/Rustup/Game/server/templates"
 bundled_sources = "/home/rustcargo/Rustup/Game/server/target/bundled-sources"
index a05841a87cd8ef569e1aeafaf7691f94e00f549f..9a623b0e96eb42f39381b0d2b01114c371a88346 100644 (file)
@@ -18,6 +18,7 @@ pub struct ServerConfigSpec {
   pub command_socket: Option<String>,
   pub debug: Option<bool>,
   pub http_port: Option<u16>,
+  pub public_url: String,
   pub rocket_workers: Option<u16>,
   pub template_dir: Option<String>,
   pub wasm_dir: Option<String>,
@@ -32,6 +33,7 @@ pub struct ServerConfig {
   pub command_socket: String,
   pub debug: bool,
   pub http_port: Option<u16>,
+  pub public_url: String,
   pub rocket_workers: u16,
   pub template_dir: String,
   pub wasm_dir: String,
@@ -46,7 +48,7 @@ impl TryFrom<ServerConfigSpec> for ServerConfig {
   fn try_from(spec: ServerConfigSpec) -> ServerConfig {
     let ServerConfigSpec {
       save_directory, command_socket, debug,
-      http_port, rocket_workers, template_dir, wasm_dir,
+      http_port, public_url, rocket_workers, template_dir, wasm_dir,
       log, bundled_sources, shapelibs,
     } = spec;
 
@@ -93,7 +95,7 @@ impl TryFrom<ServerConfigSpec> for ServerConfig {
 
     ServerConfig {
       save_directory, command_socket, debug,
-      http_port, rocket_workers, template_dir, wasm_dir,
+      http_port, public_url, rocket_workers, template_dir, wasm_dir,
       log, bundled_sources, shapelibs,
     }
   }
index 64fd7f6798678d245217cf8e9bbdc8e6256a2e4b..8bf880a1828882ed5684aacec7162e3a1df1d504 100644 (file)
@@ -719,9 +719,10 @@ impl<'ig> InstanceGuard<'ig> {
     let ipl = &self.c.g.iplayers.byid(player)?.ipl;
     let gpl = self.c.g.gs.players.byid(player)?;
 
-    let report = AccessTokenReport {
-      url: format!("http://localhost:8000/{}", token.0), // xxx
-    };
+    let url = format!("{}/{}",
+                      &config().public_url.trim_start_matches("/"),
+                      token.0);
+    let report = AccessTokenReport { url };
     let report = access
       .server_deliver(&gpl, &ipl, &report)?;
     report.cloned()