Authenticate T5 and T6 telemetry over HTTPS
This commit is contained in:
+9
-4
@@ -354,7 +354,7 @@ and [spawn entry point](https://github.com/plutoniummod/t5-scripts/blob/main/ZM/
|
||||
| `tws_lock_round` | `tws_lock` | `20` | Round at which the lobby locks |
|
||||
| `tws_server_id` | `tws_bank`, `tws_telemetry` | Required for telemetry | Exact registered Electric Cherry server name; also used as the bank label |
|
||||
| `tws_telemetry_enabled` | `tws_telemetry` | `1` | Set to `0` to disable telemetry at init |
|
||||
| `tws_telemetry_url` | `tws_telemetry` | `http://192.168.1.199:3000/api/telemetry` | Electric Cherry telemetry endpoint for JSON POSTs |
|
||||
| `tws_telemetry_url` | `tws_telemetry` | `https://ec.thewrightserver.net/api/telemetry` | Electric Cherry telemetry endpoint for JSON POSTs |
|
||||
| `tws_telemetry_log_level` | `tws_telemetry` | `1` | Read live: `0` warnings/errors/recovery only, `1` lifecycle/request/health logs, `2` also capture/queue logs and response previews |
|
||||
|
||||
## tws_telemetry.gsc
|
||||
@@ -362,13 +362,17 @@ and [spawn entry point](https://github.com/plutoniummod/t5-scripts/blob/main/ZM/
|
||||
Uses `t5-gsc-utils` HTTP/JSON components to POST directly to Electric Cherry's
|
||||
`/api/telemetry`. Install alongside `tws_common.gsc` in `storage/t5/scripts/sp/`.
|
||||
No HUD or database dependency. Reports run whether or not a beta is active.
|
||||
Follow the shared [authentication setup](../README.md#telemetry-authentication-t5-and-t6)
|
||||
to configure the service before upgrading. The reporter token is embedded in
|
||||
`level.telemetry_token`; it must match the service's `EC_TELEMETRY_TOKEN`. Short
|
||||
embedded tokens and non-HTTPS URLs disable reporting at init.
|
||||
|
||||
Example server config (except log level, read at script init; restart the map after changes):
|
||||
|
||||
```cfg
|
||||
set tws_server_id "t5_zombie_prototype_1"
|
||||
set tws_telemetry_enabled "1"
|
||||
set tws_telemetry_url "http://192.168.1.199:3000/api/telemetry"
|
||||
set tws_telemetry_url "https://ec.thewrightserver.net/api/telemetry"
|
||||
set tws_telemetry_log_level "1"
|
||||
```
|
||||
|
||||
@@ -410,8 +414,9 @@ use `jsonSerialize` for escaping.
|
||||
|
||||
Events are captured immediately into an in-memory queue. One HTTP worker
|
||||
POSTs each snapshot once, in gameplay order, with `Content-Type:
|
||||
application/json`, waiting for completion before sending the next. Gameplay
|
||||
and round detection continue while requests are pending. Repeated joins or
|
||||
application/json` and `Authorization: Bearer <token>`, waiting for completion
|
||||
before sending the next. Gameplay and round detection continue while requests
|
||||
are pending. Repeated joins or
|
||||
end notifications do not duplicate start/end reports. At game over, the
|
||||
reporter captures any round change since the last poll, stops detection,
|
||||
and lets the sender drain through `game_end`.
|
||||
|
||||
+17
-1
@@ -21,7 +21,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://")
|
||||
{
|
||||
print("^1[tws_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)
|
||||
{
|
||||
print("^1[tws_telemetry] Telemetry disabled: embedded telemetry token must be at least 32 characters");
|
||||
return;
|
||||
}
|
||||
|
||||
level.telemetry_server = GetDvar("tws_server_id");
|
||||
if (level.telemetry_server == "")
|
||||
@@ -273,6 +288,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