feat(IAR): WebDAV als Standard-NAS-Backend für OpenVZ, NFS optional (#354)
* feat(iar): introduce TLS-verified, NAS-pinned WebDAV transport for managed archives * feat(iar): enable WebDAV-first resident archive flow in ROBUST without NFS mounts * feat(iar): transfer native simulator IARs to NAS WebDAV with cleanup and fail-closed login * config(iar): default to WebDAV storage, keep NFS opt-in * config(iar): default to WebDAV storage, keep NFS opt-in * config(iar): default to WebDAV storage, keep NFS opt-in * config(sim): document WebDAV native IAR working directory and NAS credentials * config(sim): document WebDAV native IAR working directory and NAS credentials * fix(iar): suppress optional NAS transport until WebDAV endpoint configured * fix(iar): preserve existing admin archive directory in simulator defaults * fix(iar): preserve existing admin archive directory in simulator defaults * test(iar): protect WebDAV default, pinned NAS transport, and legacy NFS gate * docs(iar): replace NFS-only manual with WebDAV default deployment for OpenVZ * fix(ci): terminate legacy IAR config marker string correctly * fix(iar): support secure bounded WebDAV retention scans and retryable PUT * feat(iar): enforce WebDAV retention after job rotation using NAS-owned markers * fix(iar): include TaskCanceledException namespace for WebDAV transport * fix(config): keep simulator INIs compact while defaulting IAR transport to WebDAV * fix(config): keep simulator INIs compact while defaulting IAR transport to WebDAV * ci(sim): allow compact WebDAV IAR section without weakening runtime policy gates * test(iar): compile WebDAV transport with transfer policy regression * test(iar): verify WebDAV TLS policy and GUID-only archive keys * chore(config): keep simulator Architecture include at end after WebDAV module * fix(ci): avoid shadowing resident self-service flag in NodeAgent * fix(iar): isolate WebDAV XML/storage failures inside retention timer * docs(iar): secure secret entry and document marker-guarded WebDAV orphan cleanup
This commit is contained in:
1 parent
1b8fb1cbbc
commit
a7dfac5d2e
13 files changed
+937
-160
No files matched your search
@@ -0,0 +1,367 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
// UGREEN NAS IAR transport: WebDAV over authenticated HTTPS, no kernel mount.
|
||||
// Persistent archive bytes live on the NAS; native OpenSim archiver uses bounded
|
||||
// local working files that must be removed after import/export completes.
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Sockets;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace NexVerse.Core.Archives
|
||||
{
|
||||
public sealed class OglIarWebDavStorage : IDisposable
|
||||
{
|
||||
private readonly HttpClient m_Http;
|
||||
private readonly Uri m_Root;
|
||||
private readonly string m_NasHost;
|
||||
private readonly string m_Auth;
|
||||
public const string BackendName = "WebDAV";
|
||||
|
||||
// WebDAV URL must refer to a dedicated existing folder (not the NAS
|
||||
// service root). TLS hostname verification remains enabled. The socket
|
||||
// is pinned to 10.78.0.4 so DNS cannot move backups off the VPN.
|
||||
public OglIarWebDavStorage(string baseUrl, string nasHost, string user,
|
||||
string passwordFile)
|
||||
{
|
||||
if (nasHost != "10.78.0.4" ||
|
||||
!Uri.TryCreate(baseUrl, UriKind.Absolute, out Uri uri) ||
|
||||
uri.Scheme != Uri.UriSchemeHttps || uri.Port <= 0 ||
|
||||
!string.IsNullOrEmpty(uri.UserInfo) || !string.IsNullOrEmpty(uri.Query) ||
|
||||
!string.IsNullOrEmpty(uri.Fragment) || uri.AbsolutePath == "/" ||
|
||||
uri.AbsolutePath.Contains("%", StringComparison.Ordinal) ||
|
||||
uri.AbsolutePath.Contains("..", StringComparison.Ordinal) ||
|
||||
string.IsNullOrWhiteSpace(user) || user.Contains(':') ||
|
||||
string.IsNullOrWhiteSpace(passwordFile) ||
|
||||
!Path.IsPathFullyQualified(passwordFile))
|
||||
throw new ArgumentException("IAR WebDAV requires a pinned NAS, HTTPS folder URL and secret file.");
|
||||
if (OperatingSystem.IsLinux())
|
||||
{
|
||||
UnixFileMode permissions = File.GetUnixFileMode(passwordFile);
|
||||
if ((permissions & (UnixFileMode.GroupRead | UnixFileMode.OtherRead |
|
||||
UnixFileMode.GroupWrite | UnixFileMode.OtherWrite |
|
||||
UnixFileMode.GroupExecute | UnixFileMode.OtherExecute)) != 0)
|
||||
throw new UnauthorizedAccessException("IAR WebDAV password file must be owner-only (0600).");
|
||||
}
|
||||
string password = File.ReadAllText(passwordFile).TrimEnd('\r', '\n');
|
||||
if (string.IsNullOrEmpty(password) || password.IndexOfAny(new[] { '\r', '\n', '\0' }) >= 0)
|
||||
throw new ArgumentException("Invalid IAR WebDAV password file.");
|
||||
m_Root = new Uri(uri.AbsoluteUri.TrimEnd('/') + "/");
|
||||
m_NasHost = nasHost;
|
||||
m_Auth = Convert.ToBase64String(Encoding.UTF8.GetBytes(user + ":" + password));
|
||||
SocketsHttpHandler handler = new()
|
||||
{
|
||||
AllowAutoRedirect = false,
|
||||
UseProxy = false,
|
||||
PooledConnectionLifetime = TimeSpan.FromMinutes(2),
|
||||
ConnectTimeout = TimeSpan.FromSeconds(8),
|
||||
ConnectCallback = async (context, cancellation) =>
|
||||
{
|
||||
Socket socket = new(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
try
|
||||
{
|
||||
await socket.ConnectAsync(IPAddress.Parse(m_NasHost),
|
||||
context.DnsEndPoint.Port, cancellation).ConfigureAwait(false);
|
||||
return new NetworkStream(socket, ownsSocket: true);
|
||||
}
|
||||
catch { socket.Dispose(); throw; }
|
||||
}
|
||||
};
|
||||
m_Http = new HttpClient(handler) { Timeout = TimeSpan.FromMinutes(15) };
|
||||
}
|
||||
|
||||
public void Dispose() => m_Http.Dispose();
|
||||
|
||||
public static string ArchiveKey(Guid region, Guid id)
|
||||
{
|
||||
if (region == Guid.Empty || id == Guid.Empty)
|
||||
throw new ArgumentException("Invalid managed IAR identifiers.");
|
||||
return region.ToString("D") + "/" + id.ToString("D") + ".iar";
|
||||
}
|
||||
|
||||
public static string MarkerKey(Guid region, Guid id) =>
|
||||
ArchiveKey(region, id) + ".ogl-retention";
|
||||
|
||||
public void EnsureRegion(Guid region)
|
||||
{
|
||||
if (region == Guid.Empty) throw new ArgumentException("Invalid region.");
|
||||
using HttpRequestMessage req = Request("MKCOL", region.ToString("D") + "/");
|
||||
using HttpResponseMessage reply = Send(req);
|
||||
if (reply.StatusCode != HttpStatusCode.Created &&
|
||||
reply.StatusCode != HttpStatusCode.MethodNotAllowed &&
|
||||
reply.StatusCode != HttpStatusCode.Conflict)
|
||||
Check(reply);
|
||||
// A preexisting directory is acceptable; PUT/GET will validate access.
|
||||
}
|
||||
|
||||
public void CreateMarker(Guid region, Guid id)
|
||||
{
|
||||
using HttpRequestMessage req = Request("PUT", MarkerKey(region, id));
|
||||
req.Headers.TryAddWithoutValidation("If-None-Match", "*");
|
||||
req.Content = new ByteArrayContent(Array.Empty<byte>());
|
||||
using HttpResponseMessage reply = Send(req);
|
||||
Check(reply);
|
||||
}
|
||||
|
||||
public void Upload(Guid region, Guid id, string localPath, long maxBytes)
|
||||
{
|
||||
string key = ArchiveKey(region, id);
|
||||
using FileStream file = File.OpenRead(localPath);
|
||||
if (file.Length < 1 || file.Length > maxBytes)
|
||||
throw new IOException("IAR WebDAV upload exceeds configured quota.");
|
||||
using HttpRequestMessage req = Request("PUT", key);
|
||||
// Retriable PUT: a failed transfer may leave a partial resource.
|
||||
// The key is a server-generated region/job UUID pair; only the
|
||||
// authenticated job owner can trigger this upload.
|
||||
req.Content = new StreamContent(file);
|
||||
req.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
|
||||
using HttpResponseMessage response = Send(req);
|
||||
Check(response);
|
||||
}
|
||||
|
||||
public long Size(Guid region, Guid id)
|
||||
{
|
||||
using HttpRequestMessage req = Request("HEAD", ArchiveKey(region, id));
|
||||
using HttpResponseMessage response = Send(req);
|
||||
if (response.StatusCode == HttpStatusCode.NotFound) return -1;
|
||||
Check(response);
|
||||
return response.Content.Headers.ContentLength ?? -1;
|
||||
}
|
||||
|
||||
public void Download(Guid region, Guid id, string localPath, long maxBytes)
|
||||
{
|
||||
using HttpRequestMessage req = Request("GET", ArchiveKey(region, id));
|
||||
using HttpResponseMessage response = Send(req);
|
||||
Check(response);
|
||||
if (response.Content.Headers.ContentLength is long len && len > maxBytes)
|
||||
throw new IOException("Remote IAR exceeds size limit.");
|
||||
using Stream input = response.Content.ReadAsStream();
|
||||
using FileStream output = new(localPath, FileMode.CreateNew, FileAccess.Write, FileShare.None);
|
||||
byte[] buffer = new byte[65536];
|
||||
long total = 0;
|
||||
int count;
|
||||
try
|
||||
{
|
||||
while ((count = input.Read(buffer, 0, buffer.Length)) > 0)
|
||||
{
|
||||
total += count;
|
||||
if (total > maxBytes) throw new IOException("Remote IAR quota exceeded.");
|
||||
output.Write(buffer, 0, count);
|
||||
}
|
||||
output.Flush(true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
output.Dispose();
|
||||
File.Delete(localPath);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// WebDAV is not required to support Range. A 200 response is read as
|
||||
// a forward-only stream and skipped in bounded memory, never buffered.
|
||||
public byte[] DownloadChunk(Guid region, Guid id, long offset,
|
||||
int length, long knownSize)
|
||||
{
|
||||
if (length <= 0 || length > OglIarTransferPolicy.MaximumChunkBytes ||
|
||||
offset < 0 || offset >= knownSize || knownSize <= 0)
|
||||
throw new ArgumentException("Invalid IAR read range.");
|
||||
int take = (int)Math.Min(length, knownSize - offset);
|
||||
using HttpRequestMessage req = Request("GET", ArchiveKey(region, id));
|
||||
req.Headers.Range = new RangeHeaderValue(offset, offset + take - 1);
|
||||
using HttpResponseMessage response = Send(req);
|
||||
Check(response);
|
||||
if (response.StatusCode != HttpStatusCode.OK &&
|
||||
response.StatusCode != HttpStatusCode.PartialContent)
|
||||
throw new IOException("Unexpected IAR WebDAV range status.");
|
||||
long skip = offset;
|
||||
if (response.StatusCode == HttpStatusCode.PartialContent)
|
||||
{
|
||||
ContentRangeHeaderValue range = response.Content.Headers.ContentRange;
|
||||
if (range?.From != offset || range?.To != offset + take - 1 ||
|
||||
(range.HasLength && range.Length != knownSize))
|
||||
throw new IOException("Invalid IAR WebDAV Content-Range.");
|
||||
skip = 0;
|
||||
}
|
||||
using Stream stream = response.Content.ReadAsStream();
|
||||
byte[] scratch = new byte[65536];
|
||||
while (skip > 0)
|
||||
{
|
||||
int n = stream.Read(scratch, 0, (int)Math.Min(skip, scratch.Length));
|
||||
if (n <= 0) throw new IOException("Unexpected end of IAR WebDAV stream.");
|
||||
skip -= n;
|
||||
}
|
||||
byte[] output = new byte[take];
|
||||
stream.ReadExactly(output);
|
||||
return output;
|
||||
}
|
||||
|
||||
public string Digest(Guid region, Guid id, HashAlgorithm algorithm,
|
||||
long maxBytes)
|
||||
{
|
||||
using HttpRequestMessage req = Request("GET", ArchiveKey(region, id));
|
||||
using HttpResponseMessage response = Send(req);
|
||||
Check(response);
|
||||
if (response.Content.Headers.ContentLength is long len && len > maxBytes)
|
||||
throw new IOException("IAR WebDAV digest quota exceeded.");
|
||||
using Stream input = response.Content.ReadAsStream();
|
||||
byte[] buffer = new byte[65536];
|
||||
long total = 0;
|
||||
int read;
|
||||
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
|
||||
{
|
||||
total += read;
|
||||
if (total > maxBytes) throw new IOException("IAR WebDAV digest quota exceeded.");
|
||||
algorithm.TransformBlock(buffer, 0, read, buffer, 0);
|
||||
}
|
||||
algorithm.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
|
||||
return Convert.ToHexString(algorithm.Hash).ToLowerInvariant();
|
||||
}
|
||||
|
||||
public void Delete(Guid region, Guid id)
|
||||
{
|
||||
DeleteKey(ArchiveKey(region, id));
|
||||
DeleteKey(MarkerKey(region, id));
|
||||
}
|
||||
|
||||
public void DeleteKey(string key)
|
||||
{
|
||||
using HttpRequestMessage req = Request("DELETE", key);
|
||||
using HttpResponseMessage reply = Send(req);
|
||||
if (reply.StatusCode != HttpStatusCode.NotFound) Check(reply);
|
||||
}
|
||||
|
||||
// Retention never enumerates arbitrary shares or directories. It only
|
||||
// inspects one UUID region folder beneath the pinned WebDAV root.
|
||||
public System.Collections.Generic.IEnumerable<Guid> ListArchiveIds(Guid region)
|
||||
{
|
||||
using HttpRequestMessage req = Request("PROPFIND", region.ToString("D") + "/");
|
||||
req.Headers.TryAddWithoutValidation("Depth", "1");
|
||||
req.Content = new StringContent(
|
||||
"<?xml version=\"1.0\"?><d:propfind xmlns:d=\"DAV:\"><d:prop><d:resourcetype/></d:prop></d:propfind>",
|
||||
Encoding.UTF8, "application/xml");
|
||||
using HttpResponseMessage response = Send(req);
|
||||
if (response.StatusCode == HttpStatusCode.NotFound) yield break;
|
||||
if (response.StatusCode != (HttpStatusCode)207) Check(response);
|
||||
string prefix = new Uri(m_Root, region.ToString("D") + "/").AbsolutePath;
|
||||
foreach (string path in Hrefs(response))
|
||||
{
|
||||
if (!path.StartsWith(prefix, StringComparison.Ordinal)) continue;
|
||||
string name = path.Substring(prefix.Length);
|
||||
if (name.Contains('/') || !name.EndsWith(".iar", StringComparison.Ordinal)) continue;
|
||||
if (Guid.TryParseExact(name.Substring(0, name.Length - 4),
|
||||
"D", out Guid id) && id != Guid.Empty)
|
||||
yield return id;
|
||||
}
|
||||
}
|
||||
|
||||
public System.Collections.Generic.IEnumerable<Guid> ListRegions()
|
||||
{
|
||||
using HttpRequestMessage req = Request("PROPFIND", "");
|
||||
req.Headers.TryAddWithoutValidation("Depth", "1");
|
||||
req.Content = new StringContent(
|
||||
"<?xml version=\"1.0\"?><d:propfind xmlns:d=\"DAV:\"><d:prop><d:resourcetype/></d:prop></d:propfind>",
|
||||
Encoding.UTF8, "application/xml");
|
||||
using HttpResponseMessage response = Send(req);
|
||||
if (response.StatusCode != (HttpStatusCode)207) Check(response);
|
||||
foreach (string entry in Hrefs(response))
|
||||
{
|
||||
string path = entry;
|
||||
string prefix = m_Root.AbsolutePath;
|
||||
if (!path.StartsWith(prefix, StringComparison.Ordinal)) continue;
|
||||
string name = path.Substring(prefix.Length).TrimEnd('/');
|
||||
if (name.Contains('/') || !Guid.TryParseExact(name, "D", out Guid region) ||
|
||||
region == Guid.Empty || path != prefix + name + "/") continue;
|
||||
yield return region;
|
||||
}
|
||||
}
|
||||
|
||||
public DateTimeOffset? MarkerModified(Guid region, Guid id)
|
||||
{
|
||||
using HttpRequestMessage req = Request("HEAD", MarkerKey(region, id));
|
||||
using HttpResponseMessage response = Send(req);
|
||||
if (response.StatusCode == HttpStatusCode.NotFound) return null;
|
||||
Check(response);
|
||||
return response.Content.Headers.LastModified;
|
||||
}
|
||||
|
||||
private static System.Collections.Generic.IEnumerable<string> Hrefs(HttpResponseMessage response)
|
||||
{
|
||||
using Stream stream = response.Content.ReadAsStream();
|
||||
using MemoryStream bounded = new();
|
||||
byte[] buffer = new byte[8192];
|
||||
int count;
|
||||
while ((count = stream.Read(buffer, 0, buffer.Length)) != 0)
|
||||
{
|
||||
if (bounded.Length + count > 2 * 1024 * 1024)
|
||||
throw new IOException("IAR WebDAV PROPFIND response too large.");
|
||||
bounded.Write(buffer, 0, count);
|
||||
}
|
||||
bounded.Position = 0;
|
||||
using System.Xml.XmlReader reader = System.Xml.XmlReader.Create(
|
||||
bounded, new System.Xml.XmlReaderSettings
|
||||
{
|
||||
DtdProcessing = System.Xml.DtdProcessing.Prohibit,
|
||||
XmlResolver = null,
|
||||
MaxCharactersInDocument = 2 * 1024 * 1024
|
||||
});
|
||||
XDocument xml = XDocument.Load(reader);
|
||||
XNamespace ns = "DAV:";
|
||||
foreach (XElement entry in xml.Descendants(ns + "response"))
|
||||
{
|
||||
string href = (string)entry.Element(ns + "href");
|
||||
if (string.IsNullOrWhiteSpace(href)) continue;
|
||||
Uri resolved;
|
||||
if (!Uri.TryCreate(href, UriKind.Absolute, out resolved))
|
||||
resolved = new Uri(response.RequestMessage.RequestUri, href);
|
||||
// A forged PROPFIND response cannot escape the pinned share.
|
||||
if (resolved.Host != response.RequestMessage.RequestUri.Host ||
|
||||
resolved.Port != response.RequestMessage.RequestUri.Port ||
|
||||
resolved.Scheme != Uri.UriSchemeHttps)
|
||||
continue;
|
||||
yield return Uri.UnescapeDataString(resolved.AbsolutePath);
|
||||
}
|
||||
}
|
||||
|
||||
public bool MarkerExists(Guid region, Guid id)
|
||||
{
|
||||
using HttpRequestMessage req = Request("HEAD", MarkerKey(region, id));
|
||||
using HttpResponseMessage response = Send(req);
|
||||
if (response.StatusCode == HttpStatusCode.NotFound) return false;
|
||||
Check(response);
|
||||
return true;
|
||||
}
|
||||
|
||||
private HttpRequestMessage Request(string method, string path)
|
||||
{
|
||||
// Key components are generated from GUIDs only.
|
||||
if (path == null ||
|
||||
path.Contains("..", StringComparison.Ordinal) ||
|
||||
path.IndexOfAny(new[] { '?', '#', '%', '\\' }) >= 0)
|
||||
throw new ArgumentException("Invalid WebDAV resource path.");
|
||||
HttpRequestMessage request = new(new HttpMethod(method), new Uri(m_Root, path));
|
||||
request.Headers.Authorization = new AuthenticationHeaderValue("Basic", m_Auth);
|
||||
return request;
|
||||
}
|
||||
|
||||
private HttpResponseMessage Send(HttpRequestMessage request)
|
||||
{
|
||||
try { return m_Http.Send(request, HttpCompletionOption.ResponseHeadersRead); }
|
||||
catch (Exception e) when (e is HttpRequestException or
|
||||
TaskCanceledException or InvalidOperationException)
|
||||
{ throw new IOException("IAR WebDAV transport unavailable.", e); }
|
||||
}
|
||||
|
||||
private static void Check(HttpResponseMessage response)
|
||||
{
|
||||
if (!response.IsSuccessStatusCode)
|
||||
throw new IOException("IAR WebDAV HTTP " + (int)response.StatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,6 +99,8 @@ namespace NexVerse.RegionModules.NodeAgent
|
||||
private readonly ConcurrentDictionary<string, long> m_NodeUpdateReplay = new();
|
||||
private IDisposable m_OarControlSubscription;
|
||||
private IDisposable m_IarControlSubscription;
|
||||
private OglIarWebDavStorage m_IarWebDav;
|
||||
private long m_IarWebDavMaximumBytes = 2048L * 1024 * 1024;
|
||||
private IDisposable m_ObjectMessageSubscription;
|
||||
private IDisposable m_EstateScriptMessageSubscription;
|
||||
private IDisposable m_GridScriptMessageSubscription;
|
||||
@@ -198,6 +200,34 @@ namespace NexVerse.RegionModules.NodeAgent
|
||||
5,
|
||||
300);
|
||||
|
||||
IConfig iarConfig = source.Configs["OpenGenesisLINKIAR"];
|
||||
// Separate per-node NAS credentials. Never distribute passwords
|
||||
// or client authentication material through NexBus.
|
||||
if ((iarConfig?.GetString("StorageBackend", "WebDAV") ?? "WebDAV")
|
||||
.Equals("WebDAV", StringComparison.OrdinalIgnoreCase) &&
|
||||
iarConfig?.GetBoolean("Enabled", false) == true &&
|
||||
!string.IsNullOrWhiteSpace(iarConfig.GetString("WebDavBaseUrl", "")))
|
||||
{
|
||||
try
|
||||
{
|
||||
m_IarWebDav = new OglIarWebDavStorage(
|
||||
iarConfig.GetString("WebDavBaseUrl", ""),
|
||||
iarConfig.GetString("NasHost", "10.78.0.4"),
|
||||
iarConfig.GetString("WebDavUsername", ""),
|
||||
iarConfig.GetString("WebDavPasswordFile", ""));
|
||||
long mib = iarConfig.GetLong("MaximumArchiveMiB", 2048);
|
||||
if (mib < 101 || mib > 10240)
|
||||
throw new ArgumentException("Invalid WebDAV IAR archive size cap.");
|
||||
m_IarWebDavMaximumBytes = mib * 1024L * 1024;
|
||||
}
|
||||
catch (Exception e) when (e is IOException or ArgumentException or
|
||||
UnauthorizedAccessException or System.Security.SecurityException)
|
||||
{
|
||||
m_IarWebDav?.Dispose();
|
||||
m_IarWebDav = null;
|
||||
m_Log.Error("[OGL-IAR]: WebDAV archive transport disabled.", e);
|
||||
}
|
||||
}
|
||||
IConfig oarConfig = source.Configs["OpenGenesisLINKOAR"];
|
||||
m_MigrationStorageId =
|
||||
(oarConfig?.GetString("MigrationStorageId", string.Empty) ?? string.Empty)
|
||||
@@ -399,6 +429,8 @@ namespace NexVerse.RegionModules.NodeAgent
|
||||
m_HeartbeatTimer?.Dispose();
|
||||
m_LogForwardTimer?.Dispose();
|
||||
m_LogForwardClient?.Dispose();
|
||||
m_IarWebDav?.Dispose();
|
||||
m_IarWebDav = null;
|
||||
m_Bus?.Dispose();
|
||||
m_Transport = null;
|
||||
m_Bus = null;
|
||||
@@ -1961,23 +1993,52 @@ namespace NexVerse.RegionModules.NodeAgent
|
||||
return;
|
||||
}
|
||||
|
||||
// A resident IAR must be on the verified NAS, never in local
|
||||
// fallback storage after the WireGuard/NFS mount disappears.
|
||||
if (nexEvent.Data.TryGetValue("self_service", out string self) &&
|
||||
string.Equals(self, "true", StringComparison.OrdinalIgnoreCase))
|
||||
bool selfService = nexEvent.Data.TryGetValue("self_service", out string self) &&
|
||||
string.Equals(self, "true", StringComparison.OrdinalIgnoreCase);
|
||||
bool webdav = selfService &&
|
||||
nexEvent.Data.TryGetValue("storage_backend", out string storageBackend) &&
|
||||
string.Equals(storageBackend, "WebDAV", StringComparison.OrdinalIgnoreCase);
|
||||
string stage = string.Empty;
|
||||
if (selfService)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!nexEvent.Data.TryGetValue("nas_host", out string nasHost) ||
|
||||
!string.Equals(nasHost, "10.78.0.4", StringComparison.Ordinal))
|
||||
throw new IOException("Unapproved IAR NAS host.");
|
||||
OglIarNasStorage.RequireMounted(
|
||||
Path.GetDirectoryName(operations.StorageRoot), nasHost);
|
||||
!string.Equals(nasHost, "10.78.0.4", StringComparison.Ordinal) ||
|
||||
!string.Equals(fileName, operationId.ToString() + ".iar",
|
||||
StringComparison.OrdinalIgnoreCase))
|
||||
throw new IOException("Unapproved IAR NAS command.");
|
||||
if (webdav)
|
||||
{
|
||||
if (m_IarWebDav == null)
|
||||
throw new IOException("IAR WebDAV transport not configured.");
|
||||
Guid reg = Guid.Parse(regionId.ToString());
|
||||
Guid id = Guid.Parse(operationId.ToString());
|
||||
stage = OglIarTransferPolicy.Resolve(
|
||||
Path.GetDirectoryName(operations.StorageRoot), reg, id);
|
||||
if (!string.Equals(stage, Path.Combine(operations.StorageRoot, fileName),
|
||||
StringComparison.OrdinalIgnoreCase))
|
||||
throw new IOException("IAR WebDAV stage mismatch.");
|
||||
Directory.CreateDirectory(operations.StorageRoot);
|
||||
if (string.Equals(action, "import", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (File.Exists(stage)) throw new IOException("IAR work file already exists.");
|
||||
m_IarWebDav.Download(reg, id, stage, m_IarWebDavMaximumBytes);
|
||||
}
|
||||
}
|
||||
else if (!nexEvent.Data.TryGetValue("storage_backend", out string backend) ||
|
||||
string.Equals(backend, "NFS", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
OglIarNasStorage.RequireMounted(
|
||||
Path.GetDirectoryName(operations.StorageRoot), nasHost);
|
||||
}
|
||||
else throw new IOException("Unknown IAR backend.");
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or ArgumentException)
|
||||
catch (Exception ex) when (ex is IOException or ArgumentException or
|
||||
UnauthorizedAccessException)
|
||||
{
|
||||
PublishIarState(nexEvent, operationId, regionId, action,
|
||||
"failed", "iar_nas_mount_unavailable", 0, 0);
|
||||
"failed", "iar_nas_storage_unavailable", 0, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1986,8 +2047,39 @@ namespace NexVerse.RegionModules.NodeAgent
|
||||
{
|
||||
if (operation.RequestId != operationId) return;
|
||||
string state = operation.State.ToString().ToLowerInvariant();
|
||||
PublishIarState(nexEvent, operationId, regionId, action, state, operation.Error, operation.ItemCount, operation.FilteredCount, operation.ProgressPercent, operation.ProgressPhase);
|
||||
if (operation.State == OglIarOperationState.Completed || operation.State == OglIarOperationState.Failed)
|
||||
if (webdav && operation.State is OglIarOperationState.Completed or
|
||||
OglIarOperationState.Failed)
|
||||
{
|
||||
// The simulator's native archiver works on a temporary
|
||||
// file. Report export success only after PUT to WebDAV.
|
||||
try
|
||||
{
|
||||
if (operation.State == OglIarOperationState.Completed &&
|
||||
string.Equals(action, "export", StringComparison.OrdinalIgnoreCase))
|
||||
m_IarWebDav.Upload(Guid.Parse(regionId.ToString()),
|
||||
Guid.Parse(operationId.ToString()), stage, m_IarWebDavMaximumBytes);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
state = "failed";
|
||||
m_Log.Error("[OGL-IAR]: WebDAV export failed.", e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try { if (File.Exists(stage)) File.Delete(stage); }
|
||||
catch (IOException e) { m_Log.Warn("[OGL-IAR]: Could not delete temporary IAR.", e); }
|
||||
}
|
||||
PublishIarState(nexEvent, operationId, regionId, action, state,
|
||||
state == "failed" ? "iar_webdav_transfer_failed" : operation.Error,
|
||||
operation.ItemCount, operation.FilteredCount, operation.ProgressPercent, operation.ProgressPhase);
|
||||
operations.OperationChanged -= Changed;
|
||||
return;
|
||||
}
|
||||
PublishIarState(nexEvent, operationId, regionId, action,
|
||||
state, operation.Error, operation.ItemCount, operation.FilteredCount,
|
||||
operation.ProgressPercent, operation.ProgressPhase);
|
||||
if (operation.State == OglIarOperationState.Completed ||
|
||||
operation.State == OglIarOperationState.Failed)
|
||||
operations.OperationChanged -= Changed;
|
||||
}
|
||||
|
||||
@@ -1998,21 +2090,34 @@ namespace NexVerse.RegionModules.NodeAgent
|
||||
bool merge = nexEvent.Data.TryGetValue("merge", out string mergeRaw) && bool.TryParse(mergeRaw, out bool mergeParsed) && mergeParsed;
|
||||
OglIarOperation operation = string.Equals(action, "export", StringComparison.OrdinalIgnoreCase)
|
||||
? operations.StartExport(operationId, user, inventoryPath, fileName,
|
||||
nexEvent.Data.TryGetValue("self_service", out string selfService) &&
|
||||
string.Equals(selfService, "true", StringComparison.OrdinalIgnoreCase)
|
||||
nexEvent.Data.TryGetValue("self_service", out string selfServiceValue) &&
|
||||
string.Equals(selfServiceValue, "true", StringComparison.OrdinalIgnoreCase)
|
||||
? new Dictionary<string, object> { ["checkPermissions"] = "CT" }
|
||||
: null)
|
||||
: string.Equals(action, "import", StringComparison.OrdinalIgnoreCase)
|
||||
? operations.StartImport(operationId, user, inventoryPath, fileName, merge, dryRun)
|
||||
: throw new InvalidOperationException("unsupported_iar_action");
|
||||
|
||||
PublishIarState(nexEvent, operationId, regionId, action, operation.State.ToString().ToLowerInvariant(), operation.Error, operation.ItemCount, operation.FilteredCount, operation.ProgressPercent, operation.ProgressPhase);
|
||||
if (operation.State == OglIarOperationState.Completed || operation.State == OglIarOperationState.Failed)
|
||||
// WebDAV completion is published by Changed only AFTER
|
||||
// the remote upload or local temporary-file cleanup.
|
||||
if (!webdav || operation.State is not
|
||||
(OglIarOperationState.Completed or OglIarOperationState.Failed))
|
||||
PublishIarState(nexEvent, operationId, regionId, action,
|
||||
operation.State.ToString().ToLowerInvariant(), operation.Error,
|
||||
operation.ItemCount, operation.FilteredCount,
|
||||
operation.ProgressPercent, operation.ProgressPhase);
|
||||
if (operation.State == OglIarOperationState.Completed ||
|
||||
operation.State == OglIarOperationState.Failed)
|
||||
operations.OperationChanged -= Changed;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
operations.OperationChanged -= Changed;
|
||||
if (webdav && File.Exists(stage))
|
||||
{
|
||||
try { File.Delete(stage); }
|
||||
catch (IOException error) { m_Log.Warn("[OGL-IAR]: Could not delete temporary IAR.", error); }
|
||||
}
|
||||
PublishIarState(nexEvent, operationId, regionId, action, "failed", e.Message, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ namespace NexVerse.Server.Api
|
||||
private readonly string m_SharedRoot;
|
||||
private readonly long m_MaxBytes;
|
||||
private readonly string m_NasHost;
|
||||
private readonly bool m_UseWebDav;
|
||||
private readonly OglIarWebDavStorage m_WebDav;
|
||||
private readonly int m_RetentionDays;
|
||||
private readonly Timer m_CleanupTimer;
|
||||
private readonly ConcurrentDictionary<string, object> m_Locks = new();
|
||||
@@ -52,19 +54,43 @@ namespace NexVerse.Server.Api
|
||||
m_Auth = auth; m_Nodes = nodes; m_Bridge = bridge;
|
||||
m_Jobs = jobs; m_Bus = bus; m_Features = features;
|
||||
IConfig section = config?.Configs["OglIarSelfService"];
|
||||
string root = section?.GetString("SharedStorageRoot", "")?.Trim() ?? "";
|
||||
string backend = section?.GetString("StorageBackend", "WebDAV")?.Trim() ?? "WebDAV";
|
||||
m_UseWebDav = backend.Equals("WebDAV", StringComparison.OrdinalIgnoreCase);
|
||||
bool nfs = backend.Equals("NFS", StringComparison.OrdinalIgnoreCase);
|
||||
string root = section?.GetString(
|
||||
m_UseWebDav ? "TemporaryStorageRoot" : "SharedStorageRoot",
|
||||
m_UseWebDav ? "/var/lib/opengenesislink/iar-staging" : "")?.Trim() ?? "";
|
||||
long maxMib = section?.GetLong("MaximumArchiveMiB", 2048) ?? 2048;
|
||||
m_NasHost = section?.GetString("NasHost", "")?.Trim() ?? "";
|
||||
m_NasHost = section?.GetString("NasHost", "10.78.0.4")?.Trim() ?? "";
|
||||
int days = section?.GetInt("RetentionDays", 30) ?? 30;
|
||||
m_RetentionDays = Math.Clamp(days, 1, OglIarNasStorage.MaximumRetentionDays);
|
||||
m_Enabled = section?.GetBoolean("Enabled", false) == true &&
|
||||
root.Length > 0 && maxMib >= 101 && maxMib <= 10240 &&
|
||||
(m_UseWebDav || nfs) && Path.IsPathFullyQualified(root) &&
|
||||
maxMib >= 101 && maxMib <= 10240 &&
|
||||
string.Equals(m_NasHost, "10.78.0.4", StringComparison.Ordinal) &&
|
||||
days >= 1 && days <= OglIarNasStorage.MaximumRetentionDays;
|
||||
m_SharedRoot = m_Enabled ? Path.GetFullPath(root) : string.Empty;
|
||||
m_MaxBytes = checked(Math.Clamp(maxMib, 101, 10240) * 1024L * 1024);
|
||||
if (m_Enabled && m_SharedRoot == Path.GetPathRoot(m_SharedRoot))
|
||||
m_Enabled = false;
|
||||
if (m_Enabled && m_UseWebDav)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_WebDav = new OglIarWebDavStorage(
|
||||
section.GetString("WebDavBaseUrl", ""),
|
||||
m_NasHost,
|
||||
section.GetString("WebDavUsername", ""),
|
||||
section.GetString("WebDavPasswordFile", ""));
|
||||
Directory.CreateDirectory(m_SharedRoot);
|
||||
}
|
||||
catch (Exception e) when (e is IOException or ArgumentException or
|
||||
UnauthorizedAccessException or System.Security.SecurityException)
|
||||
{
|
||||
Trace.TraceWarning("OGL-IAR WebDAV disabled: " + e.GetType().Name);
|
||||
m_Enabled = false;
|
||||
}
|
||||
}
|
||||
if (m_Enabled)
|
||||
m_CleanupTimer = new Timer(_ => CleanupExpiredArchives(),
|
||||
null, TimeSpan.FromMinutes(1), TimeSpan.FromHours(1));
|
||||
@@ -104,8 +130,11 @@ namespace NexVerse.Server.Api
|
||||
}
|
||||
try
|
||||
{
|
||||
// Never create local backup files if NFS is not mounted.
|
||||
OglIarNasStorage.RequireMounted(m_SharedRoot, m_NasHost);
|
||||
// WebDAV has no network mount. Only NFS requires mount validation.
|
||||
// The WebDAV path uses temporary work files, never a local
|
||||
// replacement for the durable NAS archive.
|
||||
if (!m_UseWebDav)
|
||||
OglIarNasStorage.RequireMounted(m_SharedRoot, m_NasHost);
|
||||
if (path == "/api/v1/iar/me/export" && method == "POST")
|
||||
{ Start(request, response, user, "export"); return; }
|
||||
if (path == "/api/v1/iar/me/import" && method == "POST")
|
||||
@@ -192,6 +221,14 @@ namespace NexVerse.Server.Api
|
||||
|
||||
Guid id = Guid.NewGuid();
|
||||
string file = OglIarTransferPolicy.Resolve(m_SharedRoot, regionGuid, id);
|
||||
// Fail closed if WebDAV is down; reserve a remote marker before
|
||||
// accepting a request. A native import is staged locally only
|
||||
// until the upload to the NAS is complete.
|
||||
if (m_UseWebDav)
|
||||
{
|
||||
m_WebDav.EnsureRegion(regionGuid);
|
||||
m_WebDav.CreateMarker(regionGuid, id);
|
||||
}
|
||||
// Do not allow overwriting any existing archive, including symlinks.
|
||||
if (action == "import")
|
||||
{
|
||||
@@ -213,6 +250,7 @@ namespace NexVerse.Server.Api
|
||||
["merge"] = merge.ToString(),
|
||||
["dry_run"] = dry.ToString(),
|
||||
["self_service"] = "true",
|
||||
["storage_backend"] = m_UseWebDav ? "WebDAV" : "NFS",
|
||||
["retention_days"] = m_RetentionDays.ToString(CultureInfo.InvariantCulture)
|
||||
};
|
||||
OglJobSnapshot job;
|
||||
@@ -227,20 +265,23 @@ namespace NexVerse.Server.Api
|
||||
if (action == "import") File.Delete(file);
|
||||
throw;
|
||||
}
|
||||
// Retention marker survives job-store rotation. It is created
|
||||
// only for this resident-owned job, never for operator archives.
|
||||
try
|
||||
// NFS marker is stored alongside the durable archive. WebDAV's
|
||||
// marker was created remotely before the upload was reserved.
|
||||
if (!m_UseWebDav)
|
||||
{
|
||||
string marker = FileFor(job) + ".ogl-retention";
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(marker));
|
||||
using (new FileStream(marker, FileMode.CreateNew,
|
||||
FileAccess.Write, FileShare.None)) { }
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Jobs.Fail(job.JobId, "retention_marker_failed");
|
||||
if (action == "import") File.Delete(file);
|
||||
throw;
|
||||
try
|
||||
{
|
||||
string marker = FileFor(job) + ".ogl-retention";
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(marker));
|
||||
using (new FileStream(marker, FileMode.CreateNew,
|
||||
FileAccess.Write, FileShare.None)) { }
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Jobs.Fail(job.JobId, "retention_marker_failed");
|
||||
if (action == "import") File.Delete(file);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
if (action == "export")
|
||||
Publish(job);
|
||||
@@ -264,7 +305,8 @@ namespace NexVerse.Server.Api
|
||||
["merge"] = job.Metadata["merge"],
|
||||
["dry_run"] = job.Metadata["dry_run"],
|
||||
["self_service"] = "true",
|
||||
["nas_host"] = m_NasHost
|
||||
["nas_host"] = m_NasHost,
|
||||
["storage_backend"] = m_UseWebDav ? "WebDAV" : "NFS"
|
||||
};
|
||||
m_Bus.Publish(new NexEvent("archive.iar.requested",
|
||||
"opengenesislink.world-api", payload, job.JobId));
|
||||
@@ -364,8 +406,14 @@ namespace NexVerse.Server.Api
|
||||
return;
|
||||
}
|
||||
|
||||
// Uploaded file already lives where the simulator's IAR
|
||||
// inspector reads it. Never transfer binary bytes via NexBus.
|
||||
// WebDAV: publish only AFTER the full archive has reached
|
||||
// the pinned NAS. Do not send archive bytes through NexBus.
|
||||
if (m_UseWebDav)
|
||||
{
|
||||
JobIds(job, out Guid region, out Guid id);
|
||||
m_WebDav.Upload(region, id, path, m_MaxBytes);
|
||||
File.Delete(path);
|
||||
}
|
||||
if (job.State == OglJobState.Queued)
|
||||
m_Jobs.Start(job.JobId, "uploaded");
|
||||
else
|
||||
@@ -398,10 +446,16 @@ namespace NexVerse.Server.Api
|
||||
bool completeExport = job.Metadata["action"] == "export" &&
|
||||
job.State == OglJobState.Completed;
|
||||
string file = completeExport ? FileFor(job) : null;
|
||||
long remoteSize = -1;
|
||||
if (completeExport && m_UseWebDav && !IsExpired(job))
|
||||
{
|
||||
JobIds(job, out Guid region, out Guid id);
|
||||
remoteSize = m_WebDav.Size(region, id);
|
||||
}
|
||||
bool ready = completeExport && !IsExpired(job) &&
|
||||
File.Exists(file) &&
|
||||
new FileInfo(file).Length > 0 &&
|
||||
new FileInfo(file).Length <= m_MaxBytes;
|
||||
(m_UseWebDav ? remoteSize > 0 && remoteSize <= m_MaxBytes :
|
||||
File.Exists(file) && new FileInfo(file).Length > 0 &&
|
||||
new FileInfo(file).Length <= m_MaxBytes);
|
||||
Json(response, HttpStatusCode.OK, new
|
||||
{
|
||||
operation_id = job.JobId, state = job.State.ToString().ToLowerInvariant(),
|
||||
@@ -420,7 +474,9 @@ namespace NexVerse.Server.Api
|
||||
expires_at_utc = job.State == OglJobState.Completed
|
||||
? (job.FinishedAt ?? job.CreatedAt).AddDays(m_RetentionDays)
|
||||
: (DateTimeOffset?)null,
|
||||
file_size_bytes = ready ? new FileInfo(file).Length : (long?)null,
|
||||
file_size_bytes = ready
|
||||
? (m_UseWebDav ? remoteSize : new FileInfo(file).Length)
|
||||
: (long?)null,
|
||||
download_url = ready ?
|
||||
"/api/v1/iar/me/operations/" + job.JobId + "/file" : null,
|
||||
md5_url = ready ?
|
||||
@@ -433,7 +489,14 @@ namespace NexVerse.Server.Api
|
||||
{
|
||||
if (!TryReadyExport(job, out string file))
|
||||
{ Error(res, HttpStatusCode.Conflict, "export_not_ready"); return; }
|
||||
long length = new FileInfo(file).Length;
|
||||
long length;
|
||||
Guid region = Guid.Empty, id = Guid.Empty;
|
||||
if (m_UseWebDav)
|
||||
{
|
||||
JobIds(job, out region, out id);
|
||||
length = m_WebDav.Size(region, id);
|
||||
}
|
||||
else length = new FileInfo(file).Length;
|
||||
if (!long.TryParse(request.QueryString?["offset"], NumberStyles.None,
|
||||
CultureInfo.InvariantCulture, out long offset) ||
|
||||
!int.TryParse(request.QueryString?["length"], NumberStyles.None,
|
||||
@@ -442,9 +505,13 @@ namespace NexVerse.Server.Api
|
||||
chunk > OglIarTransferPolicy.MaximumChunkBytes)
|
||||
{ Error(res, HttpStatusCode.BadRequest, "use_bounded_offset_and_length"); return; }
|
||||
int take = (int)Math.Min((long)chunk, length - offset);
|
||||
byte[] data = new byte[take];
|
||||
using (FileStream stream = File.OpenRead(file))
|
||||
byte[] data;
|
||||
if (m_UseWebDav)
|
||||
data = m_WebDav.DownloadChunk(region, id, offset, take, length);
|
||||
else
|
||||
{
|
||||
data = new byte[take];
|
||||
using FileStream stream = File.OpenRead(file);
|
||||
stream.Position = offset;
|
||||
stream.ReadExactly(data);
|
||||
}
|
||||
@@ -465,8 +532,20 @@ namespace NexVerse.Server.Api
|
||||
{ Error(res, HttpStatusCode.Conflict, "export_not_ready"); return; }
|
||||
// MD5 for requested legacy tooling only; SHA-256 is the
|
||||
// security-oriented checksum also published in the manifest.
|
||||
string md5 = Digest(file, MD5.Create);
|
||||
string sha = Digest(file, SHA256.Create);
|
||||
string md5, sha;
|
||||
if (m_UseWebDav)
|
||||
{
|
||||
JobIds(job, out Guid region, out Guid id);
|
||||
using (MD5 hash = MD5.Create())
|
||||
md5 = m_WebDav.Digest(region, id, hash, m_MaxBytes);
|
||||
using (SHA256 hash = SHA256.Create())
|
||||
sha = m_WebDav.Digest(region, id, hash, m_MaxBytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
md5 = Digest(file, MD5.Create);
|
||||
sha = Digest(file, SHA256.Create);
|
||||
}
|
||||
res.StatusCode = (int)HttpStatusCode.OK;
|
||||
res.ContentType = "text/plain; charset=utf-8";
|
||||
res.AddHeader("Content-Disposition",
|
||||
@@ -495,8 +574,13 @@ namespace NexVerse.Server.Api
|
||||
}
|
||||
if (staged) m_Jobs.Cancel(job.JobId, "Resident cancelled upload.");
|
||||
string path = FileFor(job);
|
||||
if (m_UseWebDav)
|
||||
{
|
||||
JobIds(job, out Guid region, out Guid id);
|
||||
m_WebDav.Delete(region, id);
|
||||
}
|
||||
if (File.Exists(path)) File.Delete(path);
|
||||
DeleteMarker(path);
|
||||
if (!m_UseWebDav) DeleteMarker(path);
|
||||
Json(response, HttpStatusCode.OK,
|
||||
new { operation_id = job.JobId, archive_deleted = true });
|
||||
}
|
||||
@@ -526,8 +610,13 @@ namespace NexVerse.Server.Api
|
||||
continue;
|
||||
m_Jobs.Fail(j.JobId, "Expired incomplete IAR upload.");
|
||||
string path = FileFor(j);
|
||||
if (m_UseWebDav)
|
||||
{
|
||||
JobIds(j, out Guid region, out Guid id);
|
||||
m_WebDav.Delete(region, id);
|
||||
}
|
||||
if (File.Exists(path)) File.Delete(path);
|
||||
DeleteMarker(path);
|
||||
if (!m_UseWebDav) DeleteMarker(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -550,6 +639,11 @@ namespace NexVerse.Server.Api
|
||||
if (!m_Enabled) return;
|
||||
try
|
||||
{
|
||||
if (m_UseWebDav)
|
||||
{
|
||||
CleanupExpiredWebDav();
|
||||
return;
|
||||
}
|
||||
OglIarNasStorage.RequireMounted(m_SharedRoot, m_NasHost);
|
||||
if (!Directory.Exists(m_SharedRoot)) return;
|
||||
DateTimeOffset now = DateTimeOffset.UtcNow;
|
||||
@@ -597,13 +691,63 @@ namespace NexVerse.Server.Api
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) when (e is IOException or UnauthorizedAccessException
|
||||
or ArgumentException)
|
||||
catch (Exception e)
|
||||
{
|
||||
// Timers execute on the process ThreadPool. No unexpected
|
||||
// WebDAV/XML/HTTP exception may terminate the ROBUST process.
|
||||
Trace.TraceWarning("OGL-IAR NAS retention skipped: " + e.GetType().Name);
|
||||
}
|
||||
}
|
||||
|
||||
private void CleanupExpiredWebDav()
|
||||
{
|
||||
// Scan only the dedicated WebDAV share, managed region UUID
|
||||
// directories and managed job UUID archive names. A missing
|
||||
// job must have our retention marker, never delete unknown files.
|
||||
DateTimeOffset now = DateTimeOffset.UtcNow;
|
||||
foreach (Guid region in m_WebDav.ListRegions())
|
||||
{
|
||||
foreach (Guid id in m_WebDav.ListArchiveIds(region))
|
||||
{
|
||||
string jobKey = id.ToString("D");
|
||||
lock (m_Locks.GetOrAdd(jobKey, _ => new object()))
|
||||
{
|
||||
OglJobSnapshot job = m_Jobs.Get(jobKey);
|
||||
if (job != null)
|
||||
{
|
||||
if (job.State is OglJobState.Running or OglJobState.Queued ||
|
||||
job.Metadata == null ||
|
||||
!job.Metadata.TryGetValue("self_service", out string owner) ||
|
||||
owner != "true" ||
|
||||
!job.Metadata.TryGetValue("storage_backend", out string backend) ||
|
||||
backend != "WebDAV" ||
|
||||
!job.Metadata.TryGetValue("region_id", out string regionText) ||
|
||||
regionText != region.ToString("D") ||
|
||||
!IsExpired(job))
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
DateTimeOffset? marked = m_WebDav.MarkerModified(region, id);
|
||||
if (!marked.HasValue ||
|
||||
!OglIarNasStorage.IsExpired(marked.Value, now, m_RetentionDays))
|
||||
continue;
|
||||
}
|
||||
m_WebDav.Delete(region, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void JobIds(OglJobSnapshot job, out Guid region, out Guid id)
|
||||
{
|
||||
if (job?.Metadata == null ||
|
||||
!Guid.TryParseExact(job.Metadata.GetValueOrDefault("region_id"), "D", out region) ||
|
||||
!Guid.TryParseExact(job.JobId, "D", out id) ||
|
||||
region == Guid.Empty || id == Guid.Empty)
|
||||
throw new InvalidOperationException("Invalid self-service archive identity.");
|
||||
}
|
||||
|
||||
private bool TryReadyExport(OglJobSnapshot job, out string path)
|
||||
{
|
||||
path = null;
|
||||
@@ -611,6 +755,12 @@ namespace NexVerse.Server.Api
|
||||
job.State != OglJobState.Completed || IsExpired(job))
|
||||
return false;
|
||||
path = FileFor(job);
|
||||
if (m_UseWebDav)
|
||||
{
|
||||
JobIds(job, out Guid region, out Guid id);
|
||||
long size = m_WebDav.Size(region, id);
|
||||
return size > 0 && size <= m_MaxBytes;
|
||||
}
|
||||
return File.Exists(path) && new FileInfo(path).Length > 0 &&
|
||||
new FileInfo(path).Length <= m_MaxBytes;
|
||||
}
|
||||
|
||||
@@ -363,5 +363,19 @@
|
||||
BaseCapacityKw = 850
|
||||
BaseDemandKw = 2200
|
||||
|
||||
; ============================================================================
|
||||
; Resident IAR: WebDAV NAS is the default transport. Native archive working
|
||||
; files are temporary and MUST fit the configured size. The operator IAR
|
||||
; storage location is not changed automatically.
|
||||
; Configure the same WebDAV URL and credentials as on ROBUST.
|
||||
[OpenGenesisLINKIAR]
|
||||
Enabled = true
|
||||
StorageBackend = "WebDAV"
|
||||
NasHost = "10.78.0.4"
|
||||
WebDavBaseUrl = ""
|
||||
WebDavUsername = ""
|
||||
WebDavPasswordFile = ""
|
||||
|
||||
[Architecture]
|
||||
Include-Architecture = "config-include/GridHypergrid.ini"
|
||||
|
||||
@@ -308,3 +308,16 @@
|
||||
; Anzeigeoptionen unter [Startup]:
|
||||
; OGLConsoleGermanHelp = true
|
||||
; OGLConsoleExpertHelp = false
|
||||
|
||||
; ============================================================================
|
||||
; Resident IAR: WebDAV NAS is the default transport. Native archive working
|
||||
; files are temporary and MUST fit the configured size. The operator IAR
|
||||
; storage location is not changed automatically.
|
||||
; Configure the same WebDAV URL and credentials as on ROBUST.
|
||||
[OpenGenesisLINKIAR]
|
||||
Enabled = true
|
||||
StorageBackend = "WebDAV"
|
||||
NasHost = "10.78.0.4"
|
||||
WebDavBaseUrl = ""
|
||||
WebDavUsername = ""
|
||||
WebDavPasswordFile = ""
|
||||
+11
-1
@@ -1081,7 +1081,17 @@
|
||||
; ============================================================================
|
||||
[OglIarSelfService]
|
||||
Enabled = false
|
||||
SharedStorageRoot = ""
|
||||
; WebDAV is default. No NFS kernel/mount is needed on OpenVZ.
|
||||
; Persistent IARs on NAS; local files are ONLY temporary upload staging.
|
||||
StorageBackend = "WebDAV"
|
||||
TemporaryStorageRoot = "/var/lib/opengenesislink/iar-staging"
|
||||
NasHost = "10.78.0.4"
|
||||
; Replace with the NAS WebDAV HTTPS URL of a dedicated existing folder.
|
||||
; Certificate must validate. Sockets are pinned to 10.78.0.4 over WireGuard.
|
||||
WebDavBaseUrl = ""
|
||||
WebDavUsername = ""
|
||||
WebDavPasswordFile = ""
|
||||
; Optional legacy NFS backend: set StorageBackend=NFS and mount this root.
|
||||
SharedStorageRoot = ""
|
||||
RetentionDays = 30
|
||||
MaximumArchiveMiB = 2048
|
||||
@@ -1138,7 +1138,17 @@
|
||||
; ============================================================================
|
||||
[OglIarSelfService]
|
||||
Enabled = false
|
||||
SharedStorageRoot = ""
|
||||
; WebDAV is default. No NFS kernel/mount is needed on OpenVZ.
|
||||
; Persistent IARs on NAS; local files are ONLY temporary upload staging.
|
||||
StorageBackend = "WebDAV"
|
||||
TemporaryStorageRoot = "/var/lib/opengenesislink/iar-staging"
|
||||
NasHost = "10.78.0.4"
|
||||
; Replace with the NAS WebDAV HTTPS URL of a dedicated existing folder.
|
||||
; Certificate must validate. Sockets are pinned to 10.78.0.4 over WireGuard.
|
||||
WebDavBaseUrl = ""
|
||||
WebDavUsername = ""
|
||||
WebDavPasswordFile = ""
|
||||
; Optional legacy NFS backend: set StorageBackend=NFS and mount this root.
|
||||
SharedStorageRoot = ""
|
||||
RetentionDays = 30
|
||||
MaximumArchiveMiB = 2048
|
||||
+11
-1
@@ -843,7 +843,17 @@
|
||||
; ============================================================================
|
||||
[OglIarSelfService]
|
||||
Enabled = false
|
||||
SharedStorageRoot = ""
|
||||
; WebDAV is default. No NFS kernel/mount is needed on OpenVZ.
|
||||
; Persistent IARs on NAS; local files are ONLY temporary upload staging.
|
||||
StorageBackend = "WebDAV"
|
||||
TemporaryStorageRoot = "/var/lib/opengenesislink/iar-staging"
|
||||
NasHost = "10.78.0.4"
|
||||
; Replace with the NAS WebDAV HTTPS URL of a dedicated existing folder.
|
||||
; Certificate must validate. Sockets are pinned to 10.78.0.4 over WireGuard.
|
||||
WebDavBaseUrl = ""
|
||||
WebDavUsername = ""
|
||||
WebDavPasswordFile = ""
|
||||
; Optional legacy NFS backend: set StorageBackend=NFS and mount this root.
|
||||
SharedStorageRoot = ""
|
||||
RetentionDays = 30
|
||||
MaximumArchiveMiB = 2048
|
||||
@@ -5,126 +5,165 @@ OpenGenesisLINK erweitert die bestehende **administrative** World API
|
||||
für angemeldete lokale Avatar-Konten. Keine Weitergabe von Passwort,
|
||||
fremdem Benutzerkennzeichen oder rohem Archivinhalt über NexBus.
|
||||
|
||||
**Wichtig:** Dies ist eine opt-in **Shared-Storage-Implementierung**.
|
||||
Im Standardzustand ist sie deaktiviert. Für getrennte Server MUSS
|
||||
ein gemeinsames verlässliches POSIX-Verzeichnis (z. B. NFS) auf ROBUST
|
||||
und auf jedem teilnehmenden Regionssimulator gemountet sein.
|
||||
Es wird **kein** netzwerkübergreifender IAR-Byte-Transport über NexBus
|
||||
implementiert. Unterschiedliche lokale Verzeichnisse sind nicht ausreichend.
|
||||
**Status:** Benutzergebundener Self-Service bleibt standardmäßig deaktiviert
|
||||
(`Enabled=false`). **WebDAV ist der bevorzugte und voreingestellte
|
||||
StorageBackend-Typ**, NFS kann explizit als Legacy-Backend gewählt werden.
|
||||
Die Inventararchivierung selbst verwendet weiterhin native
|
||||
OpenSim-Datei-/Stream-Schnittstellen; bei WebDAV werden daher ausschließlich
|
||||
**temporäre Arbeitsdateien** auf ROBUST und dem Zielsimulator benötigt.
|
||||
Das dauerhafte Archiv liegt auf dem NAS. Ohne funktionierenden WebDAV-Zugang
|
||||
startet kein neuer Self-Service-Job.
|
||||
|
||||
## Zentrales IAR-Backup auf UGREEN NASync DXP2800 (10.78.0.4)
|
||||
## UGREEN NASync DXP2800 / WireGuard / WebDAV (Standard)
|
||||
|
||||
Das Netzlaufwerk ist unter `10.78.0.4` im WireGuard-Netz
|
||||
`10.78.0.0/24` erreichbar. UGOS Pro unterstützt NFS. Bei diesem
|
||||
Storage-Modus werden Import- und Export-IARs **direkt auf dem NAS**
|
||||
angelegt: kein dauerhafter IAR-Export auf der Systemplatte des
|
||||
Regionssimulators und keine lokale Ausweichablage bei NAS-Ausfall.
|
||||
Die NAS-IP `10.78.0.4` ist aus OpenGenesisLINK über den bereits eingerichteten
|
||||
WireGuard-Split-Tunnel erreichbar. Damit bleibt die öffentliche Serverroute
|
||||
unberührt. Der 1blu-OpenVZ-Host benötigt für WebDAV kein NFS-Kernelmodul.
|
||||
|
||||
### NAS einrichten (UGOS Pro)
|
||||
1. UGOS Pro: **Systemsteuerung > Dateidienste > WebDAV** öffnen;
|
||||
HTTPS aktivieren (häufig Port 5006; tatsächlich eingestellten Port prüfen).
|
||||
2. Eine **eigene Freigabe/Unterverzeichnis** für IAR-Archive erstellen.
|
||||
Dafür einen eigenen NAS-Benutzer nur mit Les-/Schreibrechten für diese
|
||||
Freigabe anlegen; nicht das NAS-Admin-Konto verwenden.
|
||||
3. NAS-WebDAV-HTTPS-Zertifikat korrekt konfigurieren:
|
||||
`WebDavBaseUrl` muss einen **gültigen, vertrauenswürdigen
|
||||
Zertifikatsnamen** verwenden, der NAS-IP zugeordnet ist.
|
||||
Beim Zugriff per `https://10.78.0.4:5006/...` muss ein
|
||||
*IP-SubjectAlternativeName* im Zertifikat stehen. Bei einem
|
||||
DNS-Hostnamen muss dessen Zertifikat zum Namen passen. Weder
|
||||
`--insecure` noch ein TLS-Validierungs-Bypass sind zulässig.
|
||||
Der WebDAV-Client verbindet sich unabhängig vom DNS immer
|
||||
mit `10.78.0.4` (kein Proxy, kein Redirect).
|
||||
4. Den tatsächlichen **WebDAV-Ordnerpfad** aus UGOS Pro verwenden.
|
||||
Er wird nicht aus dem bisherigen NFS-Pfad abgeleitet.
|
||||
5. Den Servern über WireGuard nur Zugriff auf den WebDAV-Port des NAS
|
||||
gestatten; **keine öffentliche Freigabe**. Vom ROBUST- und SIM-Host
|
||||
`nc -zvw3 10.78.0.4 5006` bzw. den konfigurierten Port testen.
|
||||
6. Auf ROBUST und jedem Regionssimulator eine **eigene** Passwortdatei
|
||||
für denselben dedizierten NAS-Account ablegen (nur Eigentümer lesbar):
|
||||
|
||||
1. Auf dem DXP2800 eine eigene Freigabe für OGL-IAR erstellen.
|
||||
2. **Systemsteuerung > Dateidienste > NFS** aktivieren.
|
||||
3. Die Freigabe in **Dateien > Freigegebener Ordner > Eigenschaften >
|
||||
NFS-Berechtigungen** ausschließlich für die tatsächlichen
|
||||
VPN-Client-IP-Adressen von ROBUST und der Regionsserver öffnen,
|
||||
Lese-/Schreibrecht setzen. Zugriffsrechte/UID-GID-Mapping abstimmen.
|
||||
4. TCP-Port **2049** auf dem WireGuard-Pfad erlauben und aus dem
|
||||
öffentlichen Internet **nicht** freigeben.
|
||||
5. In UGOS den **genauen Exportpfad** der Freigabe nachschlagen.
|
||||
Der Pfad hängt vom NAS-Speicherpool ab; hier wird **kein**
|
||||
unbekannter NAS-Exportpfad erfunden.
|
||||
```bash
|
||||
sudo install -d -m 700 /etc/opengenesislink
|
||||
read -rsp "NAS-WebDAV-Passwort: " OGL_IAR_PASS; echo
|
||||
printf '%s' "$OGL_IAR_PASS" | sudo tee /etc/opengenesislink/iar-webdav.pass >/dev/null
|
||||
unset OGL_IAR_PASS
|
||||
sudo chmod 600 /etc/opengenesislink/iar-webdav.pass
|
||||
```
|
||||
|
||||
### Linux-Hosts mounten
|
||||
Das Kennwort **nicht** in Git oder in World-API-/NexBus-Payloads hinterlegen.
|
||||
Bei Datenzugriff über systemd muss der Dienstbenutzer die Datei lesen dürfen.
|
||||
|
||||
Auf **jedem** beteiligten Server, also ROBUST und Regionssimulator:
|
||||
|
||||
```bash
|
||||
sudo apt install nfs-common
|
||||
sudo mkdir -p /mnt/ogl-iar
|
||||
# EXPORTPFAD durch den exakten NFS-Pfad aus der UGREEN-Oberflaeche ersetzen!
|
||||
sudo mount -t nfs4 -o vers=4.1,hard,nosuid,nodev,noexec \
|
||||
10.78.0.4:/EXPORTPFAD /mnt/ogl-iar
|
||||
findmnt -T /mnt/ogl-iar -o TARGET,SOURCE,FSTYPE
|
||||
```
|
||||
|
||||
Die `findmnt`-Ausgabe muss den **exakten Mountpunkt**
|
||||
`/mnt/ogl-iar`, den NFS-Typ und die Quelle
|
||||
`10.78.0.4:/...` zeigen. Ein leeres lokales Verzeichnis genügt
|
||||
**nicht**. In der Systemd-Service-Unit für ROBUST bzw. OpenSim
|
||||
`RequiresMountsFor=/mnt/ogl-iar` ergänzen und einen persistenten
|
||||
NFS-Mount (fstab/mount-Unit) konfigurieren. Unter dem Mountpunkt
|
||||
auf dem Host **keine** ungeschützten lokalen Backup-Dateien anlegen.
|
||||
Für starke Fail-Closed-Semantik sollte der lokale Mountpoint ohne
|
||||
NFS für den Dienstbenutzer nicht beschreibbar sein.
|
||||
|
||||
Simulator-Konfiguration in der jeweils tatsächlich geladenen INI:
|
||||
|
||||
```ini
|
||||
[OpenGenesisLINKIAR]
|
||||
Enabled = true
|
||||
StorageRoot = "/mnt/ogl-iar"
|
||||
MaximumArchiveMiB = 2048
|
||||
```
|
||||
|
||||
World-API-/ROBUST-Konfiguration:
|
||||
### ROBUST: tatsächliche `Robust.HG.ini`
|
||||
|
||||
```ini
|
||||
[OglIarSelfService]
|
||||
Enabled = true
|
||||
StorageBackend = "WebDAV"
|
||||
NasHost = "10.78.0.4"
|
||||
WebDavBaseUrl = "https://NAS-ZERTIFIKATSNAME:5006/WEB_DAV_IAR_ORDNER"
|
||||
WebDavUsername = "ogl-iar"
|
||||
WebDavPasswordFile = "/etc/opengenesislink/iar-webdav.pass"
|
||||
TemporaryStorageRoot = "/var/lib/opengenesislink/iar-staging"
|
||||
RetentionDays = 30
|
||||
MaximumArchiveMiB = 2048
|
||||
```
|
||||
|
||||
Die URL ist **ein Muster**, kein garantierter UGOS-Pro-WebDAV-Pfad.
|
||||
`TemporaryStorageRoot` ist kein Backup-Ort. Upload-Blöcke
|
||||
werden dort zunächst geschrieben, SHA-256-verifiziert und anschließend
|
||||
per HTTPS ins NAS übertragen; erst dann wird der native Import
|
||||
im Simulator ausgelöst.
|
||||
|
||||
### Simulator: tatsächlich verwendete `OpenSim.ini`
|
||||
|
||||
```ini
|
||||
[OpenGenesisLINKIAR]
|
||||
Enabled = true
|
||||
StorageBackend = "WebDAV"
|
||||
NasHost = "10.78.0.4"
|
||||
WebDavBaseUrl = "https://NAS-ZERTIFIKATSNAME:5006/WEB_DAV_IAR_ORDNER"
|
||||
WebDavUsername = "ogl-iar"
|
||||
WebDavPasswordFile = "/etc/opengenesislink/iar-webdav.pass"
|
||||
StorageRoot = "OGLInventoryArchives"
|
||||
MaximumArchiveMiB = 2048
|
||||
```
|
||||
|
||||
Auf jedem SIM muss die Region-Archivverwaltung mit WebDAV-Client und
|
||||
NexVerseNodeAgent aktiv sein. Der vorhandene `StorageRoot` des
|
||||
administrativen IAR-Dienstes bleibt standardmäßig erhalten.
|
||||
Beim Selbstbedienungs-Export schreibt der native Archiv-Manager erst
|
||||
eine **temporäre** Datei in seinen `StorageRoot/<Region-UUID>/`.
|
||||
Nur nach erfolgreichem WebDAV-PUT wird das Remote-Archiv als
|
||||
fertig gemeldet und die Arbeitsdatei gelöscht.
|
||||
Beim Import wird das über ROBUST hochgeladene NAS-Archiv in eine
|
||||
vorübergehende Datei am SIM geladen, geprüft und über den nativen
|
||||
IAR-Archiver eingelesen. Auch diese Datei wird nach Jobabschluss
|
||||
entfernt. **Vor dem Aktivieren den benötigten lokalen
|
||||
temporären Speicher für maximale Archive berücksichtigen.**
|
||||
|
||||
### Retention – maximal 30 Tage
|
||||
|
||||
- Neue Self-Service-Archive erhalten eine eindeutige
|
||||
`<region-uuid>/<operation-uuid>.iar`-Adresse und eine
|
||||
`.ogl-retention`-Markierung im NAS-Ordner.
|
||||
- Im aktiven ROBUST entfernt der stündliche Worker abgelaufene
|
||||
terminale Self-Service-Archive. Auch verwaiste, UUID-benannte
|
||||
Archivdateien können nach Jobstore-Rotation entfernt werden, **nur
|
||||
wenn eine passende WebDAV-Retention-Markierung mit ausreichend altem
|
||||
Änderungsdatum existiert**. Andere NAS-Dateien werden nicht gelöscht.
|
||||
Downloads werden nach Ablauf vor der physischen Löschung gesperrt.
|
||||
- **Einschränkung:** Bei WebDAV-Ausfall, nicht unterstützter
|
||||
PROPFIND-/HEAD-Metadatenabfrage, fehlendem Marker oder
|
||||
gestopptem ROBUST läuft die physische Löschung nicht garantiert
|
||||
fristgerecht. Für eine garantierte 30-Tage-Grenze zusätzlich eine
|
||||
unabhängige Retention auf dem NAS einrichten, **nur auf dem
|
||||
dedizierten IAR-Archivordner**. NAS-Snapshots/Recycle-Bin haben
|
||||
eigene Retention.
|
||||
- Staged Uploads nach über 24 Stunden Inaktivität werden beim
|
||||
nächsten Jobstart des Avatars verworfen. Crash-Restbestände
|
||||
auf dem Simulator erfordern derzeit operative Kontrolle.
|
||||
- Kennwort-/Zertifikatsfehler, NAS-Ausfälle, nicht lesbare Archive
|
||||
und WebDAV-Fehler führen zu einer Fehlermeldung. Es gibt **keinen
|
||||
automatischen dauerhaften lokalen Backup-Fallback**.
|
||||
|
||||
### Legacy-Backend: NFS
|
||||
|
||||
Für Hosts mit NFS-Kernelunterstützung kann weiter verwendet werden:
|
||||
|
||||
```ini
|
||||
[OglIarSelfService]
|
||||
Enabled = true
|
||||
StorageBackend = "NFS"
|
||||
SharedStorageRoot = "/mnt/ogl-iar"
|
||||
NasHost = "10.78.0.4"
|
||||
RetentionDays = 30
|
||||
MaximumArchiveMiB = 2048
|
||||
```
|
||||
|
||||
Der aktualisierte Self-Service akzeptiert ausschließlich NFS/NFSv4
|
||||
mit dem **exakten Mountpoint** und dieser NAS-Quelladresse.
|
||||
Fehlt die Freigabe, liefert die API HTTP 503; der Simulator verweigert
|
||||
den Bürger-Export/-Import ebenfalls. Es wird kein lokaler
|
||||
Fallback erzeugt. Die administrative IAR-Verwaltung ist davon
|
||||
unabhängig; für das beabsichtigte NAS-only-Betriebsmodell dürfen
|
||||
auch dort ausschließlich NAS-Pfade konfiguriert werden.
|
||||
Im Simulator dazu denselben **tatsächlich gemounteten**
|
||||
`[OpenGenesisLINKIAR].StorageRoot=/mnt/ogl-iar` einstellen.
|
||||
Die vorhandene Linux-Mountinfo-Überprüfung bleibt fail-closed.
|
||||
Auf dem OpenVZ-Server von 1blu ist dieser Modus mangels NFS-Client
|
||||
derzeit nicht nutzbar. `StorageBackend` ist **kein Protokoll-Umschalter
|
||||
für die administrative Legacy-IAR-API**; deren bestehende Dateipfade
|
||||
sind gesondert zu beachten.
|
||||
|
||||
### Maximale Aufbewahrung: 30 Tage
|
||||
## Aktivierung und Betrieb
|
||||
|
||||
`RetentionDays` kann zwischen **1 und 30** konfiguriert werden.
|
||||
Werte über 30 deaktivieren den Self-Service statt die Grenze
|
||||
stillschweigend zu verlängern.
|
||||
|
||||
- Der World-API-Prozess kontrolliert den Speicher **kurz nach dem Start**
|
||||
und danach **stündlich** und löscht abgeschlossene, abgelaufene
|
||||
`<region-uuid>/<operation-uuid>.iar`-Archive.
|
||||
- Der Ablauf beginnt mit Abschluss des Import-/Exportjobs;
|
||||
wenn kein Jobdatensatz mehr vorhanden ist, dient der
|
||||
Datei-Änderungszeitpunkt als Fallback.
|
||||
- Ab dem Ablaufzeitpunkt wird der **Download sofort verweigert**,
|
||||
auch wenn die nächste physische Bereinigung noch nicht lief.
|
||||
- Noch aktive IAR-Jobs werden aus Sicherheitsgründen nicht
|
||||
mitten im Schreibvorgang gelöscht. Die vorher vorhandene
|
||||
24-Stunden-Bereinigung abgebrochener Uploads bleibt bestehen.
|
||||
- Die automatische Bereinigung läuft **nur während ROBUST/World API
|
||||
aktiv und das NAS verbunden ist**. Wenn die 30-Tage-Grenze
|
||||
auch bei komplett abgeschaltetem ROBUST physisch garantiert
|
||||
werden soll, muss zusätzlich eine eigenständige Aufbewahrungsregel
|
||||
auf dem NAS eingerichtet werden. Diese wird hier bewusst
|
||||
**nicht automatisch auf dem DXP2800 konfiguriert**.
|
||||
- Für neue Self-Service-Archive wird eine kleine
|
||||
`.iar.ogl-retention`-Markierungsdatei auf dem NAS angelegt.
|
||||
Damit bleibt die Aufbewahrungsregel auch bei einem
|
||||
aus der Job-Datenbank entfernten Eintrag nachvollziehbar.
|
||||
- Gelöscht werden nur vom Self-Service generierte IAR-Dateinamen
|
||||
in UUID-Regionverzeichnissen, keine unbekannten Dateien,
|
||||
Unterordner oder NAS-Systemdateien. Ein Datei-Job ohne
|
||||
gültige zugehörige Job-/Markierungsinformation wird niemals
|
||||
eigenmächtig gelöscht.
|
||||
- RAID oder NAS-Snapshots ersetzen keine weitere unabhängige
|
||||
Sicherung. Kopien außerhalb des IAR-Ordners unterliegen
|
||||
nicht automatisch dieser Regel.
|
||||
|
||||
**Vor Aktivierung:** Bereits vorhandene `.iar`-Dateien im alten
|
||||
lokalen Speicher werden nicht automatisch migriert oder gelöscht.
|
||||
Den Altbestand separat prüfen und sicher umziehen. Die NAS-Regionordner
|
||||
müssen zu den vorhandenen IAR-Jobpfaden passen.
|
||||
1. Vorhandene `Robust.HG.ini` und `OpenSim.ini` sichern, da
|
||||
`git pull` keine lokalen Änderungen überschreiben darf.
|
||||
2. WebDAV-Ordner und NAS-Account auf UGOS einrichten; HTTPS-Zertifikat
|
||||
und Dateirechte prüfen.
|
||||
3. Passwortdatei auf jedem betroffenen Host sichern und konfigurieren.
|
||||
4. ROBUST und Simulatoren auf dieselbe neue Version aktualisieren,
|
||||
beide Konfigurationen für WebDAV setzen und neu starten.
|
||||
5. **Zuerst Staging mit Testavatare**: Import und Export von
|
||||
`>100 MiB` testen, SHA-256, Download, 30-Tage-Status, Cleanup,
|
||||
NAS-Ausfall, Wiederanlauf und Rechtefilter Copy+Transfer prüfen.
|
||||
6. Abgeschlossene Jobs kontrollieren: fertige Archive müssen auf
|
||||
dem NAS liegen, temporäre lokale Arbeitsdateien verschwinden.
|
||||
7. Unabhängige 30-Tage-NAS-Retention und Speicher-/Netzmonitoring
|
||||
ergänzen. Ein WebDAV-Zertifikatsfehler darf nicht übergangen werden.
|
||||
|
||||
## Berechtigungen / Voraussetzungen
|
||||
|
||||
@@ -338,7 +377,7 @@ unautorisierten Downloadlink.
|
||||
- Keine fertige direkte Inworld-Firestorm-Dateiauswahl; IARs werden
|
||||
über das authentifizierte **Webportal** oder einen HTTP-Client
|
||||
hoch- und heruntergeladen.
|
||||
- Kein echtes Cross-Host-Byte-Routing ohne Shared-Mount.
|
||||
- WebDAV verbindet ROBUST und Simulator ohne Shared-Mount; temporäre native Arbeitsdateien sind erforderlich.
|
||||
- **Kein automatischer Resume nach ROBUST-Neustart**, wenn ein
|
||||
Upload bereits als laufend markiert war. Die vorhandene persistente
|
||||
Job-Engine kennzeichnet unterbrochene Jobs als fehlgeschlagen;
|
||||
@@ -353,7 +392,7 @@ unautorisierten Downloadlink.
|
||||
Cache.
|
||||
- Die im Archiv vorhandenen Rechte bleiben Gegenstand des
|
||||
ursprünglichen OpenSim-/Asset-/Inventory-Importpfades.
|
||||
- Vollständige automatische Dateiretention für erfolgreiche Archive,
|
||||
- Vollständige NAS-seitige Dateiretention auch bei Offlinezeiten,
|
||||
ein generischer Browser-Download ohne
|
||||
Clientcode und vollständig gridgebundene Quotenverwaltung sind
|
||||
Folgeschritte. Ein Export wird in dieser Version nur blockweise
|
||||
|
||||
@@ -8,5 +8,6 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="../../../NexVerse/Core/Archives/OglIarTransferPolicy.cs" Link="OglIarTransferPolicy.cs" />
|
||||
<Compile Include="../../../NexVerse/Core/Archives/OglIarNasStorage.cs" Link="OglIarNasStorage.cs" />
|
||||
<Compile Include="../../../NexVerse/Core/Archives/OglIarWebDavStorage.cs" Link="OglIarWebDavStorage.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -14,6 +14,36 @@ internal static class Program
|
||||
Guid region = Guid.Parse("11111111-1111-1111-1111-111111111111");
|
||||
Guid job = Guid.Parse("22222222-2222-2222-2222-222222222222");
|
||||
string path = OglIarTransferPolicy.Resolve("/srv/ogl-iar", region, job);
|
||||
// WebDAV path policy: only server-issued region/job IDs may be keys.
|
||||
Check(OglIarWebDavStorage.BackendName == "WebDAV",
|
||||
"WebDAV is a named backend");
|
||||
Check(OglIarWebDavStorage.ArchiveKey(region, job) ==
|
||||
"11111111-1111-1111-1111-111111111111/22222222-2222-2222-2222-222222222222.iar",
|
||||
"WebDAV object names are UUID-generated");
|
||||
Check(OglIarWebDavStorage.MarkerKey(region, job) ==
|
||||
OglIarWebDavStorage.ArchiveKey(region, job) + ".ogl-retention",
|
||||
"WebDAV retention marker belongs to the same job");
|
||||
try
|
||||
{
|
||||
OglIarWebDavStorage.ArchiveKey(Guid.Empty, job);
|
||||
throw new Exception("empty region accepted");
|
||||
}
|
||||
catch (ArgumentException) { count++; }
|
||||
try
|
||||
{
|
||||
new OglIarWebDavStorage("http://10.78.0.4:5005/IAR/",
|
||||
"10.78.0.4", "ogl-iar", "/tmp/unused");
|
||||
throw new Exception("insecure WebDAV URL accepted");
|
||||
}
|
||||
catch (ArgumentException) { count++; }
|
||||
try
|
||||
{
|
||||
new OglIarWebDavStorage("https://10.78.0.4:5006/IAR/",
|
||||
"10.78.0.5", "ogl-iar", "/tmp/unused");
|
||||
throw new Exception("wrong NAS accepted");
|
||||
}
|
||||
catch (ArgumentException) { count++; }
|
||||
|
||||
Check(path.EndsWith("11111111-1111-1111-1111-111111111111/22222222-2222-2222-2222-222222222222.iar"),
|
||||
"server-chosen opaque storage path");
|
||||
try { OglIarTransferPolicy.Resolve("/", region, job);
|
||||
|
||||
@@ -19,10 +19,12 @@ assert connector.index('"/api/v1/iar/me"') < connector.index('"/api/v1/iar"')
|
||||
for cfg in cfgs:
|
||||
assert cfg.count("[OglIarSelfService]") == 1
|
||||
assert "Enabled = false" in cfg.split("[OglIarSelfService]")[-1]
|
||||
assert 'StorageBackend = "WebDAV"' in cfg.split("[OglIarSelfService]")[-1]
|
||||
assert 'WebDavPasswordFile = ""' in cfg.split("[OglIarSelfService]")[-1]
|
||||
assert 'SharedStorageRoot = ""' in cfg.split("[OglIarSelfService]")[-1]
|
||||
|
||||
for marker in (
|
||||
'"Enabled", false', '"SharedStorageRoot", ""',
|
||||
'"Enabled", false', '"SharedStorageRoot",',
|
||||
"m_SharedRoot = m_Enabled ?", "maximumTotal",
|
||||
"NexScopes.InventoryRead", "NexScopes.InventoryWrite",
|
||||
"resident_token_required", "principal.Subject",
|
||||
@@ -81,7 +83,7 @@ for marker in (
|
||||
):
|
||||
assert marker in nas, marker
|
||||
for marker in (
|
||||
'GetString("NasHost", "")', 'GetInt("RetentionDays", 30)',
|
||||
'GetString("NasHost", "10.78.0.4")', 'GetInt("RetentionDays", 30)',
|
||||
'string.Equals(m_NasHost, "10.78.0.4"',
|
||||
"m_CleanupTimer = new Timer(", "TimeSpan.FromHours(1)",
|
||||
"OglIarNasStorage.RequireMounted(m_SharedRoot, m_NasHost)",
|
||||
@@ -106,3 +108,27 @@ assert "OglIarNasStorage.cs" in text(
|
||||
"tools/ci/OglIarSelfServiceRegression/OglIarSelfServiceRegression.csproj")
|
||||
assert "10.78.0.4" in text("doc/NexVerse/OGL_IAR_SELF_SERVICE.md")
|
||||
print("OGL IAR resident self-service static contracts PASS")
|
||||
|
||||
# WebDAV is the default storage contract; NFS remains opt-in and fail-closed.
|
||||
dav = text("NexVerse/Core/Archives/OglIarWebDavStorage.cs")
|
||||
for marker in ('BackendName = "WebDAV"', 'ConnectCallback', '10.78.0.4',
|
||||
'AllowAutoRedirect = false', 'UseProxy = false',
|
||||
'Uri.UriSchemeHttps', 'File.GetUnixFileMode',
|
||||
'Request("MKCOL"', 'Request("PUT"', 'Request("HEAD"',
|
||||
'Request("GET"', 'Request("DELETE"', 'Request("PROPFIND"',
|
||||
'Content-Range', 'HttpCompletionOption.ResponseHeadersRead'):
|
||||
assert marker in dav, marker
|
||||
for marker in ('m_WebDav.Upload(', 'm_WebDav.DownloadChunk(',
|
||||
'm_WebDav.Digest(', 'm_WebDav.Delete(', 'm_WebDav.Size(',
|
||||
'm_UseWebDav ? "WebDAV" : "NFS"', 'TemporaryStorageRoot',
|
||||
'if (!m_UseWebDav)', 'CleanupExpiredWebDav'):
|
||||
assert marker in api, marker
|
||||
for marker in ('m_IarWebDav.Download(', 'm_IarWebDav.Upload(',
|
||||
'm_IarWebDavMaximumBytes', 'File.Delete(stage)',
|
||||
'"storage_backend"', 'OglIarNasStorage.RequireMounted('):
|
||||
assert marker in node, marker
|
||||
for p in ("bin/OpenSim.ini", "bin/OpenSim.ini.example"):
|
||||
ini = text(p)
|
||||
assert '[OpenGenesisLINKIAR]' in ini
|
||||
assert 'StorageBackend = "WebDAV"' in ini
|
||||
assert 'WebDavPasswordFile = ""' in ini
|
||||
@@ -17,7 +17,9 @@ for rel, arch, enabled, http, xmlrpc in (
|
||||
# the reusable Standalone example and a bounded site-specific allowance
|
||||
# for the active simulator INI, without dropping the strict INI parser,
|
||||
# HTTP auto-port checks or disabled-Experiences contract.
|
||||
max_lines = 380 if rel == "bin/OpenSim.ini" else 320
|
||||
# The compact profiles now also declare the WebDAV IAR backend without
|
||||
# changing existing startup/physics/auto-port semantics.
|
||||
max_lines = 400 if rel == "bin/OpenSim.ini" else 340
|
||||
assert len(src.splitlines()) < max_lines, rel
|
||||
assert "[Startup] section below." not in src
|
||||
assert not any(k in cfg.sections() for k in ("OGLPathfinding", "OGLNpcNavigation"))
|
||||
|
||||
Reference in new issue
Block a user