feat(ogl): German console and Robust ES256 archive feature control (#201)
* feat(ogl): German simulator help and Robust-signed archive feature control * fix(ci): avoid duplicate NodeAgent section marker in commented example
This commit is contained in:
1 parent
c86d87ea15
commit
6c3f6e7ff5
21 files changed
+1145
-5
No files matched your search
@@ -467,6 +467,10 @@ jobs:
|
||||
shell: bash
|
||||
run: dotnet run --configuration Release --project tools/ci/CrossRegionNexBusProcessRegression/CrossRegionNexBusProcessRegression.csproj
|
||||
|
||||
- name: OGL German console and signed feature licenses
|
||||
shell: bash
|
||||
run: dotnet run --configuration Release --project tools/ci/OglFeatureControlRegression/OglFeatureControlRegression.csproj
|
||||
|
||||
- name: Runtime LSL core conformance (0.9.3.11)
|
||||
shell: bash
|
||||
run: dotnet run --configuration Release --project tools/ci/LslConformanceRegression/LslConformanceRegression.csproj
|
||||
|
||||
@@ -68,6 +68,9 @@ namespace NexVerse.RegionModules.Archives
|
||||
|
||||
public OglIarOperation StartExport(UUID requestId, UserAccount user, string inventoryPath, string archiveFileName, Dictionary<string, object> options = null)
|
||||
{
|
||||
OpenSim.Framework.OglArchiveFeatureGate.Require(
|
||||
OpenSim.Framework.OglArchiveFeatureGate.IarExport);
|
||||
|
||||
string path = m_Storage.ResolveArchivePath(archiveFileName);
|
||||
Directory.CreateDirectory(m_Storage.RootDirectory);
|
||||
OglIarOperation operation = Create(requestId, OglIarOperationKind.Export, user, inventoryPath, path, false);
|
||||
@@ -95,6 +98,9 @@ namespace NexVerse.RegionModules.Archives
|
||||
|
||||
public OglIarOperation StartImport(UUID requestId, UserAccount user, string inventoryPath, string archiveFileName, bool merge, bool dryRun)
|
||||
{
|
||||
OpenSim.Framework.OglArchiveFeatureGate.Require(
|
||||
OpenSim.Framework.OglArchiveFeatureGate.IarImport);
|
||||
|
||||
string path = m_Storage.ResolveArchivePath(archiveFileName);
|
||||
if (!m_Storage.AcceptsExistingArchive(path, out string reason))
|
||||
throw new InvalidOperationException(reason);
|
||||
|
||||
@@ -70,6 +70,9 @@ namespace NexVerse.RegionModules.Archives
|
||||
|
||||
public OglOarOperation StartExport(Guid requestId, string archiveFileName, Dictionary<string, object> options = null)
|
||||
{
|
||||
OpenSim.Framework.OglArchiveFeatureGate.Require(
|
||||
OpenSim.Framework.OglArchiveFeatureGate.OarExport);
|
||||
|
||||
if (requestId == Guid.Empty)
|
||||
throw new ArgumentException("OAR-Request-ID darf nicht leer sein.", nameof(requestId));
|
||||
string path = m_Storage.ResolveArchivePath(archiveFileName);
|
||||
@@ -98,6 +101,9 @@ namespace NexVerse.RegionModules.Archives
|
||||
|
||||
public OglOarOperation StartImport(Guid requestId, string archiveFileName, bool dryRun, Dictionary<string, object> options = null)
|
||||
{
|
||||
OpenSim.Framework.OglArchiveFeatureGate.Require(
|
||||
OpenSim.Framework.OglArchiveFeatureGate.OarImport);
|
||||
|
||||
if (requestId == Guid.Empty)
|
||||
throw new ArgumentException("OAR-Request-ID darf nicht leer sein.", nameof(requestId));
|
||||
string path = m_Storage.ResolveArchivePath(archiveFileName);
|
||||
|
||||
@@ -79,6 +79,7 @@ namespace NexVerse.RegionModules.NodeAgent
|
||||
private IDisposable m_ObjectMessageSubscription;
|
||||
private IDisposable m_EstateScriptMessageSubscription;
|
||||
private IDisposable m_CrossRegionChatSubscription;
|
||||
private IDisposable m_FeaturePolicySubscription;
|
||||
private volatile bool m_MaintenanceMode;
|
||||
private volatile bool m_Draining;
|
||||
private DateTimeOffset m_StartedAt;
|
||||
@@ -258,6 +259,14 @@ namespace NexVerse.RegionModules.NodeAgent
|
||||
if (m_CrossRegionChatMessaging)
|
||||
m_CrossRegionChatSubscription = m_Bus.Subscribe(
|
||||
"chat.neighbor.requested", HandleNeighbourAvatarChat);
|
||||
if (OglArchiveFeatureGate.Enabled)
|
||||
{
|
||||
m_FeaturePolicySubscription = m_Bus.Subscribe(
|
||||
"feature.policy.updated", HandleFeaturePolicy);
|
||||
Publish(new NexEvent("feature.policy.requested",
|
||||
"nexverse.simulator", new Dictionary<string, string>
|
||||
{ ["node_id"] = m_NodeId }));
|
||||
}
|
||||
|
||||
if (m_EstateScriptMessagingEnabled)
|
||||
{
|
||||
@@ -313,6 +322,8 @@ namespace NexVerse.RegionModules.NodeAgent
|
||||
m_EstateScriptMessageSubscription = null;
|
||||
m_CrossRegionChatSubscription?.Dispose();
|
||||
m_CrossRegionChatSubscription = null;
|
||||
m_FeaturePolicySubscription?.Dispose();
|
||||
m_FeaturePolicySubscription = null;
|
||||
foreach (Scene scene in m_Scenes.Values)
|
||||
scene.EventManager.OnChatFromClient -= PublishNeighbourAvatarChat;
|
||||
m_ChatOutboundRates.Clear();
|
||||
@@ -995,6 +1006,27 @@ namespace NexVerse.RegionModules.NodeAgent
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleFeaturePolicy(NexEvent ev)
|
||||
{
|
||||
if (!OglArchiveFeatureGate.Enabled || ev?.Data == null ||
|
||||
!string.Equals(ev.Source, "opengenesislink.world-api", StringComparison.Ordinal) ||
|
||||
!ev.Data.TryGetValue("node_id", out string node) ||
|
||||
!ev.Data.TryGetValue("revision", out string revisionRaw) ||
|
||||
!long.TryParse(revisionRaw, out long revision) ||
|
||||
!ev.Data.TryGetValue("expires", out string expiryRaw) ||
|
||||
!long.TryParse(expiryRaw, out long expires) ||
|
||||
!ev.Data.TryGetValue("flags", out string flagsRaw) ||
|
||||
!int.TryParse(flagsRaw, out int flags) ||
|
||||
!ev.Data.TryGetValue("signature", out string signature))
|
||||
return;
|
||||
|
||||
if (OglArchiveFeatureGate.Apply(node, revision, expires, flags, signature))
|
||||
m_Log.InfoFormat("[OGL FEATURE CONTROL]: Richtlinie von Robust aktualisiert: Node {0}, Flags {1}.",
|
||||
node, flags);
|
||||
else
|
||||
m_Log.Warn("[OGL FEATURE CONTROL]: Ungültige, fremde oder abgelaufene Richtlinie verworfen.");
|
||||
}
|
||||
|
||||
private void PublishHeartbeatSafe()
|
||||
{
|
||||
try
|
||||
|
||||
@@ -332,6 +332,33 @@ input,textarea,select{width:100%;background:#08131e;color:var(--text);border:1px
|
||||
<div class="section">
|
||||
<h2>Node-Details</h2><pre id="nodeDetail">Noch kein Node ausgewählt.</pre>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><span class="icon">✦</span> OGL Feature Control · Simulator-Lizenzen</h2>
|
||||
<p class="sectionlead">Grid-Inhaber vergeben hier die Archivfreigaben der per NexBus registrierten Simulatoren.
|
||||
Die Richtlinie wird automatisch signiert und zur NodeID übertragen. Nur für World-API-Administratoren mit
|
||||
<code>simulators:manage</code> und <code>UserLevel ≥ 200</code>. Ohne Freigabe gilt bei aktivierter
|
||||
<code>[OGLFeatureControl]</code>-Pflicht eine Sperre.</p>
|
||||
<div class="planner-controls">
|
||||
<div><label class="label2">Simulator-NodeID</label><select id="licenseNode" style="width:100%;padding:11px"><option value="">Simulatoren laden …</option></select></div>
|
||||
<div><label class="label2">Lizenzkennung (optional, wird nur als Prüfsumme gespeichert)</label>
|
||||
<input id="licenseKey" type="password" autocomplete="off" placeholder="Bestehende Kennung unverändert lassen"></div>
|
||||
</div>
|
||||
<div class="planner-controls">
|
||||
<label><input id="licenseOarImport" type="checkbox"> OAR importieren</label>
|
||||
<label><input id="licenseOarExport" type="checkbox"> OAR exportieren</label>
|
||||
<label><input id="licenseIarImport" type="checkbox"> IAR importieren</label>
|
||||
<label><input id="licenseIarExport" type="checkbox"> IAR exportieren</label>
|
||||
</div>
|
||||
<div class="planner-actions">
|
||||
<button class="action" id="loadFeatureLicenses">Freigaben laden</button>
|
||||
<button class="action" id="saveFeatureLicense">Richtlinie speichern & übertragen</button>
|
||||
<button class="action" id="revokeFeatureLicense">Alle vier Funktionen sperren</button>
|
||||
</div>
|
||||
<div class="authnote">Die Funktion benötigt eine gültige Simulator-Richtlinienkonfiguration in Robust und NodeAgent.
|
||||
Sperren greifen beim nächsten erfolgreichen NexBus-Ereignis; spätestens mit Ablauf des kurzlebigen Tokens.
|
||||
Archivprüfungen bleiben auch für freigegebene Importe aktiv.</div>
|
||||
<pre id="licenseStatus">Noch keine Lizenzinformationen geladen.</pre>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="page" id="page-changes">
|
||||
@@ -956,6 +983,63 @@ async function loadNodes(){
|
||||
}
|
||||
}
|
||||
|
||||
let oglLicenseNodes=[];
|
||||
function selectedLicense(){
|
||||
const node=$('licenseNode').value;
|
||||
return oglLicenseNodes.find(x=>x.node_id===node);
|
||||
}
|
||||
function showFeatureLicense(){
|
||||
const entry=selectedLicense();
|
||||
for(const [key,field] of [['oar_import','licenseOarImport'],['oar_export','licenseOarExport'],
|
||||
['iar_import','licenseIarImport'],['iar_export','licenseIarExport']])
|
||||
$(field).checked=!!entry?.[key];
|
||||
$('licenseKey').value='';
|
||||
$('licenseStatus').textContent=entry?
|
||||
'Node: '+entry.node_id+' · '+entry.state+' · Revision '+entry.revision+
|
||||
(entry.assigned?' · Richtlinie gespeichert':' · noch keine Richtlinie'): 'Kein Simulator gewählt.';
|
||||
}
|
||||
async function loadFeatureLicenses(){
|
||||
const status=$('licenseStatus');status.textContent='Lade Freigaben …';
|
||||
try{
|
||||
const response=await fetch('/api/v1/feature-control/nodes',{
|
||||
method:'GET',headers:nodeHeaders(),cache:'no-store',credentials:'same-origin'});
|
||||
const data=await response.json();
|
||||
if(!response.ok)throw Error(data.message||data.error||('HTTP '+response.status));
|
||||
oglLicenseNodes=data.nodes||[];
|
||||
const selection=$('licenseNode'),previous=selection.value;
|
||||
selection.replaceChildren();
|
||||
oglLicenseNodes.forEach(node=>{
|
||||
const option=document.createElement('option');option.value=node.node_id;
|
||||
option.textContent=node.node_id+' · '+node.state;selection.append(option);
|
||||
});
|
||||
if(oglLicenseNodes.some(x=>x.node_id===previous))selection.value=previous;
|
||||
showFeatureLicense();
|
||||
if(!oglLicenseNodes.length)status.textContent='Noch keine Simulator-Nodes registriert.';
|
||||
}catch(error){status.textContent='Lizenzdienst nicht verfügbar: '+String(error)}
|
||||
}
|
||||
async function saveFeatureLicense(revoke=false){
|
||||
const node=$('licenseNode').value,status=$('licenseStatus');
|
||||
if(!node){status.textContent='Zuerst eine NodeID auswählen.';return;}
|
||||
if(revoke && !confirm('Alle Archivfunktionen für '+node+' sperren?'))return;
|
||||
const body={
|
||||
oar_import:!revoke&&$('licenseOarImport').checked,
|
||||
oar_export:!revoke&&$('licenseOarExport').checked,
|
||||
iar_import:!revoke&&$('licenseIarImport').checked,
|
||||
iar_export:!revoke&&$('licenseIarExport').checked
|
||||
};
|
||||
if($('licenseKey').value.trim()&&!revoke)body.license_key=$('licenseKey').value.trim();
|
||||
status.textContent='Speichere Richtlinie für '+node+' …';
|
||||
try{
|
||||
const headers={...nodeHeaders(),'Content-Type':'application/json'};
|
||||
const response=await fetch('/api/v1/feature-control/nodes/'+encodeURIComponent(node),{
|
||||
method:'PATCH',headers,credentials:'same-origin',body:JSON.stringify(body)});
|
||||
const data=await response.json();
|
||||
if(!response.ok)throw Error(data.message||data.error||('HTTP '+response.status));
|
||||
await loadFeatureLicenses();
|
||||
status.textContent='Richtlinie für '+node+' aktualisiert und per NexBus übertragen.';
|
||||
}catch(error){status.textContent='Freigabe abgelehnt: '+String(error)}
|
||||
}
|
||||
|
||||
function gridHeaders(){
|
||||
const headers={'Accept':'application/json'};
|
||||
const bearer=$('gridBearer').value.trim()||$('bearer').value.trim()||adminAuthToken();
|
||||
@@ -1649,6 +1733,10 @@ $('searchGridRegions').addEventListener('click',searchGridRegions);$('jumpGridRe
|
||||
$('loadGridNodes').addEventListener('click',loadGridManagedNodes);$('loadGridEstates').addEventListener('click',loadGridEstates);$('createGridRegion').addEventListener('click',createGridRegion);$('moveGridRegion').addEventListener('click',moveGridRegion);
|
||||
$('startGridRegion').addEventListener('click',()=>runGridLifecycle('start'));$('stopGridRegion').addEventListener('click',()=>runGridLifecycle('stop'));$('restartGridRegion').addEventListener('click',()=>runGridLifecycle('restart'));
|
||||
$('loadEstateManagement').addEventListener('click',loadEstateManagement);$('createEstateManagement').addEventListener('click',createEstateManagement);$('updateEstateManagement').addEventListener('click',updateEstateManagement);$('assignEstateRegion').addEventListener('click',assignEstateRegion);
|
||||
$('licenseNode').addEventListener('change',showFeatureLicense);
|
||||
$('loadFeatureLicenses').addEventListener('click',loadFeatureLicenses);
|
||||
$('saveFeatureLicense').addEventListener('click',()=>saveFeatureLicense(false));
|
||||
$('revokeFeatureLicense').addEventListener('click',()=>saveFeatureLicense(true));
|
||||
$('loadNodes').addEventListener('click',loadNodes);$('clearNodesCredentials').addEventListener('click',()=>{$('nodesBearer').value='';$('nodesApiKey').value=''});
|
||||
$('gridWest').addEventListener('click',()=>panGrid(-1,0));$('gridEast').addEventListener('click',()=>panGrid(1,0));$('gridSouth').addEventListener('click',()=>panGrid(0,-1));$('gridNorth').addEventListener('click',()=>panGrid(0,1));
|
||||
$('validateGridPlacement').addEventListener('click',validateGridPlacement);$('gridRegionSizeX').addEventListener('change',()=>{if(gridSelected)validateGridPlacement()});$('gridRegionSizeY').addEventListener('change',()=>{if(gridSelected)validateGridPlacement()});
|
||||
|
||||
@@ -492,6 +492,29 @@ namespace NexVerse.Server.Api
|
||||
apiKeyStore,
|
||||
adminMinimumLevel);
|
||||
|
||||
OglFeatureControlApi featureControl = null;
|
||||
IConfig featureConfig = config.Configs["OGLFeatureControl"];
|
||||
if (featureConfig?.GetBoolean("Enabled", false) == true)
|
||||
{
|
||||
string privateKey = Environment.GetEnvironmentVariable("OGL_FEATURE_PRIVATE_KEY_PEM");
|
||||
if (string.IsNullOrWhiteSpace(privateKey))
|
||||
{
|
||||
string keyPath = featureConfig.GetString("PrivateKeyPath", "");
|
||||
if (string.IsNullOrWhiteSpace(keyPath) || !System.IO.File.Exists(keyPath))
|
||||
throw new InvalidOperationException(
|
||||
"[OGL FEATURE CONTROL] Privater ES256-Schlüssel für Robust fehlt.");
|
||||
privateKey = System.IO.File.ReadAllText(keyPath);
|
||||
}
|
||||
featureControl = new OglFeatureControlApi(
|
||||
featureConfig.GetString("StorePath", "data/ogl-feature-control.json"),
|
||||
privateKey, authenticator, nodeRegistry, eventBus);
|
||||
OglFeatureControlApi registered = featureControl;
|
||||
AppDomain.CurrentDomain.ProcessExit += (_, __) => registered.Dispose();
|
||||
server.AddSimpleStreamHandler(new SimpleStreamHandler(
|
||||
"/api/v1/feature-control", apiGate.Wrap(featureControl.Handle),
|
||||
"OpenGenesisLINK Feature Control"), true);
|
||||
}
|
||||
|
||||
OpenSimNexUserService userService = new OpenSimNexUserService(
|
||||
userAccounts,
|
||||
authentication,
|
||||
@@ -762,7 +785,7 @@ namespace NexVerse.Server.Api
|
||||
"NexVerse Inventory API"),
|
||||
true);
|
||||
|
||||
OglOarApi oarApi = new OglOarApi(authenticator, nodeRegistry, eventBus, jobBridge);
|
||||
OglOarApi oarApi = new OglOarApi(authenticator, nodeRegistry, eventBus, jobBridge, featureControl);
|
||||
server.AddSimpleStreamHandler(
|
||||
new SimpleStreamHandler(
|
||||
"/api/v1/oar",
|
||||
@@ -770,7 +793,7 @@ namespace NexVerse.Server.Api
|
||||
"OpenGenesisLINK OAR API"),
|
||||
true);
|
||||
|
||||
OglIarApi iarApi = new OglIarApi(authenticator, nodeRegistry, userAccounts, eventBus, jobBridge);
|
||||
OglIarApi iarApi = new OglIarApi(authenticator, nodeRegistry, userAccounts, eventBus, jobBridge, featureControl);
|
||||
server.AddSimpleStreamHandler(
|
||||
new SimpleStreamHandler(
|
||||
"/api/v1/iar",
|
||||
|
||||
@@ -181,6 +181,10 @@ namespace NexVerse.Server.Api
|
||||
("get", "Vom NexVerse NodeAgent beobachtete Simulator-Nodes auflisten", "simulators:read", "200")),
|
||||
["/api/v1/nodes/{nodeId}"] = AuthenticatedOperations(
|
||||
("get", "Simulator-Node mit Gesundheits- und Regionszustand lesen", "simulators:read", "200")),
|
||||
["/api/v1/feature-control/nodes"] = AuthenticatedOperations(
|
||||
("get", "Simulator-Funktionsfreigaben auflisten", "simulators:read", "200")),
|
||||
["/api/v1/feature-control/nodes/{nodeId}"] = AuthenticatedOperations(
|
||||
("patch", "Signierte Archivfreigabe je NodeID vergeben oder widerrufen", "simulators:manage", "200")),
|
||||
["/api/v1/estates"] = AuthenticatedOperations(
|
||||
("get", "Estate-Metadaten für Verwaltung und Regionszuordnung durchsuchen", "estates:read", "200"),
|
||||
("post", "Estate mit Owner, Listen und Policies erstellen", "estates:manage", "201")),
|
||||
|
||||
@@ -0,0 +1,293 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using NexVerse.Core.ControlPlane;
|
||||
using log4net;
|
||||
using NexVerse.Core.Messaging;
|
||||
using NexVerse.Core.Security;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Services.Interfaces;
|
||||
|
||||
namespace NexVerse.Server.Api
|
||||
{
|
||||
/// <summary>
|
||||
/// Persistent Robust authority. Privileged node policies are pushed via NexBus,
|
||||
/// signed by Robust's private ES256 key and verified with public keys. Not a software DRM.
|
||||
/// </summary>
|
||||
internal sealed class OglFeatureControlApi : IDisposable
|
||||
{
|
||||
private static readonly ILog m_Log = LogManager.GetLogger(typeof(OglFeatureControlApi));
|
||||
private sealed class NodeRule
|
||||
{
|
||||
public NodeRule() { }
|
||||
public string NodeId { get; set; } = "";
|
||||
public int Flags { get; set; }
|
||||
public long Revision { get; set; }
|
||||
public string LicenseKeyHash { get; set; } = "";
|
||||
}
|
||||
|
||||
private readonly object m_Sync = new object();
|
||||
private readonly Dictionary<string, NodeRule> m_Rules =
|
||||
new Dictionary<string, NodeRule>(StringComparer.OrdinalIgnoreCase);
|
||||
private readonly string m_Path;
|
||||
private readonly string m_PrivateKey;
|
||||
private readonly INexEventBus m_Bus;
|
||||
private readonly NexNodeRegistry m_Nodes;
|
||||
private readonly NexApiAuthenticator m_Auth;
|
||||
private readonly IDisposable m_Heartbeat;
|
||||
private readonly IDisposable m_Online;
|
||||
private readonly IDisposable m_Requested;
|
||||
|
||||
public OglFeatureControlApi(string path, string privateKeyPem, NexApiAuthenticator auth,
|
||||
NexNodeRegistry nodes, INexEventBus bus)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(privateKeyPem))
|
||||
throw new InvalidOperationException(
|
||||
"[OGL FEATURE CONTROL] Privater ES256-Schlüssel fehlt.");
|
||||
using (ECDsa signer = ECDsa.Create())
|
||||
{
|
||||
signer.ImportFromPem(privateKeyPem);
|
||||
if (signer.KeySize != 256)
|
||||
throw new InvalidOperationException("ES256 erfordert P-256.");
|
||||
}
|
||||
m_Path = Path.GetFullPath(path);
|
||||
m_PrivateKey = privateKeyPem;
|
||||
m_Auth = auth ?? throw new ArgumentNullException(nameof(auth));
|
||||
m_Nodes = nodes ?? throw new ArgumentNullException(nameof(nodes));
|
||||
m_Bus = bus ?? throw new ArgumentNullException(nameof(bus));
|
||||
Load();
|
||||
m_Heartbeat = bus.Subscribe("node.heartbeat", Respond);
|
||||
m_Online = bus.Subscribe("node.online", Respond);
|
||||
m_Requested = bus.Subscribe("feature.policy.requested", Respond);
|
||||
}
|
||||
|
||||
private void Load()
|
||||
{
|
||||
if (!File.Exists(m_Path)) return;
|
||||
NodeRule[] rules = JsonSerializer.Deserialize<NodeRule[]>(File.ReadAllText(m_Path));
|
||||
if (rules == null) return;
|
||||
lock (m_Sync)
|
||||
foreach (NodeRule rule in rules)
|
||||
if (ValidNodeId(rule.NodeId) && (rule.Flags & ~OglArchiveFeatureGate.All) == 0)
|
||||
m_Rules[rule.NodeId] = rule;
|
||||
}
|
||||
|
||||
private void SaveLocked()
|
||||
{
|
||||
string folder = Path.GetDirectoryName(m_Path);
|
||||
Directory.CreateDirectory(folder);
|
||||
string tempfile = m_Path + "." + Guid.NewGuid().ToString("N") + ".tmp";
|
||||
try
|
||||
{
|
||||
File.WriteAllText(tempfile, JsonSerializer.Serialize(
|
||||
m_Rules.Values.OrderBy(x => x.NodeId).ToArray()));
|
||||
File.Move(tempfile, m_Path, true);
|
||||
}
|
||||
finally { if (File.Exists(tempfile)) File.Delete(tempfile); }
|
||||
}
|
||||
|
||||
private static bool ValidNodeId(string id) =>
|
||||
!string.IsNullOrWhiteSpace(id) && id.Length <= 128 &&
|
||||
id.All(c => char.IsLetterOrDigit(c) || c == '-' || c == '_' || c == '.');
|
||||
|
||||
private void Respond(NexEvent ev)
|
||||
{
|
||||
if (ev == null || ev.Data == null ||
|
||||
!string.Equals(ev.Source, "nexverse.simulator", StringComparison.Ordinal) ||
|
||||
Math.Abs((DateTimeOffset.UtcNow - ev.Timestamp).TotalSeconds) > 30 ||
|
||||
!ev.Data.TryGetValue("node_id", out string node) || !ValidNodeId(node))
|
||||
return;
|
||||
|
||||
// Do not synthesize a policy for unregistered arbitrary NodeIDs.
|
||||
if (m_Nodes.Get(node) == null &&
|
||||
!string.Equals(ev.Name, "node.online", StringComparison.Ordinal))
|
||||
return;
|
||||
Publish(node);
|
||||
}
|
||||
|
||||
private void Publish(string node)
|
||||
{
|
||||
NodeRule rule;
|
||||
lock (m_Sync) m_Rules.TryGetValue(node, out rule);
|
||||
long revision = rule?.Revision ?? 0;
|
||||
int flags = rule?.Flags ?? 0; // default deny
|
||||
long expires = DateTimeOffset.UtcNow.AddSeconds(120).ToUnixTimeSeconds();
|
||||
m_Bus.Publish(new NexEvent("feature.policy.updated", "opengenesislink.world-api",
|
||||
new Dictionary<string, string>
|
||||
{
|
||||
["node_id"] = node,
|
||||
["revision"] = revision.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
["expires"] = expires.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
["flags"] = flags.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
["signature"] = OglArchiveFeatureGate.Sign(m_PrivateKey, node, revision, expires, flags)
|
||||
}));
|
||||
}
|
||||
|
||||
public bool Permitted(string node, int capability)
|
||||
{
|
||||
lock (m_Sync)
|
||||
return ValidNodeId(node) && m_Rules.TryGetValue(node, out NodeRule policy) &&
|
||||
(policy.Flags & capability) == capability;
|
||||
}
|
||||
|
||||
private object ListSnapshot()
|
||||
{
|
||||
var nodes = m_Nodes.List();
|
||||
lock (m_Sync)
|
||||
{
|
||||
return new
|
||||
{
|
||||
mode = "enforced",
|
||||
operations = new[] { "oar_import", "oar_export", "iar_import", "iar_export" },
|
||||
nodes = nodes.Select(node =>
|
||||
{
|
||||
m_Rules.TryGetValue(node.NodeId, out NodeRule rule);
|
||||
int flags = rule?.Flags ?? 0;
|
||||
return new
|
||||
{
|
||||
node_id = node.NodeId,
|
||||
state = node.State,
|
||||
oar_import = (flags & 1) != 0,
|
||||
oar_export = (flags & 2) != 0,
|
||||
iar_import = (flags & 4) != 0,
|
||||
iar_export = (flags & 8) != 0,
|
||||
revision = rule?.Revision ?? 0,
|
||||
assigned = rule != null
|
||||
};
|
||||
}).ToArray()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public void Handle(IOSHttpRequest request, IOSHttpResponse response)
|
||||
{
|
||||
string method = request?.HttpMethod ?? "";
|
||||
bool write = method.Equals("PATCH", StringComparison.OrdinalIgnoreCase);
|
||||
bool read = method.Equals("GET", StringComparison.OrdinalIgnoreCase);
|
||||
if (!write && !read)
|
||||
{
|
||||
Reply(response, HttpStatusCode.MethodNotAllowed, new { error = "method_not_allowed" });
|
||||
return;
|
||||
}
|
||||
if (!m_Auth.TryAuthenticate(request,
|
||||
write ? NexScopes.SimulatorsManage : NexScopes.SimulatorsRead,
|
||||
out NexPrincipal principal, out UserAccount account,
|
||||
out int status, out string error) || account == null || account.UserLevel < 200)
|
||||
{
|
||||
Reply(response, status >= 400 && status <= 599 ? (HttpStatusCode)status : HttpStatusCode.Forbidden,
|
||||
new { error = "feature_control_forbidden", message = "Grid-Administrator erforderlich." });
|
||||
return;
|
||||
}
|
||||
|
||||
string path = (request.UriPath ?? "").TrimEnd('/');
|
||||
if (read && path.Equals("/api/v1/feature-control/nodes", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Reply(response, HttpStatusCode.OK, ListSnapshot());
|
||||
return;
|
||||
}
|
||||
const string prefix = "/api/v1/feature-control/nodes/";
|
||||
if (!write || !path.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Reply(response, HttpStatusCode.NotFound, new { error = "not_found" });
|
||||
return;
|
||||
}
|
||||
string nodeId = Uri.UnescapeDataString(path.Substring(prefix.Length));
|
||||
if (!ValidNodeId(nodeId) || (m_Nodes.Get(nodeId) == null &&
|
||||
!HasPolicy(nodeId)))
|
||||
{
|
||||
Reply(response, HttpStatusCode.NotFound,
|
||||
new { error = "node_not_found", message = "Unbekannte Simulator-NodeID." });
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using var buffer = new MemoryStream();
|
||||
request.InputStream.CopyTo(buffer);
|
||||
if (buffer.Length > 8192) throw new InvalidDataException("Payload zu groß.");
|
||||
using JsonDocument document = JsonDocument.Parse(buffer.ToArray());
|
||||
JsonElement obj = document.RootElement;
|
||||
int flags = 0;
|
||||
if (Enabled(obj, "oar_import")) flags |= 1;
|
||||
if (Enabled(obj, "oar_export")) flags |= 2;
|
||||
if (Enabled(obj, "iar_import")) flags |= 4;
|
||||
if (Enabled(obj, "iar_export")) flags |= 8;
|
||||
NodeRule previous;
|
||||
lock (m_Sync)
|
||||
{
|
||||
m_Rules.TryGetValue(nodeId, out previous);
|
||||
string keyHash = previous?.LicenseKeyHash ?? "";
|
||||
if (obj.TryGetProperty("license_key", out JsonElement rawKey) &&
|
||||
rawKey.ValueKind == JsonValueKind.String)
|
||||
{
|
||||
string license = rawKey.GetString();
|
||||
if (license.Length < 16 || license.Length > 128)
|
||||
throw new InvalidDataException("Lizenzkennung: 16 bis 128 Zeichen.");
|
||||
keyHash = Convert.ToHexString(
|
||||
SHA256.HashData(Encoding.UTF8.GetBytes(license)));
|
||||
}
|
||||
NodeRule rule = new NodeRule
|
||||
{
|
||||
NodeId = nodeId, Flags = flags,
|
||||
Revision = Math.Max(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
||||
(previous?.Revision ?? 0) + 1),
|
||||
LicenseKeyHash = keyHash
|
||||
};
|
||||
m_Rules[nodeId] = rule;
|
||||
try { SaveLocked(); }
|
||||
catch
|
||||
{
|
||||
if (previous == null) m_Rules.Remove(nodeId);
|
||||
else m_Rules[nodeId] = previous;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
m_Log.WarnFormat(
|
||||
"[OGL LICENSE AUDIT]: Administrator {0} (Level {1}) hat Node {2} auf Archivflags {3} gesetzt.",
|
||||
account.PrincipalID, account.UserLevel, nodeId, flags);
|
||||
Publish(nodeId);
|
||||
Reply(response, HttpStatusCode.OK,
|
||||
new { node_id = nodeId, flags, updated = true });
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Reply(response, HttpStatusCode.BadRequest,
|
||||
new { error = "invalid_policy", message = "Ungültige Freigabe oder Speicherfehler." });
|
||||
}
|
||||
}
|
||||
|
||||
private bool HasPolicy(string node)
|
||||
{
|
||||
lock (m_Sync) return m_Rules.ContainsKey(node);
|
||||
}
|
||||
|
||||
private static bool Enabled(JsonElement doc, string key)
|
||||
{
|
||||
if (!doc.TryGetProperty(key, out JsonElement value) ||
|
||||
(value.ValueKind != JsonValueKind.True && value.ValueKind != JsonValueKind.False))
|
||||
throw new InvalidDataException("Fehlendes boolesches Feld: " + key);
|
||||
return value.ValueKind == JsonValueKind.True;
|
||||
}
|
||||
|
||||
private static void Reply(IOSHttpResponse response, HttpStatusCode status, object payload)
|
||||
{
|
||||
response.StatusCode = (int)status;
|
||||
response.ContentType = "application/json; charset=utf-8";
|
||||
response.RawBuffer = JsonSerializer.SerializeToUtf8Bytes(payload);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
m_Heartbeat.Dispose();
|
||||
m_Online.Dispose();
|
||||
m_Requested.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,15 +18,16 @@ namespace NexVerse.Server.Api
|
||||
{
|
||||
internal sealed class OglIarApi
|
||||
{
|
||||
private readonly OglFeatureControlApi m_Features;
|
||||
private readonly NexApiAuthenticator m_Authenticator;
|
||||
private readonly NexNodeRegistry m_Nodes;
|
||||
private readonly IUserAccountService m_Accounts;
|
||||
private readonly INexEventBus m_Bus;
|
||||
private readonly OglJobEventBridge m_Jobs;
|
||||
|
||||
public OglIarApi(NexApiAuthenticator authenticator, NexNodeRegistry nodes, IUserAccountService accounts, INexEventBus bus, OglJobEventBridge jobs)
|
||||
public OglIarApi(NexApiAuthenticator authenticator, NexNodeRegistry nodes, IUserAccountService accounts, INexEventBus bus, OglJobEventBridge jobs, OglFeatureControlApi features = null)
|
||||
{
|
||||
m_Authenticator=authenticator; m_Nodes=nodes; m_Accounts=accounts; m_Bus=bus; m_Jobs=jobs;
|
||||
m_Authenticator=authenticator; m_Nodes=nodes; m_Accounts=accounts; m_Bus=bus; m_Jobs=jobs; m_Features=features;
|
||||
}
|
||||
|
||||
public void Handle(IOSHttpRequest request, IOSHttpResponse response)
|
||||
@@ -65,6 +66,13 @@ namespace NexVerse.Server.Api
|
||||
NexNodeSnapshot node=m_Nodes.FindNodeForRegion(regionId);
|
||||
if(node==null||!node.State.Equals("online",StringComparison.OrdinalIgnoreCase)){Error(response,HttpStatusCode.ServiceUnavailable,"region_node_unavailable","Simulator der Region ist nicht erreichbar.");return;}
|
||||
|
||||
int capability=string.Equals(action,"import",StringComparison.OrdinalIgnoreCase)
|
||||
? OglArchiveFeatureGate.IarImport : OglArchiveFeatureGate.IarExport;
|
||||
if(m_Features!=null && !m_Features.Permitted(node.NodeId,capability))
|
||||
{
|
||||
Error(response,HttpStatusCode.Forbidden,"feature_not_licensed",
|
||||
OglArchiveFeatureGate.DeniedMessage(capability));return;
|
||||
}
|
||||
Guid id=Guid.NewGuid(); OglJobSnapshot rec=m_Jobs.RegisterOperation("archive.iar."+action,id.ToString(),"world-api",id.ToString(),new Dictionary<string,string>{{"region_id",regionId},{"user_id",userId},{"node_id",node.NodeId},{"action",action},{"file_name",fileName},{"inventory_path",invPath},{"merge",merge.ToString()},{"dry_run",dryRun.ToString()}});
|
||||
m_Bus.Publish(new NexEvent("archive.iar.requested","opengenesislink.world-api",new Dictionary<string,string>{
|
||||
["operation_id"]=id.ToString(),["target_node_id"]=node.NodeId,["region_id"]=regionId,["user_id"]=userId,
|
||||
|
||||
@@ -16,8 +16,9 @@ namespace NexVerse.Server.Api
|
||||
{
|
||||
internal sealed class OglOarApi
|
||||
{
|
||||
private readonly OglFeatureControlApi m_Features;
|
||||
private readonly NexApiAuthenticator m_Authenticator; private readonly NexNodeRegistry m_Nodes; private readonly INexEventBus m_Bus; private readonly OglJobEventBridge m_Jobs;
|
||||
public OglOarApi(NexApiAuthenticator authenticator,NexNodeRegistry nodes,INexEventBus bus,OglJobEventBridge jobs){m_Authenticator=authenticator;m_Nodes=nodes;m_Bus=bus;m_Jobs=jobs;}
|
||||
public OglOarApi(NexApiAuthenticator authenticator,NexNodeRegistry nodes,INexEventBus bus,OglJobEventBridge jobs,OglFeatureControlApi features=null){m_Authenticator=authenticator;m_Nodes=nodes;m_Bus=bus;m_Jobs=jobs;m_Features=features;}
|
||||
|
||||
public void Handle(IOSHttpRequest request,IOSHttpResponse response)
|
||||
{
|
||||
@@ -36,6 +37,13 @@ namespace NexVerse.Server.Api
|
||||
using(doc){JsonElement root=doc.RootElement;string region=Str(root,"region_id"),file=Str(root,"file_name");bool dry=root.TryGetProperty("dry_run",out JsonElement d)&&d.ValueKind==JsonValueKind.True;
|
||||
if(!Guid.TryParse(region,out _)){Error(response,HttpStatusCode.BadRequest,"invalid_region_id","region_id muss eine gueltige UUID sein.");return;} if(string.IsNullOrWhiteSpace(file)){Error(response,HttpStatusCode.BadRequest,"invalid_file_name","file_name ist erforderlich.");return;}
|
||||
NexNodeSnapshot node=m_Nodes.FindNodeForRegion(region);if(node==null||!node.State.Equals("online",StringComparison.OrdinalIgnoreCase)){Error(response,HttpStatusCode.ServiceUnavailable,"region_node_unavailable","Simulator der Region ist nicht erreichbar.");return;}
|
||||
int capability=string.Equals(action,"import",StringComparison.OrdinalIgnoreCase)
|
||||
? OpenSim.Framework.OglArchiveFeatureGate.OarImport : OpenSim.Framework.OglArchiveFeatureGate.OarExport;
|
||||
if(m_Features!=null && !m_Features.Permitted(node.NodeId,capability))
|
||||
{
|
||||
Error(response,HttpStatusCode.Forbidden,"feature_not_licensed",
|
||||
OpenSim.Framework.OglArchiveFeatureGate.DeniedMessage(capability));return;
|
||||
}
|
||||
string id=Guid.NewGuid().ToString(); var job=m_Jobs.RegisterOperation("archive.oar."+action,id,"world-api",id,new Dictionary<string,string>{{"region_id",region},{"node_id",node.NodeId},{"action",action},{"file_name",file},{"dry_run",dry.ToString()}});
|
||||
m_Bus.Publish(new NexEvent("archive.oar.requested","opengenesislink.world-api",new Dictionary<string,string>{{"operation_id",id},{"target_node_id",node.NodeId},{"region_id",region},{"action",action},{"file_name",file},{"dry_run",dry.ToString()}},id)); Json(response,HttpStatusCode.Accepted,job);
|
||||
}
|
||||
|
||||
@@ -103,8 +103,158 @@ namespace OpenSim.Framework.Console
|
||||
/// </summary>
|
||||
/// <param name="helpParts">Parsed parts of the help string. If empty then general help is returned.</param>
|
||||
/// <returns></returns>
|
||||
// OGL localization is presentation-only: the underlying command names,
|
||||
// scripts and remote console protocol remain fully compatible.
|
||||
public bool OglGermanHelp { get; set; }
|
||||
public bool OglExpertHelp { get; set; }
|
||||
|
||||
private static readonly Dictionary<string, string> s_OglTopicNames =
|
||||
new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
["Archiving"] = "Archive und Datensicherung",
|
||||
["Assets"] = "Assets und Speicher",
|
||||
["Comms"] = "Kommunikation",
|
||||
["Debug"] = "Diagnose und Fehleranalyse",
|
||||
["Estates"] = "Estate-Verwaltung",
|
||||
["Friends"] = "Freunde und Kontakte",
|
||||
["General"] = "Allgemein und System",
|
||||
["Help"] = "Hilfe",
|
||||
["Hypergrid"] = "Hypergrid und Netzwerk",
|
||||
["Land"] = "Land und Grundstücke",
|
||||
["NexVerse"] = "OpenGenesisLINK und NexVerse",
|
||||
["Objects"] = "Objekte",
|
||||
["Regions"] = "Regionen",
|
||||
["Terrain"] = "Gelände und Landschaft",
|
||||
["Tree"] = "Vegetation",
|
||||
["Users"] = "Benutzer und Avatare",
|
||||
["yeng"] = "Skriptengine (YEngine)"
|
||||
};
|
||||
|
||||
private static readonly HashSet<string> s_OglExpertTopics =
|
||||
new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||
{ "Debug", "Tree", "yeng", "Friends", "Comms" };
|
||||
|
||||
private static readonly Dictionary<string, string> s_OglCommandDescriptions =
|
||||
new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
["load oar"] = "Regionsarchiv importieren (Freigabe erforderlich).",
|
||||
["save oar"] = "Regionsarchiv exportieren (Freigabe erforderlich).",
|
||||
["load iar"] = "Inventararchiv importieren (Freigabe erforderlich).",
|
||||
["save iar"] = "Inventararchiv exportieren (Freigabe erforderlich).",
|
||||
["show regions"] = "Alle geladenen Regionen anzeigen.",
|
||||
["change region"] = "Aktive Region für nachfolgende Befehle auswählen.",
|
||||
["create region"] = "Eine neue Region erstellen.",
|
||||
["delete-region"] = "Region aus der Simulatorverwaltung entfernen.",
|
||||
["show users"] = "Angemeldete Avatare anzeigen.",
|
||||
["show stats"] = "Leistungs- und Regionsstatistiken anzeigen.",
|
||||
["show status"] = "Aktuellen Simulatorstatus anzeigen.",
|
||||
["show version"] = "Version des Simulators anzeigen.",
|
||||
["help"] = "Die deutsche OpenGenesisLINK-Befehlshilfe anzeigen.",
|
||||
["quit"] = "Den Simulator regulär beenden.",
|
||||
["shutdown"] = "Den Simulator herunterfahren.",
|
||||
["restart"] = "Den Simulator neu starten.",
|
||||
["backup"] = "Eine Datensicherung ausführen."
|
||||
};
|
||||
|
||||
private static string OglDescription(CommandInfo command)
|
||||
{
|
||||
string syntax = command.help_text ?? string.Empty;
|
||||
string[] words = Parser.Parse(syntax);
|
||||
if (words.Length >= 2 &&
|
||||
s_OglCommandDescriptions.TryGetValue(words[0] + " " + words[1], out string description))
|
||||
return description;
|
||||
if (words.Length > 0 &&
|
||||
s_OglCommandDescriptions.TryGetValue(words[0], out description))
|
||||
return description;
|
||||
return s_OglTopicNames.TryGetValue(command.module, out string topic)
|
||||
? "Verwaltung: " + topic + "."
|
||||
: "OpenGenesisLINK-Verwaltungsbefehl.";
|
||||
}
|
||||
|
||||
private List<string> GetOglGermanHelp(string[] cmd)
|
||||
{
|
||||
string query = string.Join(" ", cmd.Skip(1)).Trim();
|
||||
List<string> result = new List<string>
|
||||
{
|
||||
"",
|
||||
"============================================================",
|
||||
" OpenGenesisLINK | SIMULATOR-KONSOLE | DEUTSCHE HILFE",
|
||||
"============================================================"
|
||||
};
|
||||
if (query.Length == 0)
|
||||
{
|
||||
result.Add("Befehle mit Leerzeichen in Anführungszeichen setzen.");
|
||||
result.Add("Beispiel: show object name \"Mein langes Objekt\"");
|
||||
result.Add("");
|
||||
result.Add("THEMENBEREICHE");
|
||||
lock (m_modulesCommands)
|
||||
{
|
||||
foreach (string topic in m_modulesCommands.Keys.OrderBy(x => x, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
if (!OglExpertHelp && s_OglExpertTopics.Contains(topic))
|
||||
continue;
|
||||
result.Add(" " + topic.PadRight(14) + " " +
|
||||
(s_OglTopicNames.TryGetValue(topic, out string label) ? label : topic));
|
||||
}
|
||||
}
|
||||
result.Add("");
|
||||
result.Add(" help all Alle verfügbaren Befehle anzeigen");
|
||||
result.Add(" help Regionen Befehle eines Themenbereichs");
|
||||
result.Add(" help load oar Informationen zu einem Befehl");
|
||||
result.Add(" help suche <Text> Nach Befehlen suchen");
|
||||
result.Add(OglExpertHelp ? " Expertenmodus: AKTIV" :
|
||||
" Expertenbereiche sind ausgeblendet (OGLConsoleExpertHelp=true).");
|
||||
}
|
||||
else
|
||||
{
|
||||
IEnumerable<CommandInfo> commands;
|
||||
lock (m_modulesCommands)
|
||||
{
|
||||
commands = m_modulesCommands.SelectMany(entry =>
|
||||
entry.Value.Where(_ => OglExpertHelp || !s_OglExpertTopics.Contains(entry.Key)))
|
||||
.Distinct().ToArray();
|
||||
}
|
||||
bool all = string.Equals(query, "all", StringComparison.OrdinalIgnoreCase);
|
||||
bool search = query.StartsWith("suche ", StringComparison.OrdinalIgnoreCase);
|
||||
string term = search ? query.Substring(6).Trim() : query;
|
||||
bool topicRequest = s_OglTopicNames.Any(entry =>
|
||||
string.Equals(entry.Key, term, StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(entry.Value, term, StringComparison.OrdinalIgnoreCase));
|
||||
string requestedTopic = topicRequest
|
||||
? s_OglTopicNames.First(entry =>
|
||||
string.Equals(entry.Key, term, StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(entry.Value, term, StringComparison.OrdinalIgnoreCase)).Key
|
||||
: "";
|
||||
var matched = commands.Where(command =>
|
||||
all || (topicRequest ? string.Equals(command.module, requestedTopic,
|
||||
StringComparison.OrdinalIgnoreCase) :
|
||||
search ? (command.help_text.IndexOf(term, StringComparison.OrdinalIgnoreCase) >= 0
|
||||
|| OglDescription(command).IndexOf(term, StringComparison.OrdinalIgnoreCase) >= 0) :
|
||||
string.Equals(command.help_text.Split('[')[0].Split('<')[0].Trim(),
|
||||
term, StringComparison.OrdinalIgnoreCase) ||
|
||||
command.help_text.StartsWith(term + " ", StringComparison.OrdinalIgnoreCase)))
|
||||
.OrderBy(command => command.help_text, StringComparer.OrdinalIgnoreCase).ToArray();
|
||||
result.Add(all ? "ALLE BEFEHLE" : search ? "SUCHERGEBNISSE: " + term :
|
||||
topicRequest ? "THEMA: " + s_OglTopicNames[requestedTopic] : "BEFEHL: " + term);
|
||||
if (matched.Length == 0)
|
||||
result.Add("Keine passenden Befehle gefunden. Mit 'help all' alle Befehle anzeigen.");
|
||||
else
|
||||
{
|
||||
foreach (CommandInfo command in matched)
|
||||
result.Add(" " + command.help_text + "\n " + OglDescription(command));
|
||||
result.Add("");
|
||||
result.Add("Befehlsnamen bleiben aus Kompatibilitätsgründen unverändert.");
|
||||
}
|
||||
}
|
||||
result.Add("============================================================");
|
||||
result.Add("");
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<string> GetHelp(string[] cmd)
|
||||
{
|
||||
if (OglGermanHelp)
|
||||
return GetOglGermanHelp(cmd);
|
||||
List<string> help = new List<string>();
|
||||
List<string> helpParts = new List<string>(cmd);
|
||||
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Grid-controlled permission gate for all OAR/IAR entry points.
|
||||
/// Disabled for legacy installations; when enabled, expired/missing policy DENIES.
|
||||
/// Policies are ES256 signed by Robust. Simulators hold verification keys only.
|
||||
/// </summary>
|
||||
public static class OglArchiveFeatureGate
|
||||
{
|
||||
public const int OarImport = 1;
|
||||
public const int OarExport = 2;
|
||||
public const int IarImport = 4;
|
||||
public const int IarExport = 8;
|
||||
public const int All = OarImport | OarExport | IarImport | IarExport;
|
||||
public const string Support = "info@stadt-nexverse.de";
|
||||
|
||||
private static readonly object s_Sync = new object();
|
||||
private static bool s_Enabled;
|
||||
private static string s_NodeId = "";
|
||||
private static string s_PublicKey = "";
|
||||
private static long s_Revision = -1;
|
||||
private static long s_Expires;
|
||||
private static int s_Allowed;
|
||||
|
||||
public static bool Enabled { get { lock (s_Sync) return s_Enabled; } }
|
||||
|
||||
public static void Configure(bool enabled, string nodeId, string publicKeyPem)
|
||||
{
|
||||
lock (s_Sync)
|
||||
{
|
||||
// Always invalidate the previous snapshot when configuration changes.
|
||||
s_Enabled = enabled;
|
||||
s_NodeId = nodeId?.Trim() ?? "";
|
||||
s_PublicKey = publicKeyPem ?? "";
|
||||
s_Revision = -1;
|
||||
s_Expires = 0;
|
||||
s_Allowed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static string Payload(string node, long revision, long expires, int flags)
|
||||
=> "OGL-FEATURE-V1\n" + node + "\n" +
|
||||
revision.ToString(CultureInfo.InvariantCulture) + "\n" +
|
||||
expires.ToString(CultureInfo.InvariantCulture) + "\n" +
|
||||
flags.ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
public static string Sign(string privateKeyPem, string node, long revision, long expires, int flags)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(privateKeyPem))
|
||||
throw new ArgumentException("Robust benötigt einen privaten ES256-Signaturschlüssel.");
|
||||
using ECDsa signer = ECDsa.Create();
|
||||
signer.ImportFromPem(privateKeyPem);
|
||||
return Convert.ToHexString(signer.SignData(
|
||||
Encoding.UTF8.GetBytes(Payload(node, revision, expires, flags)),
|
||||
HashAlgorithmName.SHA256)).ToLowerInvariant();
|
||||
}
|
||||
|
||||
public static bool Apply(string node, long revision, long expires, int flags, string signature)
|
||||
{
|
||||
lock (s_Sync)
|
||||
{
|
||||
if (!s_Enabled || s_NodeId.Length == 0 || string.IsNullOrWhiteSpace(s_PublicKey) ||
|
||||
!string.Equals(node, s_NodeId, StringComparison.Ordinal) ||
|
||||
revision < s_Revision || revision < 0 || (flags & ~All) != 0 ||
|
||||
expires <= DateTimeOffset.UtcNow.ToUnixTimeSeconds() ||
|
||||
expires > DateTimeOffset.UtcNow.ToUnixTimeSeconds() + 600)
|
||||
return false;
|
||||
try
|
||||
{
|
||||
using ECDsa verifier = ECDsa.Create();
|
||||
verifier.ImportFromPem(s_PublicKey);
|
||||
byte[] actual = Convert.FromHexString(signature ?? "");
|
||||
if (!verifier.VerifyData(
|
||||
Encoding.UTF8.GetBytes(Payload(node, revision, expires, flags)),
|
||||
actual, HashAlgorithmName.SHA256))
|
||||
return false;
|
||||
}
|
||||
catch { return false; }
|
||||
|
||||
// Same revision is allowed for heartbeat renewals from Robust.
|
||||
s_Revision = revision;
|
||||
s_Expires = expires;
|
||||
s_Allowed = flags;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Allowed(int capability)
|
||||
{
|
||||
lock (s_Sync)
|
||||
{
|
||||
if (!s_Enabled) return true; // backwards-compatible opt-in
|
||||
return s_Revision >= 0 &&
|
||||
s_Expires > DateTimeOffset.UtcNow.ToUnixTimeSeconds() &&
|
||||
capability != 0 && (capability & ~All) == 0 &&
|
||||
(s_Allowed & capability) == capability;
|
||||
}
|
||||
}
|
||||
|
||||
public static string DeniedMessage(int capability)
|
||||
=> "[OGL-LIC-403] Für diesen Simulator liegt keine gültige Freigabe für " +
|
||||
(capability == OarImport ? "OAR-Import" :
|
||||
capability == OarExport ? "OAR-Export" :
|
||||
capability == IarImport ? "IAR-Import" : "IAR-Export") +
|
||||
" vor. Bitte wenden Sie sich an " + Support + ".";
|
||||
|
||||
public static void Require(int capability)
|
||||
{
|
||||
if (!Allowed(capability))
|
||||
throw new InvalidOperationException(DeniedMessage(capability));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,6 +168,32 @@ namespace OpenSim
|
||||
}
|
||||
}
|
||||
|
||||
IConfig featureConfig = Config.Configs["OGLFeatureControl"];
|
||||
IConfig nodeConfig = Config.Configs["NexVerseNodeAgent"];
|
||||
string publicPem = Environment.GetEnvironmentVariable("OGL_FEATURE_PUBLIC_KEY_PEM") ?? "";
|
||||
if (string.IsNullOrWhiteSpace(publicPem) &&
|
||||
featureConfig?.GetBoolean("Enabled", false) == true)
|
||||
{
|
||||
string publicPath = featureConfig.GetString("PublicKeyPath", "");
|
||||
if (!string.IsNullOrWhiteSpace(publicPath) && File.Exists(publicPath))
|
||||
publicPem = File.ReadAllText(publicPath);
|
||||
}
|
||||
global::OpenSim.Framework.OglArchiveFeatureGate.Configure(
|
||||
featureConfig?.GetBoolean("Enabled", false) == true,
|
||||
nodeConfig?.GetString("NodeId", Environment.MachineName)?.Trim(),
|
||||
publicPem);
|
||||
if (global::OpenSim.Framework.OglArchiveFeatureGate.Enabled)
|
||||
m_log.Warn("[OGL FEATURE CONTROL]: Aktive Archivfreigabe: ohne gültige Robust-Richtlinie sind alle Archive gesperrt.");
|
||||
|
||||
if (m_console.Commands is Commands oglCommands)
|
||||
{
|
||||
IConfig startup = Config.Configs["Startup"];
|
||||
oglCommands.OglGermanHelp =
|
||||
startup?.GetBoolean("OGLConsoleGermanHelp", true) ?? true;
|
||||
oglCommands.OglExpertHelp =
|
||||
startup?.GetBoolean("OGLConsoleExpertHelp", false) ?? false;
|
||||
}
|
||||
|
||||
m_console.ReadConfig(Config);
|
||||
|
||||
MainConsole.Instance = m_console;
|
||||
@@ -1266,6 +1292,14 @@ namespace OpenSim
|
||||
/// <param name="cmdparams"></param>
|
||||
protected void LoadOar(string module, string[] cmdparams)
|
||||
{
|
||||
if (!global::OpenSim.Framework.OglArchiveFeatureGate.Allowed(
|
||||
global::OpenSim.Framework.OglArchiveFeatureGate.OarImport))
|
||||
{
|
||||
MainConsole.Instance.Output(global::OpenSim.Framework.OglArchiveFeatureGate.DeniedMessage(
|
||||
global::OpenSim.Framework.OglArchiveFeatureGate.OarImport));
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
SceneManager.LoadArchiveToCurrentScene(cmdparams);
|
||||
@@ -1282,6 +1316,14 @@ namespace OpenSim
|
||||
/// <param name="cmdparams"></param>
|
||||
protected void SaveOar(string module, string[] cmdparams)
|
||||
{
|
||||
if (!global::OpenSim.Framework.OglArchiveFeatureGate.Allowed(
|
||||
global::OpenSim.Framework.OglArchiveFeatureGate.OarExport))
|
||||
{
|
||||
MainConsole.Instance.Output(global::OpenSim.Framework.OglArchiveFeatureGate.DeniedMessage(
|
||||
global::OpenSim.Framework.OglArchiveFeatureGate.OarExport));
|
||||
return;
|
||||
}
|
||||
|
||||
SceneManager.SaveCurrentSceneToArchive(cmdparams);
|
||||
}
|
||||
|
||||
|
||||
@@ -289,6 +289,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
public bool ArchiveInventory(
|
||||
UUID id, string firstName, string lastName, string invPath, string pass, Stream saveStream)
|
||||
{
|
||||
OglArchiveFeatureGate.Require(OglArchiveFeatureGate.IarExport);
|
||||
|
||||
return ArchiveInventory(id, firstName, lastName, invPath, pass, saveStream, new Dictionary<string, object>());
|
||||
}
|
||||
|
||||
@@ -296,6 +298,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
UUID id, string firstName, string lastName, string invPath, string pass, Stream saveStream,
|
||||
Dictionary<string, object> options)
|
||||
{
|
||||
OglArchiveFeatureGate.Require(OglArchiveFeatureGate.IarExport);
|
||||
|
||||
if (m_scenes.Count > 0)
|
||||
{
|
||||
UserAccount userInfo = GetUserInfo(firstName, lastName, pass);
|
||||
@@ -336,6 +340,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
public bool ArchiveInventory(
|
||||
UUID id, UserAccount userInfo, string invPath, Stream saveStream, Dictionary<string, object> options)
|
||||
{
|
||||
OglArchiveFeatureGate.Require(OglArchiveFeatureGate.IarExport);
|
||||
|
||||
if (userInfo == null || saveStream == null || m_scenes.Count == 0)
|
||||
return false;
|
||||
|
||||
@@ -355,6 +361,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
public bool DearchiveInventory(
|
||||
UUID id, UserAccount userInfo, string invPath, Stream loadStream, Dictionary<string, object> options)
|
||||
{
|
||||
OglArchiveFeatureGate.Require(OglArchiveFeatureGate.IarImport);
|
||||
|
||||
if (userInfo == null || loadStream == null || m_scenes.Count == 0)
|
||||
return false;
|
||||
|
||||
@@ -379,6 +387,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
UUID id, string firstName, string lastName, string invPath, string pass, string savePath,
|
||||
Dictionary<string, object> options)
|
||||
{
|
||||
OglArchiveFeatureGate.Require(OglArchiveFeatureGate.IarExport);
|
||||
|
||||
// if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, savePath))
|
||||
// return false;
|
||||
|
||||
@@ -421,6 +431,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
|
||||
public bool DearchiveInventory(UUID id, string firstName, string lastName, string invPath, string pass, Stream loadStream)
|
||||
{
|
||||
OglArchiveFeatureGate.Require(OglArchiveFeatureGate.IarImport);
|
||||
|
||||
return DearchiveInventory(id, firstName, lastName, invPath, pass, loadStream, new Dictionary<string, object>());
|
||||
}
|
||||
|
||||
@@ -428,6 +440,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
UUID id, string firstName, string lastName, string invPath, string pass, Stream loadStream,
|
||||
Dictionary<string, object> options)
|
||||
{
|
||||
OglArchiveFeatureGate.Require(OglArchiveFeatureGate.IarImport);
|
||||
|
||||
if (m_scenes.Count > 0)
|
||||
{
|
||||
UserAccount userInfo = GetUserInfo(firstName, lastName, pass);
|
||||
@@ -477,6 +491,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
UUID id, string firstName, string lastName, string invPath, string pass, string loadPath,
|
||||
Dictionary<string, object> options)
|
||||
{
|
||||
OglArchiveFeatureGate.Require(OglArchiveFeatureGate.IarImport);
|
||||
|
||||
if (m_scenes.Count > 0)
|
||||
{
|
||||
UserAccount userInfo = GetUserInfo(firstName, lastName, pass);
|
||||
@@ -533,6 +549,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
/// <param name="cmdparams"></param>
|
||||
protected void HandleLoadInvConsoleCommand(string module, string[] cmdparams)
|
||||
{
|
||||
if (!OglArchiveFeatureGate.Allowed(OglArchiveFeatureGate.IarImport))
|
||||
{
|
||||
m_log.Warn(OglArchiveFeatureGate.DeniedMessage(OglArchiveFeatureGate.IarImport));
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
UUID id = UUID.Random();
|
||||
@@ -601,6 +623,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
/// <param name="cmdparams"></param>
|
||||
protected void HandleSaveInvConsoleCommand(string module, string[] cmdparams)
|
||||
{
|
||||
if (!OglArchiveFeatureGate.Allowed(OglArchiveFeatureGate.IarExport))
|
||||
{
|
||||
m_log.Warn(OglArchiveFeatureGate.DeniedMessage(OglArchiveFeatureGate.IarExport));
|
||||
return;
|
||||
}
|
||||
|
||||
UUID id = UUID.Random();
|
||||
|
||||
Dictionary<string, object> options = new Dictionary<string, object>();
|
||||
|
||||
@@ -100,6 +100,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
/// <param name="cmdparams"></param>
|
||||
public void HandleLoadOarConsoleCommand(string module, string[] cmdparams)
|
||||
{
|
||||
OglArchiveFeatureGate.Require(OglArchiveFeatureGate.OarImport);
|
||||
|
||||
bool mergeOar = false;
|
||||
bool mergeReplaceObjects = false;
|
||||
bool skipAssets = false;
|
||||
@@ -264,6 +266,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
/// <param name="cmdparams"></param>
|
||||
public void HandleSaveOarConsoleCommand(string module, string[] cmdparams)
|
||||
{
|
||||
OglArchiveFeatureGate.Require(OglArchiveFeatureGate.OarExport);
|
||||
|
||||
Dictionary<string, object> options = new Dictionary<string, object>();
|
||||
|
||||
OptionSet ops = new OptionSet();
|
||||
@@ -296,11 +300,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
|
||||
public void ArchiveRegion(string savePath, Dictionary<string, object> options)
|
||||
{
|
||||
OglArchiveFeatureGate.Require(OglArchiveFeatureGate.OarExport);
|
||||
|
||||
ArchiveRegion(savePath, Guid.Empty, options);
|
||||
}
|
||||
|
||||
public void ArchiveRegion(string savePath, Guid requestId, Dictionary<string, object> options)
|
||||
{
|
||||
OglArchiveFeatureGate.Require(OglArchiveFeatureGate.OarExport);
|
||||
|
||||
m_log.InfoFormat(
|
||||
"[ARCHIVER]: Writing archive for region {0} to {1}", Scene.RegionInfo.RegionName, savePath);
|
||||
|
||||
@@ -309,27 +317,37 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
|
||||
public void ArchiveRegion(Stream saveStream)
|
||||
{
|
||||
OglArchiveFeatureGate.Require(OglArchiveFeatureGate.OarExport);
|
||||
|
||||
ArchiveRegion(saveStream, Guid.Empty);
|
||||
}
|
||||
|
||||
public void ArchiveRegion(Stream saveStream, Guid requestId)
|
||||
{
|
||||
OglArchiveFeatureGate.Require(OglArchiveFeatureGate.OarExport);
|
||||
|
||||
ArchiveRegion(saveStream, requestId, new Dictionary<string, object>());
|
||||
}
|
||||
|
||||
public void ArchiveRegion(Stream saveStream, Guid requestId, Dictionary<string, object> options)
|
||||
{
|
||||
OglArchiveFeatureGate.Require(OglArchiveFeatureGate.OarExport);
|
||||
|
||||
new ArchiveWriteRequest(Scene, saveStream, requestId).ArchiveRegion(options);
|
||||
}
|
||||
|
||||
public void DearchiveRegion(string loadPath)
|
||||
{
|
||||
OglArchiveFeatureGate.Require(OglArchiveFeatureGate.OarImport);
|
||||
|
||||
Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
|
||||
DearchiveRegion(loadPath, Guid.Empty, archiveOptions);
|
||||
}
|
||||
|
||||
public void DearchiveRegion(string loadPath, Guid requestId, Dictionary<string, object> options)
|
||||
{
|
||||
OglArchiveFeatureGate.Require(OglArchiveFeatureGate.OarImport);
|
||||
|
||||
m_log.InfoFormat(
|
||||
"[ARCHIVER]: Loading archive to region {0} from {1}", Scene.RegionInfo.RegionName, loadPath);
|
||||
|
||||
@@ -338,11 +356,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
|
||||
public void DearchiveRegion(Stream loadStream)
|
||||
{
|
||||
OglArchiveFeatureGate.Require(OglArchiveFeatureGate.OarImport);
|
||||
|
||||
Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
|
||||
DearchiveRegion(loadStream, Guid.Empty, archiveOptions);
|
||||
}
|
||||
public void DearchiveRegion(Stream loadStream, Guid requestId, Dictionary<string, object> options)
|
||||
{
|
||||
OglArchiveFeatureGate.Require(OglArchiveFeatureGate.OarImport);
|
||||
|
||||
new ArchiveReadRequest(Scene, loadStream, requestId, options).DearchiveRegion();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,3 +235,23 @@
|
||||
|
||||
[Architecture]
|
||||
Include-Architecture = "config-include/Standalone.ini"
|
||||
|
||||
|
||||
; ================================================================
|
||||
; OpenGenesisLINK Feature Control 1.0 - Archivfreigaben (opt-in)
|
||||
; ================================================================
|
||||
[OGLFeatureControl]
|
||||
; Legacy-Verhalten: false. Erst nach Einrichtung von Robust + Nodes
|
||||
; und erfolgreicher Wiederherstellungsprobe auf true setzen.
|
||||
Enabled = false
|
||||
; Simulator erhält NUR den öffentlichen ES256-Prüfschlüssel.
|
||||
; Alternativ OGL_FEATURE_PUBLIC_KEY_PEM in der Prozessumgebung setzen.
|
||||
PublicKeyPath = "config-include/ogl-feature-public.pem"
|
||||
; NodeID muss zur NodeAgent-NodeId passen.
|
||||
; Zusätzlich NexVerseNodeAgent Enabled=true mit authentifiziertem
|
||||
; NexBus und erreichbarem Robust-Peer konfigurieren.
|
||||
|
||||
|
||||
; Anzeigeoptionen unter [Startup]:
|
||||
; OGLConsoleGermanHelp = true
|
||||
; OGLConsoleExpertHelp = false
|
||||
@@ -1022,3 +1022,17 @@
|
||||
|
||||
[MuteListService]
|
||||
LocalServiceModule = "OpenSim.Services.MuteListService.dll:MuteListService"
|
||||
|
||||
|
||||
; ================================================================
|
||||
; OpenGenesisLINK Feature Control 1.0 - Archivfreigaben (opt-in)
|
||||
; ================================================================
|
||||
[OGLFeatureControl]
|
||||
; Legacy-Verhalten: false. Erst nach Einrichtung von Robust + Nodes
|
||||
; und erfolgreicher Wiederherstellungsprobe auf true setzen.
|
||||
Enabled = false
|
||||
; Privater ES256-Signaturschlüssel NUR auf Robust, nicht in Git.
|
||||
; Alternativ OGL_FEATURE_PRIVATE_KEY_PEM in der Prozessumgebung setzen.
|
||||
PrivateKeyPath = "config-include/ogl-feature-private.pem"
|
||||
; Lokaler Persistenzpfad des Robust-Lizenzspeichers.
|
||||
StorePath = "data/ogl-feature-control.json"
|
||||
@@ -756,3 +756,17 @@
|
||||
|
||||
[MuteListService]
|
||||
LocalServiceModule = "OpenSim.Services.MuteListService.dll:MuteListService"
|
||||
|
||||
|
||||
; ================================================================
|
||||
; OpenGenesisLINK Feature Control 1.0 - Archivfreigaben (opt-in)
|
||||
; ================================================================
|
||||
[OGLFeatureControl]
|
||||
; Legacy-Verhalten: false. Erst nach Einrichtung von Robust + Nodes
|
||||
; und erfolgreicher Wiederherstellungsprobe auf true setzen.
|
||||
Enabled = false
|
||||
; Privater ES256-Signaturschlüssel NUR auf Robust, nicht in Git.
|
||||
; Alternativ OGL_FEATURE_PRIVATE_KEY_PEM in der Prozessumgebung setzen.
|
||||
PrivateKeyPath = "config-include/ogl-feature-private.pem"
|
||||
; Lokaler Persistenzpfad des Robust-Lizenzspeichers.
|
||||
StorePath = "data/ogl-feature-control.json"
|
||||
@@ -0,0 +1,140 @@
|
||||
# OpenGenesisLINK 0.9.3.12 – Deutsche Konsole und OGL Feature Control
|
||||
|
||||
## Überblick
|
||||
|
||||
Der Simulator zeigt standardmäßig die deutsche OGL-Hilfe: `help`, `help all`,
|
||||
`help Archiving`, `help Regionen`, `help suche oar`.
|
||||
Befehlsnamen selbst (z. B. `load oar`) bleiben wegen Skript-/OpenSim-
|
||||
Kompatibilität unverändert. Die Übersichten und Kurzbeschreibungen werden
|
||||
deutsch generiert; nicht katalogisierte Befehle erhalten eine allgemeine
|
||||
deutsche Bereichsbeschreibung. Es handelt sich **nicht** um eine Übersetzung
|
||||
jeder einzelnen historischen OpenSimulator-Ausgabe außerhalb der Hilfe.
|
||||
|
||||
In `[Startup]`:
|
||||
|
||||
```ini
|
||||
OGLConsoleGermanHelp = true
|
||||
OGLConsoleExpertHelp = false
|
||||
```
|
||||
|
||||
Im Normalmodus werden Debug, Tree, yeng, Friends und Comms **nur in
|
||||
der Hilfe ausgeblendet**, nicht aus dem Server entfernt. Im Expertenmodus
|
||||
(`true`) werden diese Kategorien wieder angezeigt. Die Einstellung ist
|
||||
keine Berechtigungsgrenze.
|
||||
|
||||
## Archiv-Freigaben zentral durch Robust
|
||||
|
||||
Vier einzeln freischaltbare Flags:
|
||||
|
||||
| Wert | Operation |
|
||||
| --- | --- |
|
||||
| 1 | OAR importieren |
|
||||
| 2 | OAR exportieren |
|
||||
| 4 | IAR importieren |
|
||||
| 8 | IAR exportieren |
|
||||
|
||||
**Konfiguration für Robust (World API):**
|
||||
|
||||
```ini
|
||||
[OGLFeatureControl]
|
||||
Enabled = true
|
||||
StorePath = "data/ogl-feature-control.json"
|
||||
```
|
||||
|
||||
**Konfiguration je OpenSim-Simulator:**
|
||||
|
||||
```ini
|
||||
[OGLFeatureControl]
|
||||
Enabled = true
|
||||
|
||||
[NexVerseNodeAgent]
|
||||
Enabled = true
|
||||
NodeId = "mainland-01"
|
||||
; weitere bestehende PeerUrl/SharedKey/NexBus-Konfiguration
|
||||
```
|
||||
|
||||
Erzeuge einen P-256-ES256-Schlüssel, zum Beispiel mit OpenSSL:
|
||||
|
||||
```bash
|
||||
openssl ecparam -name prime256v1 -genkey -noout -out ogl-feature-ec.pem
|
||||
openssl pkcs8 -topk8 -nocrypt -in ogl-feature-ec.pem -out ogl-feature-private.pem
|
||||
openssl pkey -in ogl-feature-private.pem -pubout -out ogl-feature-public.pem
|
||||
chmod 600 ogl-feature-private.pem
|
||||
```
|
||||
|
||||
Der **private** PEM-Schlüssel wird ausschließlich auf Robust unter
|
||||
`PrivateKeyPath` bereitgestellt (oder `OGL_FEATURE_PRIVATE_KEY_PEM`).
|
||||
Simulator-Nodes erhalten **nur** den öffentlichen PEM-Schlüssel unter
|
||||
`PublicKeyPath` (oder `OGL_FEATURE_PUBLIC_KEY_PEM`).
|
||||
Der private Schlüssel darf niemals in den Simulator-Deployments oder
|
||||
Git-Repositories liegen. Die NexBus-SharedKeys bleiben davon unabhängig. Lass die Funktion
|
||||
bei noch nicht eingerichteten Grids auf `Enabled=false`.
|
||||
|
||||
**Ablauf:** Robust erkennt Simulatoren aus der NexBus-NodeRegistry,
|
||||
speichert Freigaben atomar als JSON pro NodeID und publiziert signierte
|
||||
`feature.policy.updated`-Ereignisse (ECDSA P-256 / SHA-256).
|
||||
Simulatoren beziehen die Richtlinie automatisch beim Node-Start sowie
|
||||
bei Heartbeats erneut, binden sie an ihre NodeID und akzeptieren nur
|
||||
gültige Signaturen, monoton steigende Revisionsstände und höchstens
|
||||
600 Sekunden weit in der Zukunft liegende Ablaufzeiten.
|
||||
|
||||
Die von Robust ausgestellten Richtlinien haben eine **120-Sekunden-TTL**.
|
||||
Ein Widerruf wird über NexBus unmittelbar veröffentlicht. Ist Robust/
|
||||
NexBus unerreichbar, sperren die Simulatoren beim TTL-Ablauf automatisch
|
||||
alle vier Archivoperationen (fail-closed). Ein Netzwerkzustellfehler kann
|
||||
die Sperre während der verbleibenden TTL verzögern; ein augenblicklicher
|
||||
Widerruf ist ohne bestätigte Node-Quittierung **nicht garantiert**.
|
||||
|
||||
**Administrationsoberfläche:** World API `/api/v1/docs` →
|
||||
`Simulator-Nodes` → `OGL Feature Control`. Geschützte Endpunkte:
|
||||
|
||||
- `GET /api/v1/feature-control/nodes` – für `simulators:read` und UserLevel ≥ 200
|
||||
- `PATCH /api/v1/feature-control/nodes/{nodeId}` – für `simulators:manage` und UserLevel ≥ 200
|
||||
|
||||
PATCH-Beispiel:
|
||||
|
||||
```json
|
||||
{"oar_import": false, "oar_export": true,
|
||||
"iar_import": false, "iar_export": true}
|
||||
```
|
||||
|
||||
Optionale `license_key`-Kennungen dürfen 16–128 Zeichen haben.
|
||||
Robust speichert davon ausschließlich einen SHA-256-Fingerabdruck.
|
||||
Die eigentliche Durchsetzung erfolgt nicht durch diese sichtbare
|
||||
Kennung, sondern durch die separat signierten kurzlebigen Node-Policies.
|
||||
NodeIDs müssen eindeutig sein; die aktuelle NexBus-NodeID selbst ist
|
||||
kein kryptografischer Besitznachweis.
|
||||
|
||||
**Durchsetzung im Server**:
|
||||
|
||||
- Legacy-`load/save oar` an der Hauptkonsole und im Regions-Archiver
|
||||
- Alle öffentlichen OAR-`ArchiveRegion/DearchiveRegion`-Aufrufe
|
||||
- Legacy-`load/save iar` und öffentliche IAR-`ArchiveInventory/DearchiveInventory`-Aufrufe
|
||||
- Managed OAR-/IAR-OperationManager
|
||||
- Robust World API `/api/v1/oar/*` und `/api/v1/iar/*` vor Job-Erstellung
|
||||
|
||||
Fehlende/ungültige Freigabe ergibt `OGL-LIC-403` und
|
||||
`info@stadt-nexverse.de`. Unmodifizierte alte OpenSimulator-Versionen,
|
||||
andere externe Importpfade und Betreiber mit vollständiger Kontrolle
|
||||
über modifizierten Quellcode sind damit **nicht** zwangsweise geschützt.
|
||||
|
||||
## Archiv-Sicherheit bleibt zusätzlich nötig
|
||||
|
||||
Eine gültige Freigabe macht ein OAR oder IAR **nicht sicher**. Die
|
||||
bestehenden OGL-Archivvalidatoren und Beschränkungen bleiben erforderlich.
|
||||
Weitere Sicherung (Quoten, Isolation und Import-Audit) ist unabhängig vom
|
||||
Lizenzstatus vor produktiver Aktivierung zu prüfen.
|
||||
|
||||
## Test / Freigabegates
|
||||
|
||||
```bash
|
||||
dotnet run -c Release --project tools/ci/OglFeatureControlRegression/OglFeatureControlRegression.csproj
|
||||
```
|
||||
|
||||
Testet 22 signierte Richtlinien-, Ablauf-, Widerrufs- und Hilfefälle;
|
||||
ist im GitHub-Build eingebunden. Für die **produktive Abnahme** müssen
|
||||
darüber hinaus Live-NexBus-Policy-Updates, Robust-Neustart, Offline-Fall,
|
||||
IAR/OAR-Import/Export, Rollback und echte Rechteentziehung auf einem
|
||||
isolierten Grid getestet werden.
|
||||
|
||||
Version 0.9.3.12 bleibt DEVELOPMENT bis zu den normalen RC/STABLE-Gates.
|
||||
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<Nullable>disable</Nullable>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../../OpenSim/Framework/OpenSim.Framework.csproj"/>
|
||||
<ProjectReference Include="../../../OpenSim/Framework/Console/OpenSim.Framework.Console.csproj"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,106 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
|
||||
internal static class Program
|
||||
{
|
||||
private static int checks;
|
||||
private static void Assert(bool condition, string reason)
|
||||
{
|
||||
++checks;
|
||||
if (!condition) throw new Exception(reason);
|
||||
}
|
||||
|
||||
public static int Main()
|
||||
{
|
||||
try
|
||||
{
|
||||
const string node = "mainland-01";
|
||||
using ECDsa issuer = ECDsa.Create(ECCurve.NamedCurves.nistP256);
|
||||
using ECDsa adversary = ECDsa.Create(ECCurve.NamedCurves.nistP256);
|
||||
string valid = issuer.ExportPkcs8PrivateKeyPem();
|
||||
string publicKey = issuer.ExportSubjectPublicKeyInfoPem();
|
||||
string wrong = adversary.ExportPkcs8PrivateKeyPem();
|
||||
long expiry = DateTimeOffset.UtcNow.AddSeconds(100).ToUnixTimeSeconds();
|
||||
|
||||
OglArchiveFeatureGate.Configure(false, node, "");
|
||||
Assert(OglArchiveFeatureGate.Allowed(OglArchiveFeatureGate.All),
|
||||
"Legacy mode must preserve original archive commands");
|
||||
|
||||
OglArchiveFeatureGate.Configure(true, node, publicKey);
|
||||
Assert(!OglArchiveFeatureGate.Allowed(1), "enabled mode requires an explicit policy");
|
||||
string signed = OglArchiveFeatureGate.Sign(valid, node, 10, expiry, 1 | 8);
|
||||
Assert(!OglArchiveFeatureGate.Apply(node, 10, expiry, 1 | 8,
|
||||
OglArchiveFeatureGate.Sign(wrong, node, 10, expiry, 1 | 8)),
|
||||
"invalid signing secret should never grant access");
|
||||
Assert(!OglArchiveFeatureGate.Apply("foreign-node", 10, expiry, 1 | 8, signed),
|
||||
"a policy for another simulator must not work");
|
||||
Assert(!OglArchiveFeatureGate.Apply(node, 10, expiry, 17,
|
||||
OglArchiveFeatureGate.Sign(valid, node, 10, expiry, 17)),
|
||||
"unsupported permission flag rejected");
|
||||
Assert(OglArchiveFeatureGate.Apply(node, 10, expiry, 1 | 8, signed),
|
||||
"signed policy accepted");
|
||||
Assert(OglArchiveFeatureGate.Allowed(OglArchiveFeatureGate.OarImport),
|
||||
"OAR import enabled");
|
||||
Assert(!OglArchiveFeatureGate.Allowed(OglArchiveFeatureGate.OarExport),
|
||||
"OAR export disabled");
|
||||
Assert(!OglArchiveFeatureGate.Allowed(OglArchiveFeatureGate.IarImport),
|
||||
"IAR import disabled");
|
||||
Assert(OglArchiveFeatureGate.Allowed(OglArchiveFeatureGate.IarExport),
|
||||
"IAR export enabled");
|
||||
Assert(!OglArchiveFeatureGate.Apply(node, 9, expiry, 15,
|
||||
OglArchiveFeatureGate.Sign(valid, node, 9, expiry, 15)),
|
||||
"older revision replay rejected");
|
||||
Assert(OglArchiveFeatureGate.Allowed(1) &&
|
||||
!OglArchiveFeatureGate.Allowed(2), "older revision cannot override permissions");
|
||||
long expired = DateTimeOffset.UtcNow.AddSeconds(-1).ToUnixTimeSeconds();
|
||||
Assert(!OglArchiveFeatureGate.Apply(node, 11, expired, 15,
|
||||
OglArchiveFeatureGate.Sign(valid, node, 11, expired, 15)),
|
||||
"expired policy must be refused");
|
||||
long tooFar = DateTimeOffset.UtcNow.AddHours(2).ToUnixTimeSeconds();
|
||||
Assert(!OglArchiveFeatureGate.Apply(node, 11, tooFar, 15,
|
||||
OglArchiveFeatureGate.Sign(valid, node, 11, tooFar, 15)),
|
||||
"over-long policy duration must be refused");
|
||||
string revoke = OglArchiveFeatureGate.Sign(valid, node, 11, expiry, 0);
|
||||
Assert(OglArchiveFeatureGate.Apply(node, 11, expiry, 0, revoke),
|
||||
"Revocation policy should apply");
|
||||
Assert(!OglArchiveFeatureGate.Allowed(1) &&
|
||||
!OglArchiveFeatureGate.Allowed(8),
|
||||
"revocation must deny previous capabilities");
|
||||
Assert(OglArchiveFeatureGate.DeniedMessage(1).Contains("info@stadt-nexverse.de"),
|
||||
"German support address missing");
|
||||
bool threw = false;
|
||||
try { OglArchiveFeatureGate.Require(1); }
|
||||
catch (InvalidOperationException) { threw = true; }
|
||||
Assert(threw, "direct executable guard must throw");
|
||||
|
||||
Commands help = new Commands { OglGermanHelp = true, OglExpertHelp = false };
|
||||
help.AddCommand("Archiving", false, "load oar", "load oar <file>",
|
||||
"Load archive", (module, arguments) => { });
|
||||
help.AddCommand("Debug", false, "debug foo", "debug foo",
|
||||
"Debug command", (module, arguments) => { });
|
||||
string summary = string.Join("\n", help.GetHelp(new[] { "help" }));
|
||||
Assert(summary.Contains("SIMULATOR-KONSOLE") && summary.Contains("Archiv"),
|
||||
"German OGL console summary");
|
||||
Assert(!summary.Contains("Diagnose und Fehleranalyse"),
|
||||
"expert-only section should be hidden");
|
||||
string all = string.Join("\n", help.GetHelp(new[] { "help", "all" }));
|
||||
Assert(all.Contains("Regionsarchiv importieren") && !all.Contains("debug foo"),
|
||||
"all help only shows localized standard commands");
|
||||
help.OglExpertHelp = true;
|
||||
Assert(string.Join("\n", help.GetHelp(new[] { "help", "all" }))
|
||||
.Contains("debug foo"), "expert mode should reveal hidden topic");
|
||||
OglArchiveFeatureGate.Configure(false, "", "");
|
||||
Console.WriteLine("OGL Feature Control + german console: PASS (" + checks + " checks)");
|
||||
return 0;
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
Console.Error.WriteLine("OGL Feature Control FAIL: " + error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user