feat(gen1): guarded live-update bridge to existing OGL node updater
This commit is contained in:
1 parent
a542ced14c
commit
cb6006ade4
10 files changed
+143
-6
No files matched your search
@@ -29,13 +29,15 @@ internal sealed class AdminHttpServer : IDisposable
|
||||
private readonly HttpListener _listener = new();
|
||||
private readonly CancellationTokenSource _stop = new();
|
||||
private readonly AdminOperations _operations;
|
||||
private readonly LiveUpdateBridge _liveUpdate;
|
||||
private Task? _acceptTask;
|
||||
private readonly DateTimeOffset _started = DateTimeOffset.UtcNow;
|
||||
|
||||
public AdminHttpServer(ConcurrentDictionary<UUID, Scene> scenes, string storage, int port, int retention, List<(string Name, Uri Uri)> services)
|
||||
public AdminHttpServer(ConcurrentDictionary<UUID, Scene> scenes, string storage, int port, int retention, List<(string Name, Uri Uri)> services, LiveUpdateBridge liveUpdate)
|
||||
{
|
||||
_scenes = scenes;
|
||||
_operations = new AdminOperations(scenes, storage, retention, services);
|
||||
_liveUpdate = liveUpdate;
|
||||
// Binding to any public interface is deliberately unsupported.
|
||||
_listener.Prefixes.Add($"http://127.0.0.1:{port}/");
|
||||
}
|
||||
@@ -336,6 +338,14 @@ internal sealed class AdminHttpServer : IDisposable
|
||||
{
|
||||
await SendAsync(ctx.Response, 200, await _operations.CheckGitAsync(_stop.Token)); return;
|
||||
}
|
||||
if (method == "GET" && route == "/api/updates/live-status")
|
||||
{
|
||||
await SendAsync(ctx.Response, 200, await _liveUpdate.StatusAsync(_stop.Token)); return;
|
||||
}
|
||||
if (method == "POST" && route == "/api/updates/live-start")
|
||||
{
|
||||
await SendAsync(ctx.Response, 202, await _liveUpdate.StartAsync(_stop.Token)); return;
|
||||
}
|
||||
if (method == "POST" && route == "/api/updates/stage")
|
||||
{
|
||||
var payload = await ReadJsonAsync<UpdateRequest>(request);
|
||||
@@ -362,6 +372,7 @@ internal sealed class AdminHttpServer : IDisposable
|
||||
_stop.Cancel();
|
||||
try { _listener.Stop(); _listener.Close(); } catch { }
|
||||
_operations.Dispose();
|
||||
_liveUpdate.Dispose();
|
||||
_sessions.Clear();
|
||||
_stop.Dispose();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace OpenGenesisLINK.Addons.OSWebInterface;
|
||||
|
||||
/// <summary>
|
||||
/// Optional integration with the separately installed and independently
|
||||
/// authenticated OGL G1 live-update systemd service. This DLL NEVER runs
|
||||
/// a shell and NEVER receives script paths/commands from the browser.
|
||||
/// </summary>
|
||||
internal sealed class LiveUpdateBridge : IDisposable
|
||||
{
|
||||
private readonly bool _enabled;
|
||||
private readonly string _nodeId;
|
||||
private readonly string _token;
|
||||
private readonly HttpClient _http;
|
||||
|
||||
public LiveUpdateBridge(bool requested, string nodeId, string serviceUrl, string token)
|
||||
{
|
||||
_nodeId = nodeId;
|
||||
_token = token;
|
||||
bool goodId = nodeId.Length is >= 1 and <= 64 &&
|
||||
char.IsLetterOrDigit(nodeId[0]) &&
|
||||
nodeId.All(c => char.IsLetterOrDigit(c) || c is '.' or '_' or '-');
|
||||
bool local = Uri.TryCreate(serviceUrl, UriKind.Absolute, out Uri? u) &&
|
||||
u.Scheme == "http" && u.Host == "127.0.0.1" &&
|
||||
u.Port is >= 1025 and <= 65535 &&
|
||||
u.AbsolutePath == "/" && u.Query.Length == 0 && u.Fragment.Length == 0;
|
||||
_enabled = requested && goodId && local && Encoding.UTF8.GetByteCount(token) >= 32 &&
|
||||
!OperatingSystem.IsWindows();
|
||||
_http = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false })
|
||||
{
|
||||
BaseAddress = _enabled ? new Uri(serviceUrl.TrimEnd('/') + "/") :
|
||||
new Uri("http://127.0.0.1:19090/"),
|
||||
Timeout = TimeSpan.FromSeconds(6)
|
||||
};
|
||||
}
|
||||
|
||||
private HttpRequestMessage Request(HttpMethod method, string relative, object? body = null)
|
||||
{
|
||||
var req = new HttpRequestMessage(method, relative);
|
||||
req.Headers.Authorization = new AuthenticationHeaderValue("Bearer", _token);
|
||||
if (body is not null)
|
||||
{
|
||||
req.Content = new StringContent(JsonSerializer.Serialize(body), Encoding.UTF8, "application/json");
|
||||
}
|
||||
return req;
|
||||
}
|
||||
|
||||
public async Task<object> StatusAsync(CancellationToken stop)
|
||||
{
|
||||
if (!_enabled) return new { enabled = false, reachable = false, message = "Live-Updates sind nicht aktiviert oder der externe Updater ist nicht sicher konfiguriert." };
|
||||
try
|
||||
{
|
||||
using var request = Request(HttpMethod.Get, "v1/status");
|
||||
using var response = await _http.SendAsync(request, stop);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
return new { enabled = true, reachable = false, message = "Update-Dienst verweigert Statusabfrage: " + (int)response.StatusCode };
|
||||
using var document = JsonDocument.Parse(await response.Content.ReadAsStringAsync(stop));
|
||||
return new { enabled = true, reachable = true, update = document.RootElement.Clone() };
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return new { enabled = true, reachable = false, message = "Updater auf 127.0.0.1 nicht erreichbar" };
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<object> StartAsync(CancellationToken stop)
|
||||
{
|
||||
if (!_enabled) throw new AdminOperations.OperationException(403, "Live-Update-Dienst ist nicht aktiviert.");
|
||||
using var request = Request(HttpMethod.Post, "v1/updates", new
|
||||
{
|
||||
node_id = _nodeId,
|
||||
operation_id = Guid.NewGuid().ToString()
|
||||
});
|
||||
try
|
||||
{
|
||||
using var response = await _http.SendAsync(request, stop);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
throw new AdminOperations.OperationException((int)response.StatusCode, "Update-Dienst hat den Auftrag abgelehnt (" + (int)response.StatusCode + ").");
|
||||
using var document = JsonDocument.Parse(await response.Content.ReadAsStringAsync(stop));
|
||||
return new
|
||||
{
|
||||
accepted = true,
|
||||
update = document.RootElement.Clone(),
|
||||
note = "Updater führt Backup, Git-Aktualisierung und .NET-10-Build eigenständig aus. Anschließend Simulator manuell neu starten."
|
||||
};
|
||||
}
|
||||
catch (AdminOperations.OperationException) { throw; }
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new AdminOperations.OperationException(503, "Lokaler Update-Dienst nicht erreichbar: " + e.GetType().Name);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose() => _http.Dispose();
|
||||
}
|
||||
@@ -68,7 +68,15 @@ public sealed class OSWebInterfaceModule : ISharedRegionModule
|
||||
(endpoint.Scheme == Uri.UriSchemeHttp || endpoint.Scheme == Uri.UriSchemeHttps))
|
||||
services.Add((item.Section, endpoint));
|
||||
}
|
||||
_server = new AdminHttpServer(_scenes, _storage, _port, retention, services);
|
||||
IConfig? node = source?.Configs["NexVerseNodeAgent"];
|
||||
bool liveAllowed = c?.GetBoolean("AllowLiveUpdates", false) == true &&
|
||||
node?.GetBoolean("Enabled", false) == true &&
|
||||
node.GetBoolean("LiveUpdateEnabled", false);
|
||||
string nodeId = node?.GetString("NodeId", Environment.MachineName) ?? Environment.MachineName;
|
||||
string liveUrl = node?.GetString("LiveUpdateServiceUrl", "http://127.0.0.1:19090") ?? "";
|
||||
string liveToken = Environment.GetEnvironmentVariable("OGL_NODE_UPDATER_TOKEN") ?? "";
|
||||
var bridge = new LiveUpdateBridge(liveAllowed, nodeId, liveUrl, liveToken);
|
||||
_server = new AdminHttpServer(_scenes, _storage, _port, retention, services, bridge);
|
||||
_server.Start();
|
||||
Log.Info($"[OS WEBINTERFACE] Enabled on http://127.0.0.1:{_port}/ (loopback only). Configure an HTTPS reverse proxy for remote access.");
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ async function loadJobs(){try{const data=await api("/api/jobs");const rows=(data
|
||||
if(j.download){const a=document.createElement("a");a.href="/api/oar/download?id="+encodeURIComponent(j.id);a.textContent="OAR herunterladen";a.style.color="#69c7fb";x.lastElementChild.replaceChildren(a)}return x});
|
||||
table("job-table",["Region","Art","Status","Upload","Meldung","Download"],rows)}catch(e){notice(e.message,"Aufträge")}}
|
||||
async function loadLogs(){try{$("log-text").textContent=(await api("/api/logs")).content;}catch(e){$("log-text").textContent=e.message}}
|
||||
async function loadUpdates(){try{const d=await api("/api/updates/check");latestSha=d.remote||null;$("local-sha").textContent=d.local||"Kein lokaler Git-Checkout erkannt";$("remote-sha").textContent=d.remote||"–";$("version-note").textContent=(d.newCommitCount!=null?d.newCommitCount+" Commits seit deinem Stand. ":"")+(d.error||d.note||"");const box=$("commits");box.replaceChildren();(d.commits||[]).forEach(c=>{const x=document.createElement("article");x.className="commit";const b=document.createElement("b");b.textContent=c.title;const sm=document.createElement("small");sm.textContent=c.sha.slice(0,12)+" · "+new Date(c.date).toLocaleString("de-DE");x.append(b,sm);box.append(x)})}catch(e){notice(e.message,"GitHub")}}
|
||||
async function loadUpdates(){try{const live=await api("/api/updates/live-status");const status=live.update||{};$("update-live-status").textContent=live.enabled?(live.reachable?("Status: "+(status.state||"unbekannt")+" · Schritt "+(status.phase||0)+"/7 · "+(status.message||"")):live.message):"Nicht aktiviert – AllowLiveUpdates, NodeAgent und externer Updater müssen konfiguriert werden.";$("update-live-start").hidden=!(live.enabled&&live.reachable&&status.state!=="running"&&status.state!=="queued");const d=await api("/api/updates/check");latestSha=d.remote||null;$("local-sha").textContent=d.local||"Kein lokaler Git-Checkout erkannt";$("remote-sha").textContent=d.remote||"–";$("version-note").textContent=(d.newCommitCount!=null?d.newCommitCount+" Commits seit deinem Stand. ":"")+(d.error||d.note||"");const box=$("commits");box.replaceChildren();(d.commits||[]).forEach(c=>{const x=document.createElement("article");x.className="commit";const b=document.createElement("b");b.textContent=c.title;const sm=document.createElement("small");sm.textContent=c.sha.slice(0,12)+" · "+new Date(c.date).toLocaleString("de-DE");x.append(b,sm);box.append(x)})}catch(e){notice(e.message,"GitHub")}}
|
||||
function showView(name){document.querySelectorAll(".view").forEach(v=>v.hidden=v.id!==name);document.querySelectorAll("nav a").forEach(v=>v.classList.toggle("active",v.dataset.view===name));const titles={overview:"Übersicht",regions:"Regionen & Aktionen",archives:"OAR-Archive",network:"Netzwerk & Ports",logs:"Simulator-Logs",updates:"Updates & GitHub"};$("page-title").textContent=titles[name]||"Übersicht";if(name==="logs")loadLogs();if(name==="archives")loadJobs();if(name==="updates")loadUpdates();}
|
||||
document.querySelectorAll("nav a").forEach(a=>a.onclick=e=>{e.preventDefault();showView(a.dataset.view)});
|
||||
$("login-form").onsubmit=async e=>{e.preventDefault();try{const d=await api("/api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:$("username").value,password:$("password").value})});csrf=d.csrf;$("identity").textContent=d.name;$("login-view").hidden=true;$("dashboard").hidden=false;$("password").value="";await refresh();}catch(err){notice(err.message,err.message.includes("Access Denied")?"Access Denied":"Anmeldung fehlgeschlagen")}};
|
||||
@@ -54,9 +54,12 @@ $("logout").onclick=async()=>{try{await api("/api/logout",{method:"POST"})}final
|
||||
$("oar-file").onchange=()=>{$("selected-file").textContent=$("oar-file").files[0]?.name||""};
|
||||
$("oar-export").onclick=async()=>{try{const d=await jsonPost("/api/oar/export",{regionId:$("archive-region").value});notice("OAR-Sicherung gestartet: "+d.id);await loadJobs()}catch(e){notice(e.message,"OAR Export")}};
|
||||
$("oar-import").onclick=()=>{const f=$("oar-file").files[0];if(!f){notice("Bitte zuerst eine .oar-Datei auswählen.");return;}if(f.size>2*1024**3){notice("Die Datei überschreitet 2 GiB.");return;}notice("ACHTUNG: OAR-Import kann alle Objekte und Gelände der gewählten Region überschreiben. Jetzt „"+f.name+"“ importieren?","OAR-Import bestätigen",async()=>{try{const d=await new Promise((resolve,reject)=>{const xhr=new XMLHttpRequest();xhr.open("POST","/api/oar/import?region="+encodeURIComponent($("archive-region").value));xhr.withCredentials=true;xhr.setRequestHeader("Content-Type","application/octet-stream");xhr.setRequestHeader("X-OGL-CSRF",csrf);xhr.upload.onprogress=e=>{if(e.lengthComputable)$("selected-file").textContent="Upload: "+Math.round(e.loaded*100/e.total)+"% ("+f.name+")";};xhr.onerror=()=>reject(new Error("Netzwerkfehler beim OAR Upload"));xhr.onload=()=>{let v;try{v=JSON.parse(xhr.responseText||"{}")}catch{v={error:"Ungültige Serverantwort"}}xhr.status>=200&&xhr.status<300?resolve(v):reject(new Error(v.error||"Upload fehlgeschlagen"))};xhr.send(f)});notice("Import angenommen: "+d.id+". Status im Auftragsbereich sichtbar.");await loadJobs()}catch(e){notice(e.message,"OAR Import")}})};
|
||||
$("update-live-start").onclick=()=>notice("ACHTUNG: Der unabhängige Updater sichert lokale Konfigurationen und führt anschließend git reset --hard origin/main sowie einen .NET-10-Build aus. Die laufenden Binaries können währenddessen verändert werden. Ein Wartungsfenster und ein manueller Simulator-Neustart sind erforderlich. Update jetzt wirklich starten?","Live-Update bestätigen",async()=>{try{const d=await api("/api/updates/live-start",{method:"POST"});notice(d.note||"Live-Update angefordert.","Auftrag angenommen");await loadUpdates()}catch(e){notice(e.message,"Live-Update fehlgeschlagen")}});
|
||||
$("update-stage").onclick=()=>{if(!latestSha){notice("Bitte zuerst GitHub prüfen.");return}notice("Commit "+latestSha.slice(0,12)+" herunterladen und vertrauliche Konfiguration lokal sichern? Es werden keine laufenden Programmdateien verändert.","Update vorbereiten",async()=>{try{const d=await jsonPost("/api/updates/stage",{sha:latestSha});notice(d.note+" Sicherung: "+d.backup,"Download abgeschlossen")}catch(e){notice(e.message,"Update fehlgeschlagen")}})};
|
||||
$("logs-refresh").onclick=loadLogs;$("updates-refresh").onclick=loadUpdates;$("jobs-refresh").onclick=loadJobs;
|
||||
async function bootstrap(){try{const d=await api("/api/me");csrf=d.csrf;$("identity").textContent=d.name;$("dashboard").hidden=false;$("login-view").hidden=true;await refresh()}catch{}}bootstrap();
|
||||
setInterval(()=>{if(!$("dashboard").hidden){refresh();if(!$("archives").hidden)loadJobs()}},30000);
|
||||
|
||||
setInterval(()=>{if(!$("dashboard").hidden&&!$("archives").hidden)loadJobs()},4000);
|
||||
|
||||
setInterval(()=>{if(!$("dashboard").hidden&&!$("updates").hidden)api("/api/updates/live-status").then(d=>{const s=d.update||{};$("update-live-status").textContent=d.enabled?(d.reachable?("Status: "+(s.state||"?")+" · Schritt "+(s.phase||0)+"/7 · "+(s.message||"")):d.message):"Nicht aktiviert";$("update-live-start").hidden=!(d.enabled&&d.reachable&&s.state!=="running"&&s.state!=="queued")}).catch(()=>{})},10000);
|
||||
@@ -45,7 +45,7 @@
|
||||
<section id="archives" class="view" hidden><div class="section-head"><div><h3>OAR-Archive</h3><p>Lokaler Export, Download und Import mit Statusverfolgung. Ein Import verändert Regionsinhalt.</p></div></div><div class="panel"><label>Region auswählen<select id="archive-region"></select></label><div class="button-row"><button id="oar-export" class="primary">OAR-Sicherung erstellen</button><label for="oar-file" class="filelabel">OAR-Datei auswählen<input type="file" id="oar-file" accept=".oar,application/octet-stream" hidden></label><button id="oar-import" class="danger">Ausgewählte OAR importieren</button></div><div class="muted" id="selected-file"></div></div><section class="panel"><div class="section-head"><h3>Archivaufträge</h3><button class="ghost" id="jobs-refresh">Status abfragen</button></div><div id="job-table" class="table-wrap"></div></section></section>
|
||||
<section id="network" class="view" hidden><div class="section-head"><div><h3>Netzwerkdiagnose</h3><p>TCP-/UDP-Listener auf dem Simulatorhost und die konfigurierte Region-Ports</p></div></div><div class="panel notice">Lokale Listener sind keine Bestätigung der externen Erreichbarkeit: Fritz!Box-Portfreigaben, CGNAT und Firewall-Regeln müssen zusätzlich von außerhalb getestet werden.</div><div id="ports-table" class="table-wrap panel"></div></section>
|
||||
<section id="logs" class="view" hidden><div class="section-head"><div><h3>Simulator-Protokoll</h3><p>Letzte 90.000 Zeichen der aktiven Logdatei</p></div><button id="logs-refresh" class="ghost">Log aktualisieren</button></div><pre id="log-text" class="terminal">Lade Protokoll …</pre></section>
|
||||
<section id="updates" class="view" hidden><div class="section-head"><div><h3>GitHub & Versionskontrolle</h3><p>Commit-Stand des offiziellen OpenGenesisLINK-Repositorys</p></div><button id="updates-refresh" class="ghost">GitHub prüfen</button></div><div class="panel"><p>Installierter Commit</p><strong id="local-sha" class="mono">–</strong><p>Aktueller Main-Commit</p><strong id="remote-sha" class="mono">–</strong><div id="version-note" class="muted"></div><div class="button-row"><button class="primary" id="update-stage">Quellcode herunterladen & Konfiguration sichern</button></div></div><section class="panel"><h3>Letzte Änderungen</h3><div id="commits"></div></section><div class="panel notice">Dieser Schritt bereitet ein Update nur vor: GitHub-Quellcode herunterladen, lokale Konfiguration sicher sichern und alte Backups nach Retentionsregel entfernen. Der Build und die Aktivierung der Programmdateien sind ein separater, bewusst manueller Schritt. Kein automatischer Neustart.</div></section>
|
||||
<section id="updates" class="view" hidden><div class="section-head"><div><h3>GitHub & Versionskontrolle</h3><p>Commit-Stand des offiziellen OpenGenesisLINK-Repositorys</p></div><button id="updates-refresh" class="ghost">GitHub prüfen</button></div><div class="panel"><p>Installierter Commit</p><strong id="local-sha" class="mono">–</strong><p>Aktueller Main-Commit</p><strong id="remote-sha" class="mono">–</strong><div id="version-note" class="muted"></div><div class="button-row"><button class="primary" id="update-stage">Quellcode herunterladen & Konfiguration sichern</button></div></div><section class="panel"><h3>Unabhängiger Live-Updater</h3><p id="update-live-status" class="muted">Status wird geprüft ...</p><div class="button-row"><button class="danger" id="update-live-start" hidden>Update installieren (manueller Neustart danach)</button></div></section><section class="panel"><h3>Letzte Änderungen</h3><div id="commits"></div></section><div class="panel notice">Die Download-Schaltfläche bereitet ein Update nur vor: GitHub-Quellcode herunterladen, lokale Konfiguration sicher sichern und alte Backups nach Retentionsregel entfernen. Ein produktives In-place-Update kann optional an den vorhandenen, unabhängig installierten und authentifizierten OGL-Node-Updater delegiert werden. Das erfordert zwei explizite Freigaben und wird vor Start bestätigt. Danach ist ein manueller Neustart erforderlich.</div></section>
|
||||
</main>
|
||||
</div>
|
||||
<div id="modal" class="modal" hidden><div class="dialog" role="alertdialog" aria-modal="true" aria-labelledby="modal-title"><div class="modal-icon">!</div><h3 id="modal-title">Hinweis</h3><p id="modal-message"></p><div class="button-row"><button class="primary" id="modal-ok">Verstanden</button><button class="ghost" id="modal-cancel" hidden>Abbrechen</button></div></div></div>
|
||||
|
||||
@@ -592,3 +592,4 @@
|
||||
Port = 9847
|
||||
DataDirectory = "os-webinterface-data"
|
||||
BackupRetention = 5
|
||||
AllowLiveUpdates = false
|
||||
@@ -475,3 +475,4 @@
|
||||
Port = 9847
|
||||
DataDirectory = "os-webinterface-data"
|
||||
BackupRetention = 5
|
||||
AllowLiveUpdates = false
|
||||
@@ -15,6 +15,7 @@ The HTTP listener binds ONLY to 127.0.0.1. For remote usage, configure an HTTPS
|
||||
Port = 9847
|
||||
DataDirectory = "os-webinterface-data"
|
||||
BackupRetention = 5
|
||||
AllowLiveUpdates = false
|
||||
|
||||
Default Enabled=false; activating requires ONE planned simulator restart. Every simulator process must use a distinct port.
|
||||
|
||||
@@ -35,7 +36,8 @@ Security: cryptographically random one-hour HttpOnly SameSite=Strict sessions; S
|
||||
* Services: probes configured ROBUST/Grid/Asset/Inventory/User/Authentication/Presence/Friends/Hypergrid endpoint TCP reachability (not application-level correctness).
|
||||
* Network: checks local TCP/UDP listeners. External reachability cannot be inferred from this alone: Fritz!Box, NAT/CGNAT, ISP inbound restrictions and firewall must be independently probed from outside the LAN.
|
||||
* Git: check current SHA and latest commit titles on official OpenGenesisLINK main.
|
||||
* Updates: explicitly download a pinned latest-GitHub source snapshot, create private ZIP backup of config including keyfiles, and rotate old backups. No automatic execution of GitHub source, no build and no binary replacement. A trusted build-and-rollback mechanism is required before one-click production activation. Manual restart alone does not install a staged source snapshot.
|
||||
* Safe update staging: explicitly download a pinned latest-GitHub source snapshot, create private ZIP backup of config including keyfiles, and rotate old staging backups. Staging does not compile or overwrite binaries.
|
||||
* Optional live installation: when [OSWebInterface] AllowLiveUpdates=true AND [NexVerseNodeAgent] Enabled=true AND LiveUpdateEnabled=true, and the independent, preinstalled OGL G1 node-updater.service is running on loopback with OGL_NODE_UPDATER_TOKEN, the panel can submit an explicit, confirmed live-update operation. The independent updater backs up configs, fetches official main, runs the .NET 10 build and reports 7 phases. It does NOT restart the simulator. This is an in-place update with potential service disturbance; use a maintenance window and verify rollback before activation. The external updater's backup-retention policy is separate from BackupRetention for web staging.
|
||||
|
||||
## Tests
|
||||
|
||||
@@ -46,3 +48,7 @@ Security: cryptographically random one-hour HttpOnly SameSite=Strict sessions; S
|
||||
Perform local Bomlitz acceptance before enabling on production, including valid/invalid UserLevel login, disposable-region restart, OAR roundtrip, HTTPS reverse proxy and external connectivity testing.
|
||||
|
||||
Note: Update snapshot staging is currently restricted to Linux due to required NTFS ACL enforcement for backups containing secrets on Windows. On Windows, the monitoring and admin functions remain available.
|
||||
|
||||
## Live update installation (optional; Linux only)
|
||||
|
||||
Read the existing standalone updater documentation: doc/OpenGenesisLINK/G1_STANDALONE_NODE_UPDATER.md. Install its systemd unit outside the source checkout, configure the same OGL_NODE_UPDATER_TOKEN (minimum 32 bytes), a valid NodeId and the loopback URL (typically http://127.0.0.1:19090/). This module NEVER runs arbitrary shell commands or accepts browser-supplied repo roots, commands or update URLs. The administrator explicitly confirms the live update; only the independent service performs git reset --hard and builds after backing up the checkout config. Always schedule downtime, back up the database separately, and restart the simulator manually when the independent service shows completed.
|
||||
@@ -39,6 +39,9 @@ try
|
||||
if (staticFile.StatusCode != HttpStatusCode.OK)
|
||||
throw new Exception("Static resource missing: " + path);
|
||||
}
|
||||
using var deniedUpdate = await client.GetAsync("/api/updates/live-status");
|
||||
if (deniedUpdate.StatusCode != HttpStatusCode.Unauthorized)
|
||||
throw new Exception("Unauthenticated live-updater status not denied");
|
||||
using var denied = await client.GetAsync("/api/overview");
|
||||
if (denied.StatusCode != HttpStatusCode.Unauthorized)
|
||||
throw new Exception("Unauthenticated overview not denied");
|
||||
|
||||
@@ -11,11 +11,12 @@ module = text("addons/OSWebInterface/OSWebInterfaceModule.cs")
|
||||
http = text("addons/OSWebInterface/AdminHttpServer.cs")
|
||||
ops = text("addons/OSWebInterface/AdminOperations.cs")
|
||||
updates = text("addons/OSWebInterface/UpdateStager.cs")
|
||||
live = text("addons/OSWebInterface/LiveUpdateBridge.cs")
|
||||
js = text("addons/OSWebInterface/www/app.js")
|
||||
ini_paths = ("bin/OpenSim.ini", "bin/OpenSim.ini.example")
|
||||
for ini in ini_paths:
|
||||
c = text(ini).split("[OSWebInterface]", 1)
|
||||
assert len(c) == 2 and "Enabled = false" in c[1], ini
|
||||
assert len(c) == 2 and "Enabled = false" in c[1] and "AllowLiveUpdates = false" in c[1], ini
|
||||
|
||||
for part in (
|
||||
"<AssemblyName>os_webinterface</AssemblyName>",
|
||||
@@ -35,6 +36,7 @@ for part in (
|
||||
"GetUserAccount(UUID.Zero", "Authenticate(account.PrincipalID",
|
||||
"account.UserLevel <= 0", "!account.LoginAllowed",
|
||||
"Access Denied – Keine Berechtigung.",
|
||||
"_liveUpdate.StatusAsync", "_liveUpdate.StartAsync",
|
||||
"HttpOnly; SameSite=Strict", "X-OGL-CSRF", "SameOrigin(",
|
||||
"Content-Security-Policy", "TrySession(request",
|
||||
'"/api/regions/restart"', '"/api/oar/import"', '"/api/oar/export"',
|
||||
@@ -54,6 +56,9 @@ for part in (
|
||||
"File.Move(tmp, filename)", "git", "latest",
|
||||
):
|
||||
assert part in updates, part
|
||||
for marker in ("v1/status", "v1/updates", "127.0.0.1", "OGL", "Bearer", "_nodeId"):
|
||||
assert marker in live, marker
|
||||
assert "Process.Start(" not in live, "Web DLL must never run arbitrary commands."
|
||||
assert "Process.Start(" not in updates, "Updater must never execute downloaded source."
|
||||
assert "innerHTML" not in js, "Client must avoid arbitrary HTML insertion."
|
||||
assert "textContent" in js
|
||||
|
||||
Reference in new issue
Block a user