feat(ogl): expose server DSTZone civil clock in public viewer discovery v1
This commit is contained in:
1 parent
46d32af71f
commit
9f811b5b03
3 files changed
+182
-1
No files matched your search
@@ -152,7 +152,7 @@ namespace OpenSim.Server.Handlers.Grid
|
||||
{
|
||||
httpResponse.KeepAlive = false;
|
||||
httpResponse.ContentType = "application/json; charset=utf-8";
|
||||
httpResponse.AddHeader("Cache-Control", "public, max-age=60");
|
||||
httpResponse.AddHeader("Cache-Control", "no-store");
|
||||
httpResponse.AddHeader("X-Content-Type-Options", "nosniff");
|
||||
|
||||
if (!string.Equals(httpRequest.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase))
|
||||
@@ -205,6 +205,10 @@ namespace OpenSim.Server.Handlers.Grid
|
||||
ogl_grid_info = "/ogl/v1/grid-info",
|
||||
ogl_login = (string)null
|
||||
},
|
||||
// Explicit UTC epoch and server-selected civil zone. A legacy
|
||||
// daylight_savings boolean alone cannot replace Pacific Time.
|
||||
// New optional field; existing v1 clients ignore unknown keys.
|
||||
clock = BuildViewerClock(),
|
||||
features = new
|
||||
{
|
||||
legacy_login = true,
|
||||
@@ -223,6 +227,83 @@ namespace OpenSim.Server.Handlers.Grid
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Publish only the selected civil time zone and its CURRENT UTC
|
||||
/// offset, not the full login configuration. The same [LoginService]
|
||||
/// DSTZone setting determines the legacy daylight_savings flag.
|
||||
/// Clients refresh the offset to handle DST transitions or server
|
||||
/// configuration changes; never assume the viewer OS is in this zone.
|
||||
/// </summary>
|
||||
private object BuildViewerClock()
|
||||
{
|
||||
DateTimeOffset now = DateTimeOffset.UtcNow;
|
||||
TimeZoneInfo zone = TimeZoneInfo.Utc;
|
||||
IConfig loginConfig = m_Config?.Configs["LoginService"];
|
||||
string candidates = loginConfig?.GetString(
|
||||
"DSTZone", "America/Los_Angeles;Pacific Standard Time")
|
||||
?? "America/Los_Angeles;Pacific Standard Time";
|
||||
string configured = candidates.Trim();
|
||||
|
||||
if (string.Equals(configured, "local", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
zone = TimeZoneInfo.Local;
|
||||
}
|
||||
else if (!string.Equals(configured, "none", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
bool found = false;
|
||||
foreach (string option in configured.Split(';'))
|
||||
{
|
||||
string id = option.Trim();
|
||||
if (id.Length == 0 || id.Length > 128)
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
zone = TimeZoneInfo.FindSystemTimeZoneById(id);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
catch (TimeZoneNotFoundException) { }
|
||||
catch (InvalidTimeZoneException) { }
|
||||
}
|
||||
|
||||
if (!found)
|
||||
_log.Warn("[OGL VIEWER CLOCK]: DSTZone cannot be resolved; falling back to UTC");
|
||||
}
|
||||
|
||||
TimeSpan offset = zone.GetUtcOffset(now);
|
||||
int offsetSeconds = checked((int)offset.TotalSeconds);
|
||||
DateTimeOffset local = TimeZoneInfo.ConvertTime(now, zone);
|
||||
bool daylight = zone.IsDaylightSavingTime(local);
|
||||
string abbreviation;
|
||||
// A locale-friendly abbreviation is a PRESENTATION detail; the
|
||||
// selected zone and offset still come from ROBUST's config.
|
||||
if (zone.Id == "Europe/Berlin" || zone.Id == "W. Europe Standard Time")
|
||||
{
|
||||
abbreviation = daylight ? "MESZ" : "MEZ";
|
||||
}
|
||||
else if (zone.Equals(TimeZoneInfo.Utc))
|
||||
{
|
||||
abbreviation = "UTC";
|
||||
}
|
||||
else
|
||||
{
|
||||
int abs = Math.Abs(offsetSeconds);
|
||||
abbreviation = string.Format(System.Globalization.CultureInfo.InvariantCulture,
|
||||
"UTC{0}{1:00}:{2:00}", offsetSeconds < 0 ? "-" : "+",
|
||||
abs / 3600, (abs % 3600) / 60);
|
||||
}
|
||||
|
||||
return new
|
||||
{
|
||||
schema = "org.opengenesislink.viewer.clock.v1",
|
||||
unix_time = now.ToUnixTimeSeconds(),
|
||||
timezone = zone.Id,
|
||||
utc_offset_seconds = offsetSeconds,
|
||||
abbreviation
|
||||
};
|
||||
}
|
||||
|
||||
private string PublicLabel(string key, string fallback)
|
||||
{
|
||||
if (!_info.TryGetValue(key, out string value) ||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
# OGL Viewer clock v1 — server-authoritative civil time
|
||||
|
||||
This non-authenticated protocol extension was introduced to remove Firestorm's
|
||||
hardcoded SLT/PST/PDT clock from the TrixieStorm Viewer.
|
||||
|
||||
## Source of truth
|
||||
|
||||
The server reads the **loaded** ROBUST `[LoginService] DSTZone` setting,
|
||||
the same configuration used for legacy login daylight-savings flags. It picks
|
||||
the first valid IANA/Windows zone in the configured semicolon-separated list,
|
||||
or the server's local zone for `DSTZone=local`. `DSTZone=none` or an unresolved
|
||||
zone falls back to UTC. It does not use the timezone of the user's PC.
|
||||
|
||||
On `GET /ogl/v1/grid-info`, `clock` is an optional additional field within
|
||||
the existing schema `org.opengenesislink.viewer.grid-info.v1`:
|
||||
|
||||
```json
|
||||
{
|
||||
"clock": {
|
||||
"schema": "org.opengenesislink.viewer.clock.v1",
|
||||
"unix_time": 1790000000,
|
||||
"timezone": "Europe/Berlin",
|
||||
"utc_offset_seconds": 7200,
|
||||
"abbreviation": "MESZ"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The numeric values above are **illustrative**. Every response is recomputed
|
||||
using the current UTC instant and the server's resolved timezone. No epoch or
|
||||
offset value is hardcoded. The response uses `Cache-Control: no-store`.
|
||||
The transport and legacy login remain unchanged.
|
||||
|
||||
## Viewer integration and DST
|
||||
|
||||
TrixieStorm reads `clock` only from the pinned G1 OGL discovery URL. It
|
||||
validates schema, grid product and configured login target, timestamp bounds,
|
||||
timezone name, display abbreviation and offset range. The clock uses server
|
||||
UTC epoch plus a monotonic elapsed timer; it renders civil time using the
|
||||
received offset, without changing the viewer's process or system timezone.
|
||||
The viewer refreshes the metadata about once per minute and never trusts a
|
||||
received clock field to change authentication endpoints.
|
||||
|
||||
Server response updates will naturally switch between Berlin winter
|
||||
**MEZ (UTC+01:00)** and summer **MESZ (UTC+02:00)**. The refresh can produce
|
||||
a transition delay of up to roughly a minute. When the server is unavailable
|
||||
or is an older version without `clock`, the viewer displays **UTC**, not
|
||||
mislabelled PST. The full IANA zone is retained in a tooltip.
|
||||
|
||||
This is a **wall-clock display** feature. It does not modify simulator day
|
||||
cycles, sun positions, region environment/EEP, LSL time or grid authorization.
|
||||
|
||||
## Verification
|
||||
|
||||
- Winter UTC 2026-01-15: Berlin offset 3600, display MEZ.
|
||||
- Summer UTC 2026-07-15: Berlin offset 7200, display MESZ.
|
||||
- Europe/Berlin DST transition: refresh returns newly effective offset.
|
||||
- Changing `DSTZone` to another valid zone changes the response after ROBUST
|
||||
restarts with the new configuration, no TrixieStorm rebuild needed.
|
||||
- Legacy Firestorm and classic login response remain compatible.
|
||||
- Full Windows/Linux ReleaseOS runtime tests are still required.
|
||||
|
||||
The endpoint is public and intentionally returns no secrets, credentials,
|
||||
NexBus keys or privileged World API data.
|
||||
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Source-level guard for the optional OGL discovery civil-time extension."""
|
||||
from pathlib import Path
|
||||
from datetime import datetime, timezone
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
root = Path(__file__).resolve().parents[2]
|
||||
source = (root / "OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs").read_text()
|
||||
markers = (
|
||||
'clock = BuildViewerClock()',
|
||||
'private object BuildViewerClock()',
|
||||
'm_Config?.Configs["LoginService"]',
|
||||
'"DSTZone"',
|
||||
'TimeZoneInfo.FindSystemTimeZoneById',
|
||||
'now.ToUnixTimeSeconds()',
|
||||
'zone.GetUtcOffset(now)',
|
||||
'TimeZoneInfo.ConvertTime(now, zone)',
|
||||
'org.opengenesislink.viewer.clock.v1',
|
||||
'utc_offset_seconds = offsetSeconds',
|
||||
'httpResponse.AddHeader("Cache-Control", "no-store")',
|
||||
)
|
||||
for marker in markers:
|
||||
assert marker in source, marker
|
||||
zone = ZoneInfo("Europe/Berlin")
|
||||
for instant, seconds, label in (
|
||||
(datetime(2026, 1, 15, 12, tzinfo=timezone.utc), 3600, "MEZ"),
|
||||
(datetime(2026, 7, 15, 12, tzinfo=timezone.utc), 7200, "MESZ"),
|
||||
(datetime(2026, 3, 29, 0, 59, tzinfo=timezone.utc), 3600, "MEZ"),
|
||||
(datetime(2026, 3, 29, 1, 1, tzinfo=timezone.utc), 7200, "MESZ"),
|
||||
(datetime(2026, 10, 25, 0, 59, tzinfo=timezone.utc), 7200, "MESZ"),
|
||||
(datetime(2026, 10, 25, 1, 1, tzinfo=timezone.utc), 3600, "MEZ"),
|
||||
):
|
||||
berlin = instant.astimezone(zone)
|
||||
assert int(berlin.utcoffset().total_seconds()) == seconds
|
||||
assert (("MESZ" if berlin.dst().total_seconds() else "MEZ")) == label
|
||||
print("OGL discovery clock v1 source guard and Berlin DST fixtures passed.")
|
||||
Reference in new issue
Block a user