* feat(logging): rotate Robust logs daily into bin/logs/Robust_dd_MM_yyyy.log * feat(logging): rotate OpenSim logs daily into bin/logs/OpenSim_dd_MM_yyyy.log * feat(worldapi): secured paginated per-day ROBUST/OpenSim log reader * feat(worldapi): register secured daily logs in HTTP routing and API catalogs * feat(worldapi): register secured daily logs in HTTP routing and API catalogs * feat(worldapi): register secured daily logs in HTTP routing and API catalogs * feat(worldapi): create grouped daily console logs and audit sections * feat(worldapi): redesigned operator console with daily expandable log browser and grouped audit pages * feat(worldapi): inline admin operation execution and real user create/search/deactivate UI * fix(logging): compile-safe defensive secret redaction regex for operator logs * feat(worldapi): full cinematic responsive operator login redesign with original branding * feat(nexbus): archive authenticated external OpenSim logs daily by NodeId * fix(nexbus): match subscribed Action<NexEvent> handler signature * feat(nexbus): automatically forward daily OpenSim logs from every TLS-connected simulator NodeId with signed replay-safe chunks * feat(nexbus): subscribe ROBUST to authenticated NodeId log batches from connected simulators * feat(logging): include remote NodeId daily archives in secure file list and reader * feat(worldapi): show remote NodeId and archive date in expandable log viewer * security(nexbus): acknowledge remote log batches only after persistence and prevent peer broadcast * security(nexbus): acknowledge remote log batches only after persistence and prevent peer broadcast * security(nexbus): make remote log ingestion synchronous and ack only persisted chunks * security(nexbus): route signed log messages directly to committed NodeId archive receiver * docs(nexbus): enable signed TLS-only external NodeId log sync in NodeAgent example config * docs(worldapi): audit supplied 63-table SQL export against API and code, record retained schemas and NodeId log relay handoff * test(worldapi): gate full operator UI and authenticated NexBus NodeId daily log forwarding * ci(worldapi): run operator dashboard, daily log rotation and signed NodeId relay checks * test(worldapi): retain admin auth requirement across new CRUD, audit and log pages * test(worldapi): accept operator documentation with concrete Robust/OpenSim enum in URL
106 lines
3.3 KiB
C#
106 lines
3.3 KiB
C#
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
using System;
|
|
using System.Collections.Concurrent;
|
|
using System.Threading;
|
|
|
|
namespace NexVerse.Core.Messaging
|
|
{
|
|
public sealed class DistributedNexEventBus : INexEventBus, IDisposable
|
|
{
|
|
private const int DefaultDeduplicationWindow = 10000;
|
|
|
|
private readonly InMemoryNexEventBus m_Local = new InMemoryNexEventBus();
|
|
private readonly INexEventTransport m_Transport;
|
|
// ROBUST-only authenticated NexBus log chunks bypass normal fan-out.
|
|
// Unlike ordinary bus events, they must never be re-relayed to
|
|
// third-party simulator peers which would expose private log text.
|
|
public Func<NexEvent, bool> ReceiveLogChunk { get; set; }
|
|
private readonly ConcurrentDictionary<Guid, byte> m_Seen =
|
|
new ConcurrentDictionary<Guid, byte>();
|
|
private readonly ConcurrentQueue<Guid> m_SeenOrder =
|
|
new ConcurrentQueue<Guid>();
|
|
private readonly int m_DeduplicationWindow;
|
|
private int m_Disposed;
|
|
|
|
public DistributedNexEventBus(
|
|
INexEventTransport transport,
|
|
int deduplicationWindow = DefaultDeduplicationWindow)
|
|
{
|
|
m_Transport = transport ?? throw new ArgumentNullException(nameof(transport));
|
|
m_DeduplicationWindow = Math.Max(128, deduplicationWindow);
|
|
}
|
|
|
|
public IDisposable Subscribe(string eventName, Action<NexEvent> handler)
|
|
{
|
|
ThrowIfDisposed();
|
|
return m_Local.Subscribe(eventName, handler);
|
|
}
|
|
|
|
public void Publish(NexEvent nexEvent)
|
|
{
|
|
ThrowIfDisposed();
|
|
|
|
if (nexEvent == null)
|
|
throw new ArgumentNullException(nameof(nexEvent));
|
|
|
|
if (!TryMarkSeen(nexEvent.EventId))
|
|
return;
|
|
|
|
m_Local.Publish(nexEvent);
|
|
m_Transport.Send(nexEvent);
|
|
}
|
|
|
|
public bool Receive(NexEvent nexEvent)
|
|
{
|
|
ThrowIfDisposed();
|
|
|
|
if (nexEvent == null)
|
|
throw new ArgumentNullException(nameof(nexEvent));
|
|
|
|
if (!TryMarkSeen(nexEvent.EventId))
|
|
return false;
|
|
|
|
m_Local.Publish(nexEvent);
|
|
|
|
// Re-relay accepted remote events. Peers receiving the same EventId
|
|
// suppress it, allowing hub or mesh topologies without event loops.
|
|
m_Transport.Send(nexEvent);
|
|
return true;
|
|
}
|
|
|
|
private bool TryMarkSeen(Guid eventId)
|
|
{
|
|
if (eventId == Guid.Empty || !m_Seen.TryAdd(eventId, 0))
|
|
return false;
|
|
|
|
m_SeenOrder.Enqueue(eventId);
|
|
TrimSeen();
|
|
return true;
|
|
}
|
|
|
|
private void TrimSeen()
|
|
{
|
|
while (m_Seen.Count > m_DeduplicationWindow &&
|
|
m_SeenOrder.TryDequeue(out Guid oldId))
|
|
{
|
|
m_Seen.TryRemove(oldId, out _);
|
|
}
|
|
}
|
|
|
|
private void ThrowIfDisposed()
|
|
{
|
|
if (Volatile.Read(ref m_Disposed) != 0)
|
|
throw new ObjectDisposedException(nameof(DistributedNexEventBus));
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
if (Interlocked.Exchange(ref m_Disposed, 1) != 0)
|
|
return;
|
|
|
|
m_Transport.Dispose();
|
|
}
|
|
}
|
|
}
|