From 1e8fe6cbbce2e130c7f26d9ce22bc9d888f3fecf Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 13 Nov 2020 21:34:12 +0000 Subject: [PATCH] public_url config Signed-off-by: Ian Jackson --- server.toml | 2 ++ src/config.rs | 6 ++++-- src/global.rs | 7 ++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/server.toml b/server.toml index 316bca4c..3fe1a513 100644 --- a/server.toml +++ b/server.toml @@ -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" diff --git a/src/config.rs b/src/config.rs index a05841a8..9a623b0e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -18,6 +18,7 @@ pub struct ServerConfigSpec { pub command_socket: Option, pub debug: Option, pub http_port: Option, + pub public_url: String, pub rocket_workers: Option, pub template_dir: Option, pub wasm_dir: Option, @@ -32,6 +33,7 @@ pub struct ServerConfig { pub command_socket: String, pub debug: bool, pub http_port: Option, + pub public_url: String, pub rocket_workers: u16, pub template_dir: String, pub wasm_dir: String, @@ -46,7 +48,7 @@ impl TryFrom 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 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, } } diff --git a/src/global.rs b/src/global.rs index 64fd7f67..8bf880a1 100644 --- a/src/global.rs +++ b/src/global.rs @@ -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() -- 2.30.2