feat(0.9.3.10): automatische HTTP-Portwahl und bereinigte INI (#171)

* feat(0.9.3.10): update bin/OpenSim.ini

* feat(0.9.3.10): update bin/OpenSim.ini.example

* feat(0.9.3.10): update OpenSim/Region/Application/ConfigurationLoader.cs

* feat(0.9.3.10): update OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs

* feat(0.9.3.10): update .github/workflows/nexjast-ci.yml

* feat(0.9.3.10): update tools/ci/verify_simulator_runtime_profile.py

* feat(0.9.3.10): add tools/ci/verify_opensim_autoports.py

* feat(0.9.3.10): add doc/NexVerse/OPEN_SIM_INI_PORT_MANAGEMENT_09310.md

* test(09310): do not require obsolete commented OGLVoice INI examples

* test(09310): do not require obsolete commented OGLVoice INI examples
This commit is contained in:
OpenGenesis (MPL 2.0) authored and GitHub committed 2026-10-11 23:03:14 +02:00
1 parent 16d219f142
commit ec05155c3a
10 files changed
+270 -2515

No files matched your search

+4
View File
@@ -278,6 +278,10 @@ jobs:
shell: bash
run: python3 tools/ci/verify_experience_viewer_purchase.py
- name: Verify compact simulator INIs and automatic HTTP ports
shell: bash
run: python3 tools/ci/verify_opensim_autoports.py
- name: Regression-test NexExperiences persistence and K/V
shell: bash
run: dotnet run --configuration Release --project tools/ci/NexExperiencesRegression/NexExperiencesRegression.csproj
@@ -28,6 +28,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Threading;
using System.Xml;
@@ -342,7 +344,130 @@ namespace OpenSim
= startupConfig.GetString("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll");
}
NexVerseHttpPortAllocator.Apply(m_config.Source);
m_networkServersInfo.loadFromConfiguration(m_config.Source);
}
}
/// <summary>
/// Cooperative per-host simulator HTTP port allocation; never touches region UDP ports.
/// </summary>
internal static class NexVerseHttpPortAllocator
{
private static readonly ILog m_log = LogManager.GetLogger(typeof(NexVerseHttpPortAllocator));
private static readonly object m_sync = new object();
private static FileStream m_lease;
private static int m_selectedPort;
public static void Apply(IConfigSource source)
{
IConfig network = source.Configs["Network"];
if (network == null)
return;
int configuredPort = network.GetInt("http_listener_port", 9000);
if (configuredPort < 0 || configuredPort > 65535)
throw new InvalidOperationException("[PORTS]: Invalid http_listener_port.");
if (configuredPort != 0)
return; // An explicit fixed HTTP port always wins.
IConfig options = source.Configs["NexVerseAutoPorts"];
if (options == null || !options.GetBoolean("Enabled", false))
throw new InvalidOperationException(
"[PORTS]: http_listener_port=0 requires NexVerseAutoPorts.Enabled=true.");
if (network.GetBoolean("http_listener_ssl", false))
throw new InvalidOperationException(
"[PORTS]: Automatic HTTP allocation does not support http_listener_ssl=true.");
int min = options.GetInt("HttpPortMin", 9000);
int max = options.GetInt("HttpPortMax", 9099);
if (min < 1024 || max > 65535 || max < min || max - min > 1000)
throw new InvalidOperationException("[PORTS]: Invalid HTTP port range.");
lock (m_sync)
{
if (m_lease != null)
{
network.Set("http_listener_port", m_selectedPort);
return;
}
string stateDirectory = Path.Combine(Util.configDir(), "data", "NexVersePorts");
string lockDirectory = Path.Combine(Path.GetTempPath(), "opengenesislink-http-port-locks");
Directory.CreateDirectory(stateDirectory);
Directory.CreateDirectory(lockDirectory);
string preferredFile = Path.Combine(stateDirectory, "http.port");
int preferred = -1;
if (File.Exists(preferredFile))
int.TryParse(File.ReadAllText(preferredFile).Trim(), out preferred);
int httpsPort = network.GetBoolean("https_listener", false)
? network.GetInt("https_port", 0) : 0;
for (int pass = 0; pass < 2; pass++)
{
int first = pass == 0 ? preferred : min;
int last = pass == 0 ? preferred : max;
if (pass == 0 && (preferred < min || preferred > max))
continue;
for (int port = first; port <= last; port++)
{
if (port == httpsPort)
continue;
string lockPath = Path.Combine(lockDirectory, port.ToString(
System.Globalization.CultureInfo.InvariantCulture) + ".lock");
FileStream lease = null;
try
{
lease = new FileStream(lockPath, FileMode.OpenOrCreate,
FileAccess.ReadWrite, FileShare.ReadWrite);
lease.Lock(0, 1);
}
catch (IOException)
{
lease?.Dispose();
continue;
}
bool retained = false;
try
{
// Other software may take a port after this probe.
TcpListener probe = new TcpListener(IPAddress.Any, port);
try
{
probe.Start();
}
catch (SocketException)
{
continue;
}
finally
{
probe.Stop();
}
File.WriteAllText(preferredFile, port.ToString(
System.Globalization.CultureInfo.InvariantCulture));
network.Set("http_listener_port", port);
m_selectedPort = port;
m_lease = lease;
retained = true;
m_log.InfoFormat("[PORTS]: Simulator HTTP TCP port {0} auto-selected.", port);
return;
}
finally
{
if (!retained)
{
try { lease.Unlock(0, 1); }
finally { lease.Dispose(); }
}
}
}
}
}
throw new InvalidOperationException(
"[PORTS]: No free HTTP TCP port in the configured range.");
}
}
}
@@ -127,6 +127,17 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
{
}
}
// -1 shares the resolved simulator HTTP listener. 0 disables XML-RPC.
if (m_remoteDataPort == -1)
{
IConfig network = config.Configs["Network"];
int listenerPort = network?.GetInt("http_listener_port", 0) ?? 0;
if (listenerPort <= 0 || listenerPort > 65535)
throw new InvalidOperationException(
"[XMLRPC]: Shared llRemoteData requires an HTTP listener.");
m_remoteDataPort = listenerPort;
m_log.InfoFormat("[XMLRPC]: Sharing simulator HTTP TCP port {0}", listenerPort);
}
}
public void PostInitialise()
+13 -1232
View File
File diff suppressed because it is too large. Load diff
+13 -1281
View File
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,50 @@
# OpenGenesisLINK 0.9.3.10 – OpenSim.ini und automatische Ports
11.10.2026: Neu auf aktuellem main nach der Entfernung von OGL Pathfinding.
Der geschlossene alte PR #164 darf nicht unveraendert uebernommen werden.
## Bereinigung
bin/OpenSim.ini (Grid) und bin/OpenSim.ini.example (Standalone) wurden von
historischen Kommentaren und auskommentierten Einstellungen befreit.
Alle bisherigen aktiven Schluessel blieben erhalten, ausser den bewussten
Aenderungen an Grid HTTP und XMLRPC. Leere Sektionen bleiben wegen moeglicher
legacy Abhaengigkeiten bestehen. OpenSimDefaults.ini wird nicht veraendert.
## Grid HTTP automatische Portwahl
[Network]
http_listener_port = 0
[NexVerseAutoPorts]
Enabled = true
HttpPortMin = 9000
HttpPortMax = 9099
Ein expliziter positiver Network.http_listener_port hat immer Vorrang.
0 ohne Enabled=true, ungueltige Bereiche und SSL am Hauptlistener werden
abgewiesen. Der Simulator versucht zuerst den lokal gespeicherten Port unter
bin/data/NexVersePorts/http.port und scannt sonst den Bereich. Eine
Dateisperre im Temp-Verzeichnis verhindert kollidierende OGL-Instanzen,
ein TCP-Bind-Test erkennt auch andere Dienste. Fremde Programme koennen
zwischen dieser Probe und der echten Bindung noch ein Rennen verursachen.
Separat konfiguriertes HTTPS wird bei der Portwahl beruecksichtigt.
Standalone behaelt den festen HTTP-Port 9000.
## XMLRPC und Regionen
Im Grid-Profil verwendet XMLRPC.XmlRpcPort=-1 den ausgewaehlten HTTP-Port.
0 deaktiviert RemoteData; positive feste Ports funktionieren weiterhin.
Standalone und OpenSimDefaults.ini behalten XmlRpcPort=20800.
Fremde XMLRPC-Clients muessen die neue Grid HTTP-Adresse verwenden.
Es werden **keine** UDP-Regionsports, NAT-Regeln, Firewalls oder
Reverse-Proxies automatisch konfiguriert. TCP 9000–9099 sowie die
konfigurierten Region-UDP-Ports muessen extern erreichbar sein.
## Abnahme
CI: python3 tools/ci/verify_opensim_autoports.py sowie regulärer Build.
Live-Test mit parallelen Simulatoren und Neustart steht vor Stable noch aus.
Kein Simulator wird durch einen GitHub-Commit automatisch neugestartet.
Lokale Konfigurationsaenderungen vor dem Pull separat sichern.
+1 -1
View File
@@ -32,7 +32,7 @@ for path in ("bin/Robust.ini.example", "bin/Robust.HG.ini.example"):
assert 'Mode = "GridAuthority"' in config
assert 'IncludeHypergridGuests = true' in config
sim = (root/"bin/OpenSim.ini.example").read_text()
assert ';[OGLVoice]' in sim and 'Mode = "Standalone"' in sim
assert "[OGLVoice]" not in sim, "Standalone voice must be configured by the operator"
roadmap = (root/"doc/NexVerse/OGLVOICE_ARCHITECTURE.md").read_text()
assert "nicht" in roadmap.lower() and "LiveKit" in roadmap
print("OGLVoice Robust/Standalone signed provider discovery CI guard: OK")
+3 -1
View File
@@ -40,7 +40,9 @@ for conf in ("bin/Robust.HG.ini.example","bin/Robust.ini.example"):
section=(root/conf).read_text().split("[OGLVoice]",1)[1].split("\n[",1)[0]
assert "EnableFirestormGateway = false" in section
assert 'MediaGatewayUrl = ""' in section
assert "EnableFirestormGateway = true" in (root/"bin/OpenSim.ini.example").read_text()
# The compact default INI does not ship an enabled OGLVoice example.
assert "[OGLVoice]" not in (root/"bin/OpenSim.ini.example").read_text()
assert 'local.GetBoolean("EnableFirestormGateway", false)' in node
assert "OGLVOICE_LIVEKIT_API_SECRET" not in region
assert "OGLVOICE_LIVEKIT_API_KEY" not in region
assert "ChatSessionRequest" not in region # no false group voice support
+48
View File
@@ -0,0 +1,48 @@
#!/usr/bin/env python3
"""Validate compact simulator INIs and optional HTTP TCP auto-port allocation."""
from configparser import ConfigParser
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
for rel, arch, enabled, http, xmlrpc in (
("bin/OpenSim.ini", "config-include/GridHypergrid.ini", True, 0, -1),
("bin/OpenSim.ini.example", "config-include/Standalone.ini", False, 9000, 20800),
):
src = (ROOT / rel).read_text(encoding="utf-8")
cfg = ConfigParser(interpolation=None, strict=True)
cfg.optionxform = str
cfg.read_string(src)
assert len(src.splitlines()) < 320, rel
assert "[Startup] section below." not in src
assert not any(k in cfg.sections() for k in ("OGLPathfinding", "OGLNpcNavigation"))
assert cfg.get("Architecture", "Include-Architecture").strip('"') == arch
assert cfg.getboolean("NexVerseAutoPorts", "Enabled") is enabled
assert cfg.getint("NexVerseAutoPorts", "HttpPortMin") == 9000
assert cfg.getint("NexVerseAutoPorts", "HttpPortMax") == 9099
assert cfg.getint("Network", "http_listener_port") == http
assert cfg.getint("XMLRPC", "XmlRpcPort") == xmlrpc
assert cfg.get("Startup", "physics") == "BulletSim"
assert cfg.get("Startup", "meshing") == "Meshmerizer"
assert cfg.get("Economy", "economymodule") == "NexVerseMoneyModule"
for key in ("MasterBankEnabled", "AllowHypergridGuests"):
assert not cfg.getboolean("NexEconomyViewer", key)
for key in ("Enabled", "FirestormReadCaps", "FirestormPermissionCaps",
"FirestormManageCaps", "ScriptPendingConsent", "NativeExperiencePrompt"):
assert cfg.getboolean("NexExperiencesViewer", key)
for key, var in (("ApiKey","NEXVERSE_EXPERIENCES_API_KEY"),
("ViewerPermissionsApiKey","NEXVERSE_EXPERIENCES_VIEWER_PERMISSIONS_API_KEY"),
("ViewerManageApiKey","NEXVERSE_EXPERIENCES_VIEWER_MANAGE_API_KEY")):
assert cfg.get("NexExperiencesViewer", key) == '"' + "$" + '{Environment|' + var + '}"'
code = (ROOT / "OpenSim/Region/Application/ConfigurationLoader.cs").read_text()
assert code.index("NexVerseHttpPortAllocator.Apply(m_config.Source);") < code.index("m_networkServersInfo.loadFromConfiguration(m_config.Source);")
for token in ('if (configuredPort != 0)', 'lease.Lock(0, 1);',
'probe.Start();', 'network.Set("http_listener_port", port);',
'Path.Combine(Util.configDir(), "data", "NexVersePorts")',
'GetBoolean("http_listener_ssl", false)',
'GetBoolean("https_listener", false)'):
assert token in code, token
xml = (ROOT / "OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs").read_text()
assert "if (m_remoteDataPort == -1)" in xml
assert 'network?.GetInt("http_listener_port", 0)' in xml
print("OpenGenesisLINK INIs and HTTP automatic port selection: OK")
@@ -41,6 +41,8 @@ for rel in ("bin/OpenSim.ini", "bin/OpenSim.ini.example", "bin/OpenSimDefaults.i
path = ROOT / rel
values = parse_ini(path)
for key, expected in EXPECTED.items():
if rel == "bin/OpenSim.ini" and key == ("XMLRPC", "XmlRpcPort"):
expected = "-1"
actual = values.get(key)
if actual is None:
errors.append(f"{rel}: missing active [{key[0]}] {key[1]}")