Authenticate T5 and T6 telemetry over HTTPS
This commit is contained in:
+19
-8
@@ -1,7 +1,8 @@
|
||||
# TWS T6 Zombies scripts
|
||||
|
||||
Plutonium T6 versions of the T5 server scripts. Defaults live in the scripts,
|
||||
just like T5. There is no separate TWS config file or database setup.
|
||||
just like T5. The telemetry token is embedded in the reporter script; no
|
||||
separate token config or database setup is required.
|
||||
|
||||
| File | Role | Dependencies |
|
||||
| --- | --- | --- |
|
||||
@@ -20,7 +21,9 @@ just like T5. There is no separate TWS config file or database setup.
|
||||
2. For telemetry or leaderboard, install [t6-gsc-utils v3.1.1](https://github.com/alicealys/t6-gsc-utils/releases/tag/v3.1.1)
|
||||
in `Plutonium/plugins/` and restart the server process. The other five scripts
|
||||
do not require that plugin.
|
||||
3. Restart the map to load script updates.
|
||||
3. Ensure the API service's `EC_TELEMETRY_TOKEN` matches the token embedded in
|
||||
the reporter; see [authentication setup](../README.md#telemetry-authentication-t5-and-t6).
|
||||
4. Restart the map to load script updates.
|
||||
|
||||
If upgrading from the earlier leaderboard filename, **remove
|
||||
`tws_leaderboard.gsc` from the T6 server script directory** before installing
|
||||
@@ -86,14 +89,15 @@ their module's initialization so the list stays current.
|
||||
- Lock uses T5's HUD round/game-over notifications. Default threshold is 20.
|
||||
As in T5, it clears `g_password` at startup and game over.
|
||||
- Telemetry is enabled by default and posts to
|
||||
`http://192.168.1.199:3000/api/telemetry`. Set `tws_server_id` to the exact,
|
||||
`https://ec.thewrightserver.net/api/telemetry`. Set `tws_server_id` to the exact,
|
||||
case-sensitive Electric Cherry registry name; missing or overlong names
|
||||
disable reporting with a console diagnostic.
|
||||
disable reporting with a console diagnostic. An embedded token matching the service's
|
||||
`EC_TELEMETRY_TOKEN` (at least 32 characters) and an HTTPS URL are required as well.
|
||||
|
||||
The optional dvars already present in T5 are still supported: `tws_lock_round`,
|
||||
The dvars already present in T5 are still supported: `tws_lock_round`,
|
||||
`tws_server_id`, `tws_telemetry_url`, and `tws_telemetry_enabled` (`0` disables
|
||||
telemetry). None require a separate config file. If earlier settings are already
|
||||
set on the server, they still override these defaults.
|
||||
telemetry). Earlier settings still override defaults; remove any old HTTP URL
|
||||
override when upgrading. The reporter token lives in `level.telemetry_token`.
|
||||
|
||||
## Round telemetry
|
||||
|
||||
@@ -102,9 +106,16 @@ Cherry registry name and full endpoint in your existing server configuration:
|
||||
|
||||
```cfg
|
||||
set tws_server_id "t6_zombie_town_1"
|
||||
set tws_telemetry_url "http://192.168.1.199:3000/api/telemetry"
|
||||
set tws_telemetry_url "https://ec.thewrightserver.net/api/telemetry"
|
||||
```
|
||||
|
||||
The script embeds the reporter token in `level.telemetry_token`; it must match
|
||||
the API service's `EC_TELEMETRY_TOKEN` environment variable. Follow the shared
|
||||
[authentication setup](../README.md#telemetry-authentication-t5-and-t6). Every
|
||||
request includes `Authorization: Bearer <token>` and `Content-Type:
|
||||
application/json`. Token rotation requires updating and redeploying both reporter
|
||||
scripts. Token and endpoint changes require a map restart.
|
||||
|
||||
It sends four event types over the life of a match, mirroring the T5 script:
|
||||
|
||||
| Event | When | Round in payload |
|
||||
|
||||
+17
-1
@@ -26,7 +26,22 @@ init()
|
||||
|
||||
level.telemetry_url = GetDvar("tws_telemetry_url");
|
||||
if (level.telemetry_url == "")
|
||||
level.telemetry_url = "http://192.168.1.199:3000/api/telemetry";
|
||||
level.telemetry_url = "https://ec.thewrightserver.net/api/telemetry";
|
||||
|
||||
if (getSubStr(toLower(level.telemetry_url), 0, 8) != "https://")
|
||||
{
|
||||
println("^1[tws_t6_telemetry] Telemetry disabled: tws_telemetry_url must use HTTPS");
|
||||
return;
|
||||
}
|
||||
|
||||
// Shared reporter secret; update both scripts when rotating it.
|
||||
// This must match Electric Cherry's EC_TELEMETRY_TOKEN environment variable.
|
||||
level.telemetry_token = "e03a03f7d22418f0c062b0b2a7317fd91b1194c4400e84b469866de501180dc2";
|
||||
if (level.telemetry_token.size < 32)
|
||||
{
|
||||
println("^1[tws_t6_telemetry] Telemetry disabled: embedded telemetry token must be at least 32 characters");
|
||||
return;
|
||||
}
|
||||
|
||||
level.telemetry_server = GetDvar("tws_server_id");
|
||||
if (level.telemetry_server == "" || level.telemetry_server.size > 255)
|
||||
@@ -292,6 +307,7 @@ telemetry_send(entry)
|
||||
|
||||
headers = [];
|
||||
headers["Content-Type"] = "application/json";
|
||||
headers["Authorization"] = "Bearer " + level.telemetry_token;
|
||||
|
||||
options = [];
|
||||
options["method"] = "POST";
|
||||
|
||||
Reference in New Issue
Block a user