From 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 21:24:15 +1000 Subject: Dump OpenSim 0.9.0.1 into it's own branch. --- OpenSim/Region/Application/OpenSimBase.cs | 185 +++++++++++++++++++++++------- 1 file changed, 142 insertions(+), 43 deletions(-) (limited to 'OpenSim/Region/Application/OpenSimBase.cs') diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index ab6f036..9f349c0 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -85,9 +85,10 @@ namespace OpenSim protected string proxyUrl; protected int proxyOffset = 0; - + public string userStatsURI = String.Empty; public string managedStatsURI = String.Empty; + public string managedStatsPassword = String.Empty; protected bool m_autoCreateClientStack = true; @@ -110,6 +111,10 @@ namespace OpenSim public List m_plugins = new List(); + private List m_permsModules; + + private bool m_securePermissionsLoading = true; + /// /// The config information passed into the OpenSimulator region server. /// @@ -121,7 +126,7 @@ namespace OpenSim { get { return m_EnvConfigSource; } } - + public uint HttpServerPort { get { return m_httpServerPort; } @@ -206,7 +211,7 @@ namespace OpenSim } /// - /// Performs startup specific to the region server, including initialization of the scene + /// Performs startup specific to the region server, including initialization of the scene /// such as loading configuration from disk. /// protected override void StartupSpecific() @@ -214,12 +219,28 @@ namespace OpenSim IConfig startupConfig = Config.Configs["Startup"]; if (startupConfig != null) { + // refuse to run MegaRegions + if(startupConfig.GetBoolean("CombineContiguousRegions", false)) + { + m_log.Fatal("CombineContiguousRegions (MegaRegions) option is no longer suported. Use a older version to save region contents as OAR, then import into a fresh install of this new version"); + throw new Exception("CombineContiguousRegions not suported"); + } + string pidFile = startupConfig.GetString("PIDFile", String.Empty); if (pidFile != String.Empty) CreatePIDFile(pidFile); - + userStatsURI = startupConfig.GetString("Stats_URI", String.Empty); + + m_securePermissionsLoading = startupConfig.GetBoolean("SecurePermissionsLoading", true); + + string permissionModules = Util.GetConfigVarFromSections(Config, "permissionmodules", + new string[] { "Startup", "Permissions" }, "DefaultPermissionsModule"); + + m_permsModules = new List(permissionModules.Split(',').Select(m => m.Trim())); + managedStatsURI = startupConfig.GetString("ManagedStatsRemoteFetchURI", String.Empty); + managedStatsPassword = startupConfig.GetString("ManagedStatsRemoteFetchPassword", String.Empty); } // Load the simulation data service @@ -235,11 +256,11 @@ namespace OpenSim if (m_simulationDataService == null) throw new Exception( string.Format( - "Could not load an ISimulationDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [SimulationDataStore] config section.", + "Could not load an ISimulationDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [SimulationDataStore] config section.", module)); // Load the estate data service - module = Util.GetConfigVarFromSections(Config, "LocalServiceModule", new string[]{"EstateDataStore", "EstateService"}, String.Empty); + module = Util.GetConfigVarFromSections(Config, "LocalServiceModule", new string[]{"EstateDataStore", "EstateService"}, String.Empty); if (String.IsNullOrEmpty(module)) throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] or [EstateService] section"); @@ -249,7 +270,7 @@ namespace OpenSim if (m_estateDataService == null) throw new Exception( string.Format( - "Could not load an IEstateDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [EstateDataStore] config section.", + "Could not load an IEstateDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [EstateDataStore] config section.", module)); } @@ -386,9 +407,9 @@ namespace OpenSim // set initial ServerURI regionInfo.HttpPort = m_httpServerPort; regionInfo.ServerURI = "http://" + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort.ToString() + "/"; - + regionInfo.osSecret = m_osSecret; - + if ((proxyUrl.Length > 0) && (portadd_flag)) { // set proxy url to RegionInfo @@ -410,19 +431,48 @@ namespace OpenSim } else m_log.Error("[REGIONMODULES]: The new RegionModulesController is missing..."); + if (m_securePermissionsLoading) + { + foreach (string s in m_permsModules) + { + if (!scene.RegionModules.ContainsKey(s)) + { + m_log.Fatal("[MODULES]: Required module " + s + " not found."); + Environment.Exit(0); + } + } + + m_log.InfoFormat("[SCENE]: Secure permissions loading enabled, modules loaded: {0}", String.Join(" ", m_permsModules.ToArray())); + } + scene.SetModuleInterfaces(); +// First Step of bootreport sequence + if (scene.SnmpService != null) + { + scene.SnmpService.ColdStart(1,scene); + scene.SnmpService.LinkDown(scene); + } + + if (scene.SnmpService != null) + { + scene.SnmpService.BootInfo("Loading prims", scene); + } while (regionInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null) SetUpEstateOwner(scene); + scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID); + // Prims have to be loaded after module configuration since some modules may be invoked during the load scene.LoadPrimsFromStorage(regionInfo.originRegionID); - + // TODO : Try setting resource for region xstats here on scene MainServer.Instance.AddStreamHandler(new RegionStatsHandler(regionInfo)); - - scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID); - scene.EventManager.TriggerParcelPrimCountUpdate(); + + if (scene.SnmpService != null) + { + scene.SnmpService.BootInfo("Grid Registration in progress", scene); + } try { @@ -431,18 +481,32 @@ namespace OpenSim catch (Exception e) { m_log.ErrorFormat( - "[STARTUP]: Registration of region with grid failed, aborting startup due to {0} {1}", + "[STARTUP]: Registration of region with grid failed, aborting startup due to {0} {1}", e.Message, e.StackTrace); + if (scene.SnmpService != null) + { + scene.SnmpService.Critical("Grid registration failed. Startup aborted.", scene); + } // Carrying on now causes a lot of confusion down the // line - we need to get the user's attention Environment.Exit(1); } + if (scene.SnmpService != null) + { + scene.SnmpService.BootInfo("Grid Registration done", scene); + } + // We need to do this after we've initialized the // scripting engines. scene.CreateScriptInstances(); + if (scene.SnmpService != null) + { + scene.SnmpService.BootInfo("ScriptEngine started", scene); + } + SceneManager.Add(scene); //if (m_autoCreateClientStack) @@ -454,10 +518,20 @@ namespace OpenSim // } //} + if (scene.SnmpService != null) + { + scene.SnmpService.BootInfo("Initializing region modules", scene); + } scene.EventManager.OnShutdown += delegate() { ShutdownRegion(scene); }; mscene = scene; + if (scene.SnmpService != null) + { + scene.SnmpService.BootInfo("The region is operational", scene); + scene.SnmpService.LinkUp(scene); + } + //return clientServers; } @@ -535,7 +609,7 @@ namespace OpenSim if (rawEstateOwnerUuid == null) rawEstateOwnerUuid = MainConsole.Instance.CmdPrompt("User ID", UUID.Random().ToString()); - + UUID estateOwnerUuid = UUID.Zero; if (!UUID.TryParse(rawEstateOwnerUuid, out estateOwnerUuid)) { @@ -573,6 +647,11 @@ namespace OpenSim private void ShutdownRegion(Scene scene) { m_log.DebugFormat("[SHUTDOWN]: Shutting down region {0}", scene.RegionInfo.RegionName); + if (scene.SnmpService != null) + { + scene.SnmpService.BootInfo("The region is shutting down", scene); + scene.SnmpService.LinkDown(scene); + } IRegionModulesController controller; if (ApplicationRegistry.TryGet(out controller)) { @@ -593,7 +672,7 @@ namespace OpenSim scene.DeleteAllSceneObjects(); SceneManager.CloseScene(scene); //ShutdownClientServer(scene.RegionInfo); - + if (!cleanup) return; @@ -655,7 +734,7 @@ namespace OpenSim SceneManager.CloseScene(scene); //ShutdownClientServer(scene.RegionInfo); } - + /// /// Remove a region from the simulator without deleting it permanently. /// @@ -667,7 +746,7 @@ namespace OpenSim if (SceneManager.TryGetScene(name, out target)) CloseRegion(target); } - + /// /// Create a scene and its initial base structures. /// @@ -703,15 +782,15 @@ namespace OpenSim IEstateDataService estateDataService, AgentCircuitManager circuitManager) { return new Scene( - regionInfo, circuitManager, + regionInfo, circuitManager, simDataService, estateDataService, Config, m_version); } - + protected virtual void HandleRestartRegion(RegionInfo whichRegion) { m_log.InfoFormat( - "[OPENSIM]: Got restart signal from SceneManager for region {0} ({1},{2})", + "[OPENSIM]: Got restart signal from SceneManager for region {0} ({1},{2})", whichRegion.RegionName, whichRegion.RegionLocX, whichRegion.RegionLocY); //ShutdownClientServer(whichRegion); @@ -746,18 +825,18 @@ namespace OpenSim /// /// Handler to supply the current extended status of this sim - /// Sends the statistical data in a json serialization + /// Sends the statistical data in a json serialization /// public class XSimStatusHandler : BaseStreamHandler { OpenSimBase m_opensim; - - public XSimStatusHandler(OpenSimBase sim) + + public XSimStatusHandler(OpenSimBase sim) : base("GET", "/" + Util.SHA1Hash(sim.osSecret), "XSimStatus", "Simulator XStatus") { m_opensim = sim; } - + protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { @@ -772,20 +851,20 @@ namespace OpenSim /// /// Handler to supply the current extended status of this sim to a user configured URI - /// Sends the statistical data in a json serialization - /// If the request contains a key, "callback" the response will be wrappend in the + /// Sends the statistical data in a json serialization + /// If the request contains a key, "callback" the response will be wrappend in the /// associated value for jsonp used with ajax/javascript /// protected class UXSimStatusHandler : BaseStreamHandler { OpenSimBase m_opensim; - + public UXSimStatusHandler(OpenSimBase sim) : base("GET", "/" + sim.userStatsURI, "UXSimStatus", "Simulator UXStatus") { - m_opensim = sim; + m_opensim = sim; } - + protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { @@ -798,6 +877,26 @@ namespace OpenSim } } + /// + /// handler to supply serving http://domainname:port/robots.txt + /// + public class SimRobotsHandler : BaseStreamHandler + { + public SimRobotsHandler() : base("GET", "/robots.txt", "SimRobots.txt", "Simulator Robots.txt") {} + + protected override byte[] ProcessRequest(string path, Stream request, + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) + { + string robots = "# go away\nUser-agent: *\nDisallow: /\n"; + return Util.UTF8.GetBytes(robots); + } + + public override string ContentType + { + get { return "text/plain"; } + } + } + #endregion /// @@ -858,7 +957,7 @@ namespace OpenSim { regionnum = SceneManager.Scenes.Count; } - + /// /// Create an estate with an initial region. /// @@ -885,19 +984,19 @@ namespace OpenSim MainConsole.Instance.OutputFormat("An estate named {0} already exists. Please try again.", newName); return false; } - + regInfo.EstateSettings.EstateName = newName; - + // FIXME: Later on, the scene constructor will reload the estate settings no matter what. // Therefore, we need to do an initial save here otherwise the new estate name will be reset // back to the default. The reloading of estate settings by scene could be eliminated if it - // knows that the passed in settings in RegionInfo are already valid. Also, it might be + // knows that the passed in settings in RegionInfo are already valid. Also, it might be // possible to eliminate some additional later saves made by callers of this method. - EstateDataService.StoreEstateSettings(regInfo.EstateSettings); - + EstateDataService.StoreEstateSettings(regInfo.EstateSettings); + return true; } - + /// /// Load the estate information for the provided RegionInfo object. /// @@ -911,8 +1010,8 @@ namespace OpenSim return false; // estate info in the database did not change m_log.WarnFormat("[ESTATE] Region {0} is not part of an estate.", regInfo.RegionName); - - List estates = EstateDataService.LoadEstateSettingsAll(); + + List estates = EstateDataService.LoadEstateSettingsAll(); Dictionary estatesByName = new Dictionary(); foreach (EstateSettings estate in estates) @@ -1005,12 +1104,12 @@ namespace OpenSim MainConsole.Instance.Output("Joining the estate failed. Please try again."); } } - } + } - return true; // need to update the database - } + return true; // need to update the database + } } - + public class OpenSimConfigSource { public IConfigSource Source; -- cgit v1.1