aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Application/OpenSimBase.cs
diff options
context:
space:
mode:
authoronefang2019-05-19 21:24:15 +1000
committeronefang2019-05-19 21:24:15 +1000
commit5e4d6cab00cb29cd088ab7b62ab13aff103b64cb (patch)
treea9fbc62df9eb2d1d9ba2698d8552eae71eca20d8 /OpenSim/Region/Application/OpenSimBase.cs
parentAdd a build script. (diff)
downloadopensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.zip
opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.gz
opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.bz2
opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.xz
Dump OpenSim 0.9.0.1 into it's own branch.
Diffstat (limited to 'OpenSim/Region/Application/OpenSimBase.cs')
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs185
1 files changed, 142 insertions, 43 deletions
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
85 85
86 protected string proxyUrl; 86 protected string proxyUrl;
87 protected int proxyOffset = 0; 87 protected int proxyOffset = 0;
88 88
89 public string userStatsURI = String.Empty; 89 public string userStatsURI = String.Empty;
90 public string managedStatsURI = String.Empty; 90 public string managedStatsURI = String.Empty;
91 public string managedStatsPassword = String.Empty;
91 92
92 protected bool m_autoCreateClientStack = true; 93 protected bool m_autoCreateClientStack = true;
93 94
@@ -110,6 +111,10 @@ namespace OpenSim
110 111
111 public List<IApplicationPlugin> m_plugins = new List<IApplicationPlugin>(); 112 public List<IApplicationPlugin> m_plugins = new List<IApplicationPlugin>();
112 113
114 private List<string> m_permsModules;
115
116 private bool m_securePermissionsLoading = true;
117
113 /// <value> 118 /// <value>
114 /// The config information passed into the OpenSimulator region server. 119 /// The config information passed into the OpenSimulator region server.
115 /// </value> 120 /// </value>
@@ -121,7 +126,7 @@ namespace OpenSim
121 { 126 {
122 get { return m_EnvConfigSource; } 127 get { return m_EnvConfigSource; }
123 } 128 }
124 129
125 public uint HttpServerPort 130 public uint HttpServerPort
126 { 131 {
127 get { return m_httpServerPort; } 132 get { return m_httpServerPort; }
@@ -206,7 +211,7 @@ namespace OpenSim
206 } 211 }
207 212
208 /// <summary> 213 /// <summary>
209 /// Performs startup specific to the region server, including initialization of the scene 214 /// Performs startup specific to the region server, including initialization of the scene
210 /// such as loading configuration from disk. 215 /// such as loading configuration from disk.
211 /// </summary> 216 /// </summary>
212 protected override void StartupSpecific() 217 protected override void StartupSpecific()
@@ -214,12 +219,28 @@ namespace OpenSim
214 IConfig startupConfig = Config.Configs["Startup"]; 219 IConfig startupConfig = Config.Configs["Startup"];
215 if (startupConfig != null) 220 if (startupConfig != null)
216 { 221 {
222 // refuse to run MegaRegions
223 if(startupConfig.GetBoolean("CombineContiguousRegions", false))
224 {
225 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");
226 throw new Exception("CombineContiguousRegions not suported");
227 }
228
217 string pidFile = startupConfig.GetString("PIDFile", String.Empty); 229 string pidFile = startupConfig.GetString("PIDFile", String.Empty);
218 if (pidFile != String.Empty) 230 if (pidFile != String.Empty)
219 CreatePIDFile(pidFile); 231 CreatePIDFile(pidFile);
220 232
221 userStatsURI = startupConfig.GetString("Stats_URI", String.Empty); 233 userStatsURI = startupConfig.GetString("Stats_URI", String.Empty);
234
235 m_securePermissionsLoading = startupConfig.GetBoolean("SecurePermissionsLoading", true);
236
237 string permissionModules = Util.GetConfigVarFromSections<string>(Config, "permissionmodules",
238 new string[] { "Startup", "Permissions" }, "DefaultPermissionsModule");
239
240 m_permsModules = new List<string>(permissionModules.Split(',').Select(m => m.Trim()));
241
222 managedStatsURI = startupConfig.GetString("ManagedStatsRemoteFetchURI", String.Empty); 242 managedStatsURI = startupConfig.GetString("ManagedStatsRemoteFetchURI", String.Empty);
243 managedStatsPassword = startupConfig.GetString("ManagedStatsRemoteFetchPassword", String.Empty);
223 } 244 }
224 245
225 // Load the simulation data service 246 // Load the simulation data service
@@ -235,11 +256,11 @@ namespace OpenSim
235 if (m_simulationDataService == null) 256 if (m_simulationDataService == null)
236 throw new Exception( 257 throw new Exception(
237 string.Format( 258 string.Format(
238 "Could not load an ISimulationDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [SimulationDataStore] config section.", 259 "Could not load an ISimulationDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [SimulationDataStore] config section.",
239 module)); 260 module));
240 261
241 // Load the estate data service 262 // Load the estate data service
242 module = Util.GetConfigVarFromSections<string>(Config, "LocalServiceModule", new string[]{"EstateDataStore", "EstateService"}, String.Empty); 263 module = Util.GetConfigVarFromSections<string>(Config, "LocalServiceModule", new string[]{"EstateDataStore", "EstateService"}, String.Empty);
243 if (String.IsNullOrEmpty(module)) 264 if (String.IsNullOrEmpty(module))
244 throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] or [EstateService] section"); 265 throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] or [EstateService] section");
245 266
@@ -249,7 +270,7 @@ namespace OpenSim
249 if (m_estateDataService == null) 270 if (m_estateDataService == null)
250 throw new Exception( 271 throw new Exception(
251 string.Format( 272 string.Format(
252 "Could not load an IEstateDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [EstateDataStore] config section.", 273 "Could not load an IEstateDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [EstateDataStore] config section.",
253 module)); 274 module));
254 } 275 }
255 276
@@ -386,9 +407,9 @@ namespace OpenSim
386 // set initial ServerURI 407 // set initial ServerURI
387 regionInfo.HttpPort = m_httpServerPort; 408 regionInfo.HttpPort = m_httpServerPort;
388 regionInfo.ServerURI = "http://" + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort.ToString() + "/"; 409 regionInfo.ServerURI = "http://" + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort.ToString() + "/";
389 410
390 regionInfo.osSecret = m_osSecret; 411 regionInfo.osSecret = m_osSecret;
391 412
392 if ((proxyUrl.Length > 0) && (portadd_flag)) 413 if ((proxyUrl.Length > 0) && (portadd_flag))
393 { 414 {
394 // set proxy url to RegionInfo 415 // set proxy url to RegionInfo
@@ -410,19 +431,48 @@ namespace OpenSim
410 } 431 }
411 else m_log.Error("[REGIONMODULES]: The new RegionModulesController is missing..."); 432 else m_log.Error("[REGIONMODULES]: The new RegionModulesController is missing...");
412 433
434 if (m_securePermissionsLoading)
435 {
436 foreach (string s in m_permsModules)
437 {
438 if (!scene.RegionModules.ContainsKey(s))
439 {
440 m_log.Fatal("[MODULES]: Required module " + s + " not found.");
441 Environment.Exit(0);
442 }
443 }
444
445 m_log.InfoFormat("[SCENE]: Secure permissions loading enabled, modules loaded: {0}", String.Join(" ", m_permsModules.ToArray()));
446 }
447
413 scene.SetModuleInterfaces(); 448 scene.SetModuleInterfaces();
449// First Step of bootreport sequence
450 if (scene.SnmpService != null)
451 {
452 scene.SnmpService.ColdStart(1,scene);
453 scene.SnmpService.LinkDown(scene);
454 }
455
456 if (scene.SnmpService != null)
457 {
458 scene.SnmpService.BootInfo("Loading prims", scene);
459 }
414 460
415 while (regionInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null) 461 while (regionInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null)
416 SetUpEstateOwner(scene); 462 SetUpEstateOwner(scene);
417 463
464 scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID);
465
418 // Prims have to be loaded after module configuration since some modules may be invoked during the load 466 // Prims have to be loaded after module configuration since some modules may be invoked during the load
419 scene.LoadPrimsFromStorage(regionInfo.originRegionID); 467 scene.LoadPrimsFromStorage(regionInfo.originRegionID);
420 468
421 // TODO : Try setting resource for region xstats here on scene 469 // TODO : Try setting resource for region xstats here on scene
422 MainServer.Instance.AddStreamHandler(new RegionStatsHandler(regionInfo)); 470 MainServer.Instance.AddStreamHandler(new RegionStatsHandler(regionInfo));
423 471
424 scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID); 472 if (scene.SnmpService != null)
425 scene.EventManager.TriggerParcelPrimCountUpdate(); 473 {
474 scene.SnmpService.BootInfo("Grid Registration in progress", scene);
475 }
426 476
427 try 477 try
428 { 478 {
@@ -431,18 +481,32 @@ namespace OpenSim
431 catch (Exception e) 481 catch (Exception e)
432 { 482 {
433 m_log.ErrorFormat( 483 m_log.ErrorFormat(
434 "[STARTUP]: Registration of region with grid failed, aborting startup due to {0} {1}", 484 "[STARTUP]: Registration of region with grid failed, aborting startup due to {0} {1}",
435 e.Message, e.StackTrace); 485 e.Message, e.StackTrace);
436 486
487 if (scene.SnmpService != null)
488 {
489 scene.SnmpService.Critical("Grid registration failed. Startup aborted.", scene);
490 }
437 // Carrying on now causes a lot of confusion down the 491 // Carrying on now causes a lot of confusion down the
438 // line - we need to get the user's attention 492 // line - we need to get the user's attention
439 Environment.Exit(1); 493 Environment.Exit(1);
440 } 494 }
441 495
496 if (scene.SnmpService != null)
497 {
498 scene.SnmpService.BootInfo("Grid Registration done", scene);
499 }
500
442 // We need to do this after we've initialized the 501 // We need to do this after we've initialized the
443 // scripting engines. 502 // scripting engines.
444 scene.CreateScriptInstances(); 503 scene.CreateScriptInstances();
445 504
505 if (scene.SnmpService != null)
506 {
507 scene.SnmpService.BootInfo("ScriptEngine started", scene);
508 }
509
446 SceneManager.Add(scene); 510 SceneManager.Add(scene);
447 511
448 //if (m_autoCreateClientStack) 512 //if (m_autoCreateClientStack)
@@ -454,10 +518,20 @@ namespace OpenSim
454 // } 518 // }
455 //} 519 //}
456 520
521 if (scene.SnmpService != null)
522 {
523 scene.SnmpService.BootInfo("Initializing region modules", scene);
524 }
457 scene.EventManager.OnShutdown += delegate() { ShutdownRegion(scene); }; 525 scene.EventManager.OnShutdown += delegate() { ShutdownRegion(scene); };
458 526
459 mscene = scene; 527 mscene = scene;
460 528
529 if (scene.SnmpService != null)
530 {
531 scene.SnmpService.BootInfo("The region is operational", scene);
532 scene.SnmpService.LinkUp(scene);
533 }
534
461 //return clientServers; 535 //return clientServers;
462 } 536 }
463 537
@@ -535,7 +609,7 @@ namespace OpenSim
535 609
536 if (rawEstateOwnerUuid == null) 610 if (rawEstateOwnerUuid == null)
537 rawEstateOwnerUuid = MainConsole.Instance.CmdPrompt("User ID", UUID.Random().ToString()); 611 rawEstateOwnerUuid = MainConsole.Instance.CmdPrompt("User ID", UUID.Random().ToString());
538 612
539 UUID estateOwnerUuid = UUID.Zero; 613 UUID estateOwnerUuid = UUID.Zero;
540 if (!UUID.TryParse(rawEstateOwnerUuid, out estateOwnerUuid)) 614 if (!UUID.TryParse(rawEstateOwnerUuid, out estateOwnerUuid))
541 { 615 {
@@ -573,6 +647,11 @@ namespace OpenSim
573 private void ShutdownRegion(Scene scene) 647 private void ShutdownRegion(Scene scene)
574 { 648 {
575 m_log.DebugFormat("[SHUTDOWN]: Shutting down region {0}", scene.RegionInfo.RegionName); 649 m_log.DebugFormat("[SHUTDOWN]: Shutting down region {0}", scene.RegionInfo.RegionName);
650 if (scene.SnmpService != null)
651 {
652 scene.SnmpService.BootInfo("The region is shutting down", scene);
653 scene.SnmpService.LinkDown(scene);
654 }
576 IRegionModulesController controller; 655 IRegionModulesController controller;
577 if (ApplicationRegistry.TryGet<IRegionModulesController>(out controller)) 656 if (ApplicationRegistry.TryGet<IRegionModulesController>(out controller))
578 { 657 {
@@ -593,7 +672,7 @@ namespace OpenSim
593 scene.DeleteAllSceneObjects(); 672 scene.DeleteAllSceneObjects();
594 SceneManager.CloseScene(scene); 673 SceneManager.CloseScene(scene);
595 //ShutdownClientServer(scene.RegionInfo); 674 //ShutdownClientServer(scene.RegionInfo);
596 675
597 if (!cleanup) 676 if (!cleanup)
598 return; 677 return;
599 678
@@ -655,7 +734,7 @@ namespace OpenSim
655 SceneManager.CloseScene(scene); 734 SceneManager.CloseScene(scene);
656 //ShutdownClientServer(scene.RegionInfo); 735 //ShutdownClientServer(scene.RegionInfo);
657 } 736 }
658 737
659 /// <summary> 738 /// <summary>
660 /// Remove a region from the simulator without deleting it permanently. 739 /// Remove a region from the simulator without deleting it permanently.
661 /// </summary> 740 /// </summary>
@@ -667,7 +746,7 @@ namespace OpenSim
667 if (SceneManager.TryGetScene(name, out target)) 746 if (SceneManager.TryGetScene(name, out target))
668 CloseRegion(target); 747 CloseRegion(target);
669 } 748 }
670 749
671 /// <summary> 750 /// <summary>
672 /// Create a scene and its initial base structures. 751 /// Create a scene and its initial base structures.
673 /// </summary> 752 /// </summary>
@@ -703,15 +782,15 @@ namespace OpenSim
703 IEstateDataService estateDataService, AgentCircuitManager circuitManager) 782 IEstateDataService estateDataService, AgentCircuitManager circuitManager)
704 { 783 {
705 return new Scene( 784 return new Scene(
706 regionInfo, circuitManager, 785 regionInfo, circuitManager,
707 simDataService, estateDataService, 786 simDataService, estateDataService,
708 Config, m_version); 787 Config, m_version);
709 } 788 }
710 789
711 protected virtual void HandleRestartRegion(RegionInfo whichRegion) 790 protected virtual void HandleRestartRegion(RegionInfo whichRegion)
712 { 791 {
713 m_log.InfoFormat( 792 m_log.InfoFormat(
714 "[OPENSIM]: Got restart signal from SceneManager for region {0} ({1},{2})", 793 "[OPENSIM]: Got restart signal from SceneManager for region {0} ({1},{2})",
715 whichRegion.RegionName, whichRegion.RegionLocX, whichRegion.RegionLocY); 794 whichRegion.RegionName, whichRegion.RegionLocX, whichRegion.RegionLocY);
716 795
717 //ShutdownClientServer(whichRegion); 796 //ShutdownClientServer(whichRegion);
@@ -746,18 +825,18 @@ namespace OpenSim
746 825
747 /// <summary> 826 /// <summary>
748 /// Handler to supply the current extended status of this sim 827 /// Handler to supply the current extended status of this sim
749 /// Sends the statistical data in a json serialization 828 /// Sends the statistical data in a json serialization
750 /// </summary> 829 /// </summary>
751 public class XSimStatusHandler : BaseStreamHandler 830 public class XSimStatusHandler : BaseStreamHandler
752 { 831 {
753 OpenSimBase m_opensim; 832 OpenSimBase m_opensim;
754 833
755 public XSimStatusHandler(OpenSimBase sim) 834 public XSimStatusHandler(OpenSimBase sim)
756 : base("GET", "/" + Util.SHA1Hash(sim.osSecret), "XSimStatus", "Simulator XStatus") 835 : base("GET", "/" + Util.SHA1Hash(sim.osSecret), "XSimStatus", "Simulator XStatus")
757 { 836 {
758 m_opensim = sim; 837 m_opensim = sim;
759 } 838 }
760 839
761 protected override byte[] ProcessRequest(string path, Stream request, 840 protected override byte[] ProcessRequest(string path, Stream request,
762 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 841 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
763 { 842 {
@@ -772,20 +851,20 @@ namespace OpenSim
772 851
773 /// <summary> 852 /// <summary>
774 /// Handler to supply the current extended status of this sim to a user configured URI 853 /// Handler to supply the current extended status of this sim to a user configured URI
775 /// Sends the statistical data in a json serialization 854 /// Sends the statistical data in a json serialization
776 /// If the request contains a key, "callback" the response will be wrappend in the 855 /// If the request contains a key, "callback" the response will be wrappend in the
777 /// associated value for jsonp used with ajax/javascript 856 /// associated value for jsonp used with ajax/javascript
778 /// </summary> 857 /// </summary>
779 protected class UXSimStatusHandler : BaseStreamHandler 858 protected class UXSimStatusHandler : BaseStreamHandler
780 { 859 {
781 OpenSimBase m_opensim; 860 OpenSimBase m_opensim;
782 861
783 public UXSimStatusHandler(OpenSimBase sim) 862 public UXSimStatusHandler(OpenSimBase sim)
784 : base("GET", "/" + sim.userStatsURI, "UXSimStatus", "Simulator UXStatus") 863 : base("GET", "/" + sim.userStatsURI, "UXSimStatus", "Simulator UXStatus")
785 { 864 {
786 m_opensim = sim; 865 m_opensim = sim;
787 } 866 }
788 867
789 protected override byte[] ProcessRequest(string path, Stream request, 868 protected override byte[] ProcessRequest(string path, Stream request,
790 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 869 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
791 { 870 {
@@ -798,6 +877,26 @@ namespace OpenSim
798 } 877 }
799 } 878 }
800 879
880 /// <summary>
881 /// handler to supply serving http://domainname:port/robots.txt
882 /// </summary>
883 public class SimRobotsHandler : BaseStreamHandler
884 {
885 public SimRobotsHandler() : base("GET", "/robots.txt", "SimRobots.txt", "Simulator Robots.txt") {}
886
887 protected override byte[] ProcessRequest(string path, Stream request,
888 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
889 {
890 string robots = "# go away\nUser-agent: *\nDisallow: /\n";
891 return Util.UTF8.GetBytes(robots);
892 }
893
894 public override string ContentType
895 {
896 get { return "text/plain"; }
897 }
898 }
899
801 #endregion 900 #endregion
802 901
803 /// <summary> 902 /// <summary>
@@ -858,7 +957,7 @@ namespace OpenSim
858 { 957 {
859 regionnum = SceneManager.Scenes.Count; 958 regionnum = SceneManager.Scenes.Count;
860 } 959 }
861 960
862 /// <summary> 961 /// <summary>
863 /// Create an estate with an initial region. 962 /// Create an estate with an initial region.
864 /// </summary> 963 /// </summary>
@@ -885,19 +984,19 @@ namespace OpenSim
885 MainConsole.Instance.OutputFormat("An estate named {0} already exists. Please try again.", newName); 984 MainConsole.Instance.OutputFormat("An estate named {0} already exists. Please try again.", newName);
886 return false; 985 return false;
887 } 986 }
888 987
889 regInfo.EstateSettings.EstateName = newName; 988 regInfo.EstateSettings.EstateName = newName;
890 989
891 // FIXME: Later on, the scene constructor will reload the estate settings no matter what. 990 // FIXME: Later on, the scene constructor will reload the estate settings no matter what.
892 // Therefore, we need to do an initial save here otherwise the new estate name will be reset 991 // Therefore, we need to do an initial save here otherwise the new estate name will be reset
893 // back to the default. The reloading of estate settings by scene could be eliminated if it 992 // back to the default. The reloading of estate settings by scene could be eliminated if it
894 // knows that the passed in settings in RegionInfo are already valid. Also, it might be 993 // knows that the passed in settings in RegionInfo are already valid. Also, it might be
895 // possible to eliminate some additional later saves made by callers of this method. 994 // possible to eliminate some additional later saves made by callers of this method.
896 EstateDataService.StoreEstateSettings(regInfo.EstateSettings); 995 EstateDataService.StoreEstateSettings(regInfo.EstateSettings);
897 996
898 return true; 997 return true;
899 } 998 }
900 999
901 /// <summary> 1000 /// <summary>
902 /// Load the estate information for the provided RegionInfo object. 1001 /// Load the estate information for the provided RegionInfo object.
903 /// </summary> 1002 /// </summary>
@@ -911,8 +1010,8 @@ namespace OpenSim
911 return false; // estate info in the database did not change 1010 return false; // estate info in the database did not change
912 1011
913 m_log.WarnFormat("[ESTATE] Region {0} is not part of an estate.", regInfo.RegionName); 1012 m_log.WarnFormat("[ESTATE] Region {0} is not part of an estate.", regInfo.RegionName);
914 1013
915 List<EstateSettings> estates = EstateDataService.LoadEstateSettingsAll(); 1014 List<EstateSettings> estates = EstateDataService.LoadEstateSettingsAll();
916 Dictionary<string, EstateSettings> estatesByName = new Dictionary<string, EstateSettings>(); 1015 Dictionary<string, EstateSettings> estatesByName = new Dictionary<string, EstateSettings>();
917 1016
918 foreach (EstateSettings estate in estates) 1017 foreach (EstateSettings estate in estates)
@@ -1005,12 +1104,12 @@ namespace OpenSim
1005 MainConsole.Instance.Output("Joining the estate failed. Please try again."); 1104 MainConsole.Instance.Output("Joining the estate failed. Please try again.");
1006 } 1105 }
1007 } 1106 }
1008 } 1107 }
1009 1108
1010 return true; // need to update the database 1109 return true; // need to update the database
1011 } 1110 }
1012 } 1111 }
1013 1112
1014 public class OpenSimConfigSource 1113 public class OpenSimConfigSource
1015 { 1114 {
1016 public IConfigSource Source; 1115 public IConfigSource Source;