2007-07-16 15:40:11 +00:00
|
|
|
/*
|
2008-03-18 05:16:43 +00:00
|
|
|
* Copyright (c) Contributors, http://opensimulator.org/
|
|
|
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* * Neither the name of the OpenSim Project nor the
|
|
|
|
* names of its contributors may be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
|
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
|
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
2007-07-16 15:40:11 +00:00
|
|
|
|
|
|
|
using System;
|
2007-09-11 14:20:09 +00:00
|
|
|
using System.Collections.Generic;
|
2007-07-16 15:40:11 +00:00
|
|
|
using System.IO;
|
2008-05-19 11:38:35 +00:00
|
|
|
using System.Net;
|
2008-04-21 07:09:17 +00:00
|
|
|
using System.Reflection;
|
2007-09-11 14:20:09 +00:00
|
|
|
using System.Text;
|
2007-12-27 21:41:48 +00:00
|
|
|
using System.Threading;
|
2008-09-06 07:52:41 +00:00
|
|
|
using OpenMetaverse;
|
2008-04-21 07:09:17 +00:00
|
|
|
using log4net;
|
2007-08-04 18:15:48 +00:00
|
|
|
using Nini.Config;
|
2007-10-30 09:05:31 +00:00
|
|
|
using OpenSim.Framework;
|
2008-08-16 20:42:43 +00:00
|
|
|
using OpenSim.Framework.Communications;
|
2007-09-24 05:15:13 +00:00
|
|
|
using OpenSim.Framework.Communications.Cache;
|
2008-07-12 19:29:49 +00:00
|
|
|
using OpenSim.Framework.Console;
|
2007-07-16 15:40:11 +00:00
|
|
|
using OpenSim.Framework.Servers;
|
2008-01-31 00:42:31 +00:00
|
|
|
using OpenSim.Framework.Statistics;
|
2007-07-16 15:40:11 +00:00
|
|
|
using OpenSim.Region.ClientStack;
|
|
|
|
using OpenSim.Region.Communications.Local;
|
|
|
|
using OpenSim.Region.Communications.OGS1;
|
|
|
|
using OpenSim.Region.Environment;
|
2009-02-06 16:55:34 +00:00
|
|
|
using OpenSim.Region.Framework;
|
|
|
|
using OpenSim.Region.Framework.Interfaces;
|
|
|
|
using OpenSim.Region.Framework.Scenes;
|
2007-09-11 14:20:09 +00:00
|
|
|
using OpenSim.Region.Physics.Manager;
|
2008-09-29 14:41:16 +00:00
|
|
|
|
2007-07-16 15:40:11 +00:00
|
|
|
namespace OpenSim
|
|
|
|
{
|
2008-06-01 01:01:16 +00:00
|
|
|
/// <summary>
|
2009-02-05 18:36:53 +00:00
|
|
|
/// Common OpenSim simulator code
|
2008-06-01 01:01:16 +00:00
|
|
|
/// </summary>
|
|
|
|
public class OpenSimBase : RegionApplicationBase
|
2008-05-16 01:22:11 +00:00
|
|
|
{
|
2008-04-21 07:09:17 +00:00
|
|
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
2008-02-05 19:44:27 +00:00
|
|
|
|
2008-04-28 14:41:46 +00:00
|
|
|
protected string proxyUrl;
|
2009-02-05 21:35:59 +00:00
|
|
|
protected int proxyOffset = 0;
|
2008-04-28 14:41:46 +00:00
|
|
|
|
2008-05-22 17:09:33 +00:00
|
|
|
/// <summary>
|
2008-07-29 14:28:08 +00:00
|
|
|
/// The file used to load and save prim backup xml if no filename has been specified
|
2008-05-22 17:09:33 +00:00
|
|
|
/// </summary>
|
2008-09-06 14:58:23 +00:00
|
|
|
protected const string DEFAULT_PRIM_BACKUP_FILENAME = "prim-backup.xml";
|
2008-05-25 23:27:38 +00:00
|
|
|
|
2008-05-22 17:09:33 +00:00
|
|
|
/// <summary>
|
2008-07-29 14:28:08 +00:00
|
|
|
/// The file used to load and save an opensim archive if no filename has been specified
|
2008-05-22 17:09:33 +00:00
|
|
|
/// </summary>
|
2008-07-12 18:54:21 +00:00
|
|
|
protected const string DEFAULT_OAR_BACKUP_FILENAME = "scene_oar.tar.gz";
|
2008-08-18 00:39:10 +00:00
|
|
|
|
2008-07-29 14:28:08 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The file to load and save inventory if no filename has been specified
|
|
|
|
/// </summary>
|
|
|
|
protected const string DEFAULT_INV_BACKUP_FILENAME = "opensim_inv.tar.gz";
|
2009-02-05 18:36:53 +00:00
|
|
|
|
2008-11-05 17:18:16 +00:00
|
|
|
public ConfigSettings ConfigurationSettings
|
|
|
|
{
|
|
|
|
get { return m_configSettings; }
|
|
|
|
set { m_configSettings = value; }
|
|
|
|
}
|
2009-02-05 18:36:53 +00:00
|
|
|
protected ConfigSettings m_configSettings;
|
2007-08-28 14:21:17 +00:00
|
|
|
|
2008-11-05 20:14:52 +00:00
|
|
|
protected ConfigurationLoader m_configLoader;
|
|
|
|
|
2009-02-05 19:34:23 +00:00
|
|
|
protected GridInfoService m_gridInfoService;
|
2007-07-16 15:40:11 +00:00
|
|
|
|
2007-08-11 11:59:51 +00:00
|
|
|
public ConsoleCommand CreateAccount = null;
|
2008-11-05 20:14:52 +00:00
|
|
|
|
2008-04-28 14:41:46 +00:00
|
|
|
protected List<IApplicationPlugin> m_plugins = new List<IApplicationPlugin>();
|
2007-11-04 22:16:13 +00:00
|
|
|
|
2008-11-03 18:36:04 +00:00
|
|
|
/// <value>
|
|
|
|
/// The config information passed into the OpenSim region server.
|
|
|
|
/// </value>
|
2008-06-26 17:20:08 +00:00
|
|
|
public OpenSimConfigSource ConfigSource
|
2007-11-04 22:16:13 +00:00
|
|
|
{
|
|
|
|
get { return m_config; }
|
|
|
|
set { m_config = value; }
|
|
|
|
}
|
2008-11-03 18:36:04 +00:00
|
|
|
protected OpenSimConfigSource m_config;
|
2008-05-16 01:22:11 +00:00
|
|
|
|
2008-05-02 18:26:19 +00:00
|
|
|
public List<IClientNetworkServer> ClientServers
|
2008-03-04 05:31:54 +00:00
|
|
|
{
|
2008-05-02 16:41:08 +00:00
|
|
|
get { return m_clientServers; }
|
2009-02-05 18:47:39 +00:00
|
|
|
}
|
2009-02-05 19:34:23 +00:00
|
|
|
protected List<IClientNetworkServer> m_clientServers = new List<IClientNetworkServer>();
|
2008-05-16 01:22:11 +00:00
|
|
|
|
2008-05-14 19:13:54 +00:00
|
|
|
public new BaseHttpServer HttpServer
|
|
|
|
{
|
|
|
|
get { return m_httpServer; }
|
|
|
|
}
|
2008-05-16 01:22:11 +00:00
|
|
|
|
2008-06-28 14:46:20 +00:00
|
|
|
public uint HttpServerPort
|
2008-05-14 19:13:54 +00:00
|
|
|
{
|
|
|
|
get { return m_httpServerPort; }
|
2009-02-05 18:36:53 +00:00
|
|
|
}
|
2007-11-04 22:16:13 +00:00
|
|
|
|
|
|
|
public ModuleLoader ModuleLoader
|
|
|
|
{
|
|
|
|
get { return m_moduleLoader; }
|
|
|
|
set { m_moduleLoader = value; }
|
|
|
|
}
|
2009-02-05 18:36:53 +00:00
|
|
|
protected ModuleLoader m_moduleLoader;
|
2007-11-04 22:16:13 +00:00
|
|
|
|
2008-10-04 20:27:55 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Constructor.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="configSource"></param>
|
2008-10-03 19:42:35 +00:00
|
|
|
public OpenSimBase(IConfigSource configSource) : base()
|
2008-11-10 15:17:50 +00:00
|
|
|
{
|
|
|
|
LoadConfigSettings(configSource);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected virtual void LoadConfigSettings(IConfigSource configSource)
|
2008-11-05 17:18:16 +00:00
|
|
|
{
|
2008-11-05 20:14:52 +00:00
|
|
|
m_configLoader = new ConfigurationLoader();
|
|
|
|
m_config = m_configLoader.LoadConfigSettings(configSource, out m_configSettings, out m_networkServersInfo);
|
|
|
|
ReadExtraConfigSettings();
|
2008-11-05 17:18:16 +00:00
|
|
|
}
|
|
|
|
|
2008-11-05 20:14:52 +00:00
|
|
|
protected virtual void ReadExtraConfigSettings()
|
2007-07-16 15:40:11 +00:00
|
|
|
{
|
2008-11-06 20:17:20 +00:00
|
|
|
IConfig networkConfig = m_config.Source.Configs["Network"];
|
|
|
|
if (networkConfig != null)
|
|
|
|
{
|
|
|
|
proxyUrl = networkConfig.GetString("proxy_url", "");
|
|
|
|
proxyOffset = Int32.Parse(networkConfig.GetString("proxy_offset", "0"));
|
|
|
|
}
|
2008-04-28 14:41:46 +00:00
|
|
|
}
|
2008-05-16 01:22:11 +00:00
|
|
|
|
2008-11-06 20:17:20 +00:00
|
|
|
protected virtual void LoadPlugins()
|
2008-06-27 02:15:57 +00:00
|
|
|
{
|
2008-08-18 00:39:10 +00:00
|
|
|
PluginLoader<IApplicationPlugin> loader =
|
2008-10-03 19:42:35 +00:00
|
|
|
new PluginLoader<IApplicationPlugin>(new ApplicationPluginInitialiser(this));
|
2008-07-04 03:11:53 +00:00
|
|
|
|
2008-10-03 19:42:35 +00:00
|
|
|
loader.Load("/OpenSim/Startup");
|
2008-06-27 02:15:57 +00:00
|
|
|
m_plugins = loader.Plugins;
|
|
|
|
}
|
2009-02-05 21:35:59 +00:00
|
|
|
|
|
|
|
protected override List<string> GetHelpTopics()
|
|
|
|
{
|
|
|
|
List<string> topics = base.GetHelpTopics();
|
|
|
|
topics.AddRange(SceneManager.CurrentOrFirstScene.GetCommanders().Keys);
|
|
|
|
|
|
|
|
return topics;
|
|
|
|
}
|
|
|
|
|
2008-04-28 14:41:46 +00:00
|
|
|
/// <summary>
|
2008-10-03 19:42:35 +00:00
|
|
|
/// Performs startup specific to this region server, including initialization of the scene
|
|
|
|
/// such as loading configuration from disk.
|
2008-04-28 14:41:46 +00:00
|
|
|
/// </summary>
|
2008-10-03 15:11:29 +00:00
|
|
|
protected override void StartupSpecific()
|
2008-04-28 14:41:46 +00:00
|
|
|
{
|
2008-10-03 15:11:29 +00:00
|
|
|
base.StartupSpecific();
|
|
|
|
|
2008-06-01 01:22:19 +00:00
|
|
|
m_stats = StatsManager.StartCollectingSimExtraStats();
|
2008-09-19 17:41:21 +00:00
|
|
|
|
2008-12-29 16:56:48 +00:00
|
|
|
LibraryRootFolder libraryRootFolder = new LibraryRootFolder(m_configSettings.LibrariesXMLFile);
|
2007-07-16 15:40:11 +00:00
|
|
|
|
2008-11-05 17:45:56 +00:00
|
|
|
// StandAlone mode? is determined by !startupConfig.GetBoolean("gridmode", false)
|
|
|
|
if (m_configSettings.Standalone)
|
2007-08-06 16:33:54 +00:00
|
|
|
{
|
2008-11-05 17:45:56 +00:00
|
|
|
InitialiseStandaloneServices(libraryRootFolder);
|
2007-08-06 16:33:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-01-05 16:38:37 +00:00
|
|
|
// We are in grid mode
|
2008-11-06 19:21:50 +00:00
|
|
|
InitialiseGridServices(libraryRootFolder);
|
2007-08-06 16:33:54 +00:00
|
|
|
}
|
|
|
|
|
2008-01-05 16:38:37 +00:00
|
|
|
// Create a ModuleLoader instance
|
2008-06-26 17:23:05 +00:00
|
|
|
m_moduleLoader = new ModuleLoader(m_config.Source);
|
2007-11-04 22:16:13 +00:00
|
|
|
|
2008-06-27 02:15:57 +00:00
|
|
|
LoadPlugins();
|
2008-09-19 17:41:21 +00:00
|
|
|
|
2008-09-19 20:02:19 +00:00
|
|
|
// Only enable logins to the regions once we have completely finished starting up (apart from scripts)
|
2008-09-19 17:41:21 +00:00
|
|
|
m_commsManager.GridService.RegionLoginsEnabled = true;
|
2009-02-07 12:25:39 +00:00
|
|
|
|
|
|
|
List<string> topics = GetHelpTopics();
|
|
|
|
|
|
|
|
foreach (string topic in topics)
|
|
|
|
{
|
2009-02-09 20:52:04 +00:00
|
|
|
m_console.Commands.AddCommand("plugin", "help " + topic,
|
|
|
|
"help " + topic,
|
|
|
|
"Get help on plugin command '" + topic + "'",
|
2009-02-07 12:25:39 +00:00
|
|
|
HandleCommanderHelp);
|
|
|
|
|
|
|
|
m_console.Commands.AddCommand("plugin", topic,
|
|
|
|
topic,
|
2009-02-09 20:52:04 +00:00
|
|
|
"Execute subcommand for plugin '" + topic + "'",
|
2009-02-07 12:25:39 +00:00
|
|
|
null);
|
|
|
|
|
|
|
|
ICommander commander =
|
|
|
|
SceneManager.CurrentOrFirstScene.GetCommanders()[topic];
|
|
|
|
|
|
|
|
if (commander == null)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
foreach (string command in commander.Commands.Keys)
|
|
|
|
{
|
2009-02-09 20:52:04 +00:00
|
|
|
m_console.Commands.AddCommand(topic, topic + " " + command,
|
|
|
|
topic + " " + commander.Commands[command].ShortHelp(),
|
2009-02-07 12:25:39 +00:00
|
|
|
String.Empty, HandleCommanderCommand);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void HandleCommanderCommand(string module, string[] cmd)
|
|
|
|
{
|
|
|
|
m_sceneManager.SendCommandToPluginModules(cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void HandleCommanderHelp(string module, string[] cmd)
|
|
|
|
{
|
|
|
|
ICommander moduleCommander = SceneManager.CurrentOrFirstScene.GetCommander(cmd[1]);
|
|
|
|
if (moduleCommander != null)
|
|
|
|
m_console.Notice(moduleCommander.Help);
|
2007-08-24 16:17:57 +00:00
|
|
|
}
|
|
|
|
|
2008-11-05 17:45:56 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Initialises the backend services for standalone mode, and registers some http handlers
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="libraryRootFolder"></param>
|
2008-11-06 19:21:50 +00:00
|
|
|
protected virtual void InitialiseStandaloneServices(LibraryRootFolder libraryRootFolder)
|
2008-11-05 17:45:56 +00:00
|
|
|
{
|
|
|
|
LocalInventoryService inventoryService = new LocalInventoryService();
|
|
|
|
inventoryService.AddPlugin(m_configSettings.StandaloneInventoryPlugin, m_configSettings.StandaloneInventorySource);
|
|
|
|
|
|
|
|
LocalUserServices userService =
|
2008-11-28 15:40:44 +00:00
|
|
|
new LocalUserServices(
|
|
|
|
m_networkServersInfo.DefaultHomeLocX, m_networkServersInfo.DefaultHomeLocY, inventoryService);
|
2008-11-05 17:45:56 +00:00
|
|
|
userService.AddPlugin(m_configSettings.StandaloneUserPlugin, m_configSettings.StandaloneUserSource);
|
|
|
|
|
|
|
|
LocalBackEndServices backendService = new LocalBackEndServices();
|
|
|
|
|
|
|
|
LocalLoginService loginService =
|
|
|
|
new LocalLoginService(
|
|
|
|
userService, m_configSettings.StandaloneWelcomeMessage, inventoryService, backendService, m_networkServersInfo,
|
|
|
|
m_configSettings.StandaloneAuthenticate, libraryRootFolder);
|
|
|
|
|
|
|
|
m_commsManager
|
|
|
|
= new CommunicationsLocal(
|
|
|
|
m_networkServersInfo, m_httpServer, m_assetCache, userService, userService,
|
|
|
|
inventoryService, backendService, backendService, userService,
|
2008-11-05 20:14:52 +00:00
|
|
|
libraryRootFolder, m_configSettings.DumpAssetsToFile);
|
2008-11-05 17:45:56 +00:00
|
|
|
|
|
|
|
// set up XMLRPC handler for client's initial login request message
|
|
|
|
m_httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod);
|
|
|
|
|
|
|
|
// provides the web form login
|
|
|
|
m_httpServer.AddHTTPHandler("login", loginService.ProcessHTMLLogin);
|
|
|
|
|
|
|
|
// Provides the LLSD login
|
|
|
|
m_httpServer.SetDefaultLLSDHandler(loginService.LLSDLoginMethod);
|
|
|
|
|
|
|
|
// provide grid info
|
|
|
|
// m_gridInfoService = new GridInfoService(m_config.Source.Configs["Startup"].GetString("inifile", Path.Combine(Util.configDir(), "OpenSim.ini")));
|
|
|
|
m_gridInfoService = new GridInfoService(m_config.Source);
|
|
|
|
m_httpServer.AddXmlRPCHandler("get_grid_info", m_gridInfoService.XmlRpcGridInfoMethod);
|
|
|
|
m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info", m_gridInfoService.RestGetGridInfoMethod));
|
|
|
|
}
|
|
|
|
|
2008-11-06 19:21:50 +00:00
|
|
|
protected virtual void InitialiseGridServices(LibraryRootFolder libraryRootFolder)
|
|
|
|
{
|
|
|
|
m_commsManager
|
|
|
|
= new CommunicationsOGS1(m_networkServersInfo, m_httpServer, m_assetCache, libraryRootFolder);
|
|
|
|
|
|
|
|
m_httpServer.AddStreamHandler(new SimStatusHandler());
|
|
|
|
}
|
|
|
|
|
2008-01-05 16:38:37 +00:00
|
|
|
protected override void Initialize()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// Called from base.StartUp()
|
|
|
|
//
|
|
|
|
|
|
|
|
m_httpServerPort = m_networkServersInfo.HttpListenerPort;
|
|
|
|
|
2008-11-05 17:45:56 +00:00
|
|
|
InitialiseAssetCache();
|
|
|
|
|
|
|
|
m_sceneManager.OnRestartSim += handleRestartRegion;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Initialises the assetcache
|
|
|
|
/// </summary>
|
2008-11-06 20:17:20 +00:00
|
|
|
protected virtual void InitialiseAssetCache()
|
2008-11-05 17:45:56 +00:00
|
|
|
{
|
2009-02-09 21:47:55 +00:00
|
|
|
|
|
|
|
IAssetServer assetServer = null;
|
|
|
|
string mode = m_configSettings.AssetStorage;
|
|
|
|
|
|
|
|
if (m_configSettings.Standalone == false &&
|
|
|
|
m_configSettings.AssetStorage == "default")
|
|
|
|
mode = "grid";
|
|
|
|
|
|
|
|
switch (mode)
|
2008-10-14 08:54:46 +00:00
|
|
|
{
|
2009-02-09 21:47:55 +00:00
|
|
|
case "grid" :
|
|
|
|
assetServer = new GridAssetClient(m_networkServersInfo.AssetURL);
|
|
|
|
break;
|
|
|
|
case "cryptogrid" :
|
|
|
|
assetServer = new CryptoGridAssetClient(m_networkServersInfo.AssetURL,
|
2008-10-14 08:54:46 +00:00
|
|
|
Environment.CurrentDirectory, true);
|
2009-02-09 21:47:55 +00:00
|
|
|
break;
|
|
|
|
case "cryptogrid_eou" :
|
|
|
|
assetServer = new CryptoGridAssetClient(m_networkServersInfo.AssetURL,
|
2008-10-14 08:54:46 +00:00
|
|
|
Environment.CurrentDirectory, false);
|
2009-02-09 21:47:55 +00:00
|
|
|
break;
|
|
|
|
case "file" :
|
|
|
|
assetServer = new FileAssetClient(m_networkServersInfo.AssetURL);
|
|
|
|
break;
|
|
|
|
default :
|
|
|
|
if (!ResolveAssetServer(out assetServer))
|
|
|
|
{
|
|
|
|
SQLAssetServer sqlAssetServer = new SQLAssetServer(m_configSettings.StandaloneAssetPlugin, m_configSettings.StandaloneAssetSource);
|
|
|
|
sqlAssetServer.LoadDefaultAssets(m_configSettings.AssetSetsXMLFile);
|
|
|
|
assetServer = sqlAssetServer;
|
|
|
|
}
|
|
|
|
break;
|
2008-10-14 08:54:46 +00:00
|
|
|
}
|
2008-01-05 16:38:37 +00:00
|
|
|
|
2009-02-09 21:47:55 +00:00
|
|
|
m_assetCache = ResolveAssetCache(assetServer);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private bool ResolveAssetServer(out IAssetServer assetServer)
|
|
|
|
{
|
|
|
|
assetServer = null;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private IAssetCache ResolveAssetCache(IAssetServer assetServer)
|
|
|
|
{
|
|
|
|
return new AssetCache(assetServer);
|
2008-01-05 16:38:37 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 09:53:49 +00:00
|
|
|
public void ProcessLogin(bool LoginEnabled)
|
|
|
|
{
|
|
|
|
if (LoginEnabled)
|
|
|
|
{
|
|
|
|
m_log.Info("[Login] Login are now enabled ");
|
|
|
|
m_commsManager.GridService.RegionLoginsEnabled = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_log.Info("[Login] Login are now disabled ");
|
|
|
|
m_commsManager.GridService.RegionLoginsEnabled = false;
|
2008-11-28 15:34:30 +00:00
|
|
|
}
|
2008-11-24 09:53:49 +00:00
|
|
|
}
|
|
|
|
|
2008-03-24 20:22:58 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Execute the region creation process. This includes setting up scene infrastructure.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="regionInfo"></param>
|
|
|
|
/// <param name="portadd_flag"></param>
|
|
|
|
/// <returns></returns>
|
2008-05-02 18:18:43 +00:00
|
|
|
public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag)
|
2008-05-02 03:40:38 +00:00
|
|
|
{
|
2008-04-21 12:42:56 +00:00
|
|
|
return CreateRegion(regionInfo, portadd_flag, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Execute the region creation process. This includes setting up scene infrastructure.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="regionInfo"></param>
|
|
|
|
/// <returns></returns>
|
2008-05-02 18:18:43 +00:00
|
|
|
public IClientNetworkServer CreateRegion(RegionInfo regionInfo)
|
2008-05-02 03:40:38 +00:00
|
|
|
{
|
2008-04-21 12:42:56 +00:00
|
|
|
return CreateRegion(regionInfo, false, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Execute the region creation process. This includes setting up scene infrastructure.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="regionInfo"></param>
|
|
|
|
/// <param name="portadd_flag"></param>
|
|
|
|
/// <param name="do_post_init"></param>
|
|
|
|
/// <returns></returns>
|
2008-05-02 18:18:43 +00:00
|
|
|
public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag, bool do_post_init)
|
2007-10-23 12:44:12 +00:00
|
|
|
{
|
2008-03-04 05:31:54 +00:00
|
|
|
int port = regionInfo.InternalEndPoint.Port;
|
|
|
|
|
2008-09-02 12:07:23 +00:00
|
|
|
// set initial originRegionID to RegionID in RegionInfo. (it needs for loding prims)
|
2008-03-07 08:10:52 +00:00
|
|
|
regionInfo.originRegionID = regionInfo.RegionID;
|
2008-03-04 05:31:54 +00:00
|
|
|
|
2008-03-07 08:10:52 +00:00
|
|
|
// set initial ServerURI
|
2008-10-03 19:42:35 +00:00
|
|
|
regionInfo.ServerURI = "http://" + regionInfo.ExternalHostName + ":" + regionInfo.InternalEndPoint.Port;
|
2008-05-16 01:22:11 +00:00
|
|
|
regionInfo.HttpPort = m_httpServerPort;
|
|
|
|
|
|
|
|
if ((proxyUrl.Length > 0) && (portadd_flag))
|
2008-03-07 08:10:52 +00:00
|
|
|
{
|
|
|
|
// set proxy url to RegionInfo
|
|
|
|
regionInfo.proxyUrl = proxyUrl;
|
2008-03-24 01:37:00 +00:00
|
|
|
Util.XmlRpcCommand(proxyUrl, "AddPort", port, port + proxyOffset, regionInfo.ExternalHostName);
|
2008-03-04 05:31:54 +00:00
|
|
|
}
|
2008-03-07 08:10:52 +00:00
|
|
|
|
2008-05-02 18:26:19 +00:00
|
|
|
IClientNetworkServer clientServer;
|
2008-11-03 18:33:35 +00:00
|
|
|
Scene scene = SetupScene(regionInfo, proxyOffset, m_config.Source, out clientServer);
|
2007-10-23 12:44:12 +00:00
|
|
|
|
2008-02-05 19:44:27 +00:00
|
|
|
m_log.Info("[MODULES]: Loading Region's modules");
|
2007-10-23 12:44:12 +00:00
|
|
|
|
2008-04-21 12:42:56 +00:00
|
|
|
List<IRegionModule> modules = m_moduleLoader.PickupModules(scene, ".");
|
2008-10-03 19:42:35 +00:00
|
|
|
|
2008-04-24 12:27:24 +00:00
|
|
|
// This needs to be ahead of the script engine load, so the
|
|
|
|
// script module can pick up events exposed by a module
|
2008-04-23 22:44:59 +00:00
|
|
|
m_moduleLoader.InitialiseSharedModules(scene);
|
|
|
|
|
2007-10-23 12:44:12 +00:00
|
|
|
scene.SetModuleInterfaces();
|
2008-09-11 13:56:25 +00:00
|
|
|
|
|
|
|
// Prims have to be loaded after module configuration since some modules may be invoked during the load
|
|
|
|
scene.LoadPrimsFromStorage(regionInfo.originRegionID);
|
|
|
|
|
|
|
|
scene.StartTimer();
|
2007-10-23 12:44:12 +00:00
|
|
|
|
2008-10-03 19:42:35 +00:00
|
|
|
// moved these here as the terrain texture has to be created after the modules are initialized
|
2008-05-16 01:22:11 +00:00
|
|
|
// and has to happen before the region is registered with the grid.
|
2008-06-14 02:39:27 +00:00
|
|
|
scene.CreateTerrainTexture(false);
|
2008-05-16 01:22:11 +00:00
|
|
|
|
2008-09-06 08:10:40 +00:00
|
|
|
try
|
|
|
|
{
|
2008-05-12 16:57:56 +00:00
|
|
|
scene.RegisterRegionWithGrid();
|
2008-09-06 08:10:40 +00:00
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
m_log.ErrorFormat("[STARTUP]: Registration of region with grid failed, aborting startup - {0}", e);
|
2008-05-16 01:22:11 +00:00
|
|
|
|
2008-09-02 12:07:23 +00:00
|
|
|
// Carrying on now causes a lot of confusion down the
|
|
|
|
// line - we need to get the user's attention
|
2008-09-06 08:10:40 +00:00
|
|
|
System.Environment.Exit(1);
|
|
|
|
}
|
2008-05-16 01:22:11 +00:00
|
|
|
|
2008-09-02 12:07:23 +00:00
|
|
|
// We need to do this after we've initialized the
|
|
|
|
// scripting engines.
|
2008-06-28 16:08:12 +00:00
|
|
|
scene.CreateScriptInstances();
|
2008-03-22 23:10:22 +00:00
|
|
|
|
|
|
|
scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID);
|
2008-05-23 15:12:15 +00:00
|
|
|
scene.EventManager.TriggerParcelPrimCountUpdate();
|
2007-10-23 12:44:12 +00:00
|
|
|
|
2008-05-16 01:22:11 +00:00
|
|
|
m_sceneManager.Add(scene);
|
2007-10-23 12:44:12 +00:00
|
|
|
|
2008-05-02 18:26:19 +00:00
|
|
|
m_clientServers.Add(clientServer);
|
|
|
|
clientServer.Start();
|
2007-10-23 12:44:12 +00:00
|
|
|
|
2008-04-21 12:42:56 +00:00
|
|
|
if (do_post_init)
|
|
|
|
{
|
|
|
|
foreach (IRegionModule module in modules)
|
|
|
|
{
|
|
|
|
module.PostInitialise();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-02 18:26:19 +00:00
|
|
|
return clientServer;
|
2007-10-23 12:44:12 +00:00
|
|
|
}
|
|
|
|
|
2008-09-18 15:44:05 +00:00
|
|
|
public void RemoveRegion(Scene scene, bool cleanup)
|
|
|
|
{
|
|
|
|
// only need to check this if we are not at the
|
|
|
|
// root level
|
|
|
|
if ((m_sceneManager.CurrentScene != null) &&
|
|
|
|
(m_sceneManager.CurrentScene.RegionInfo.RegionID == scene.RegionInfo.RegionID))
|
|
|
|
{
|
|
|
|
m_sceneManager.TrySetCurrentScene("..");
|
|
|
|
}
|
|
|
|
|
|
|
|
scene.DeleteAllSceneObjects();
|
|
|
|
m_sceneManager.CloseScene(scene);
|
|
|
|
|
|
|
|
if (!cleanup)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(scene.RegionInfo.RegionFile))
|
|
|
|
{
|
|
|
|
File.Delete(scene.RegionInfo.RegionFile);
|
2009-02-05 18:36:53 +00:00
|
|
|
m_log.InfoFormat("[OPENSIM]: deleting region file \"{0}\"", scene.RegionInfo.RegionFile);
|
2008-09-18 15:44:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void RemoveRegion(string name, bool cleanUp)
|
|
|
|
{
|
|
|
|
Scene target;
|
|
|
|
if (m_sceneManager.TryGetScene(name, out target))
|
|
|
|
RemoveRegion(target, cleanUp);
|
2008-11-05 18:00:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override StorageManager CreateStorageManager()
|
|
|
|
{
|
|
|
|
return CreateStorageManager(m_configSettings.StorageConnectionString, m_configSettings.EstateConnectionString);
|
|
|
|
}
|
2008-09-18 15:44:05 +00:00
|
|
|
|
2008-11-05 18:00:45 +00:00
|
|
|
protected StorageManager CreateStorageManager(string connectionstring, string estateconnectionstring)
|
2007-07-16 21:53:39 +00:00
|
|
|
{
|
2008-11-05 17:18:16 +00:00
|
|
|
return new StorageManager(m_configSettings.StorageDll, connectionstring, estateconnectionstring);
|
2007-07-16 21:53:39 +00:00
|
|
|
}
|
|
|
|
|
2008-06-20 01:35:54 +00:00
|
|
|
protected override ClientStackManager CreateClientStackManager()
|
|
|
|
{
|
2008-11-05 17:18:16 +00:00
|
|
|
return new ClientStackManager(m_configSettings.ClientstackDll);
|
2008-06-20 01:35:54 +00:00
|
|
|
}
|
|
|
|
|
2007-10-30 09:05:31 +00:00
|
|
|
protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager,
|
|
|
|
AgentCircuitManager circuitManager)
|
2007-07-16 23:25:35 +00:00
|
|
|
{
|
2007-11-03 19:14:22 +00:00
|
|
|
SceneCommunicationService sceneGridService = new SceneCommunicationService(m_commsManager);
|
2009-01-06 15:09:52 +00:00
|
|
|
|
|
|
|
return new Scene(
|
|
|
|
regionInfo, circuitManager, m_commsManager, sceneGridService, m_assetCache,
|
|
|
|
storageManager, m_moduleLoader, m_configSettings.DumpAssetsToFile, m_configSettings.PhysicalPrim,
|
|
|
|
m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version);
|
2007-07-16 23:25:35 +00:00
|
|
|
}
|
2007-08-04 18:15:48 +00:00
|
|
|
|
2007-12-27 21:41:48 +00:00
|
|
|
public void handleRestartRegion(RegionInfo whichRegion)
|
2007-11-25 04:52:14 +00:00
|
|
|
{
|
2009-02-05 18:36:53 +00:00
|
|
|
m_log.Info("[OPENSIM]: Got restart signal from SceneManager");
|
2008-08-18 00:39:10 +00:00
|
|
|
|
2008-05-02 18:26:19 +00:00
|
|
|
// Shutting down the client server
|
|
|
|
bool foundClientServer = false;
|
|
|
|
int clientServerElement = 0;
|
2007-12-27 21:41:48 +00:00
|
|
|
|
2008-05-02 16:41:08 +00:00
|
|
|
for (int i = 0; i < m_clientServers.Count; i++)
|
2007-11-25 04:52:14 +00:00
|
|
|
{
|
2008-05-02 16:41:08 +00:00
|
|
|
if (m_clientServers[i].HandlesRegion(new Location(whichRegion.RegionHandle)))
|
2007-11-25 04:52:14 +00:00
|
|
|
{
|
2008-05-02 18:26:19 +00:00
|
|
|
clientServerElement = i;
|
|
|
|
foundClientServer = true;
|
2007-11-25 04:52:14 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-02-05 18:36:53 +00:00
|
|
|
|
2008-05-02 18:26:19 +00:00
|
|
|
if (foundClientServer)
|
2007-11-25 04:52:14 +00:00
|
|
|
{
|
2008-05-02 18:26:19 +00:00
|
|
|
m_clientServers[clientServerElement].Server.Close();
|
|
|
|
m_clientServers.RemoveAt(clientServerElement);
|
2007-11-25 04:52:14 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 05:31:54 +00:00
|
|
|
CreateRegion(whichRegion, true);
|
2007-07-16 21:53:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# region Setup methods
|
|
|
|
|
2008-12-15 18:39:54 +00:00
|
|
|
protected override PhysicsScene GetPhysicsScene(string osSceneIdentifier)
|
2007-07-16 18:37:31 +00:00
|
|
|
{
|
2008-12-15 18:39:54 +00:00
|
|
|
return GetPhysicsScene(
|
|
|
|
m_configSettings.PhysicsEngine, m_configSettings.MeshEngineName, m_config.Source, osSceneIdentifier);
|
2007-07-16 18:37:31 +00:00
|
|
|
}
|
|
|
|
|
2008-05-12 16:16:50 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Handler to supply the current status of this sim
|
|
|
|
/// </summary>
|
2008-12-15 18:39:54 +00:00
|
|
|
/// Currently this is always OK if the simulator is still listening for connections on its HTTP service
|
2008-04-28 14:41:46 +00:00
|
|
|
protected class SimStatusHandler : IStreamedRequestHandler
|
2007-07-16 15:40:11 +00:00
|
|
|
{
|
2008-05-25 23:27:38 +00:00
|
|
|
public byte[] Handle(string path, Stream request,
|
2008-05-19 11:38:35 +00:00
|
|
|
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
|
2007-07-16 15:40:11 +00:00
|
|
|
{
|
|
|
|
return Encoding.UTF8.GetBytes("OK");
|
|
|
|
}
|
|
|
|
|
|
|
|
public string ContentType
|
|
|
|
{
|
|
|
|
get { return "text/plain"; }
|
|
|
|
}
|
|
|
|
|
|
|
|
public string HttpMethod
|
|
|
|
{
|
|
|
|
get { return "GET"; }
|
|
|
|
}
|
2007-08-04 18:15:48 +00:00
|
|
|
|
2007-07-16 15:40:11 +00:00
|
|
|
public string Path
|
|
|
|
{
|
|
|
|
get { return "/simstatus/"; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
2008-08-18 00:39:10 +00:00
|
|
|
|
2007-07-16 15:40:11 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Performs any last-minute sanity checking and shuts down the region server
|
|
|
|
/// </summary>
|
2008-12-02 11:40:22 +00:00
|
|
|
public override void ShutdownSpecific()
|
2007-07-16 15:40:11 +00:00
|
|
|
{
|
2008-05-16 01:22:11 +00:00
|
|
|
if (proxyUrl.Length > 0)
|
2008-03-24 03:03:21 +00:00
|
|
|
{
|
2008-05-16 01:22:11 +00:00
|
|
|
Util.XmlRpcCommand(proxyUrl, "Stop");
|
2008-03-24 03:03:21 +00:00
|
|
|
}
|
2008-03-18 15:30:38 +00:00
|
|
|
|
2008-02-05 19:44:27 +00:00
|
|
|
m_log.Info("[SHUTDOWN]: Closing all threads");
|
|
|
|
m_log.Info("[SHUTDOWN]: Killing listener thread");
|
|
|
|
m_log.Info("[SHUTDOWN]: Killing clients");
|
2007-12-06 18:17:44 +00:00
|
|
|
// TODO: implement this
|
2008-02-05 19:44:27 +00:00
|
|
|
m_log.Info("[SHUTDOWN]: Closing console and terminating");
|
2007-09-17 06:57:17 +00:00
|
|
|
|
2008-09-29 15:40:16 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
m_sceneManager.Close();
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
m_log.ErrorFormat("[SHUTDOWN]: Ignoring failure during shutdown - {0}", e);
|
|
|
|
}
|
2007-09-04 16:39:44 +00:00
|
|
|
}
|
2007-10-30 09:05:31 +00:00
|
|
|
|
2008-03-04 05:31:54 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Get the start time and up time of Region server
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="starttime">The first out parameter describing when the Region server started</param>
|
|
|
|
/// <param name="uptime">The second out parameter describing how long the Region server has run</param>
|
|
|
|
public void GetRunTime(out string starttime, out string uptime)
|
2008-03-18 15:30:38 +00:00
|
|
|
{
|
|
|
|
starttime = m_startuptime.ToString();
|
|
|
|
uptime = (DateTime.Now - m_startuptime).ToString();
|
|
|
|
}
|
2008-03-04 05:31:54 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Get the number of the avatars in the Region server
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="usernum">The first out parameter describing the number of all the avatars in the Region server</param>
|
|
|
|
public void GetAvatarNumber(out int usernum)
|
2008-03-18 15:30:38 +00:00
|
|
|
{
|
|
|
|
usernum = m_sceneManager.GetCurrentSceneAvatars().Count;
|
|
|
|
}
|
2008-03-04 05:31:54 +00:00
|
|
|
|
|
|
|
/// <summary>
|
2008-05-02 03:40:38 +00:00
|
|
|
/// Get the number of regions
|
2008-03-04 05:31:54 +00:00
|
|
|
/// </summary>
|
2008-05-02 03:40:38 +00:00
|
|
|
/// <param name="regionnum">The first out parameter describing the number of regions</param>
|
2008-03-04 05:31:54 +00:00
|
|
|
public void GetRegionNumber(out int regionnum)
|
2008-03-18 15:30:38 +00:00
|
|
|
{
|
2008-05-14 06:09:39 +00:00
|
|
|
regionnum = m_sceneManager.Scenes.Count;
|
2008-03-18 15:30:38 +00:00
|
|
|
}
|
2007-07-16 15:40:11 +00:00
|
|
|
}
|
2008-06-26 17:20:08 +00:00
|
|
|
|
|
|
|
public class OpenSimConfigSource
|
|
|
|
{
|
2008-06-26 17:23:05 +00:00
|
|
|
public IConfigSource Source;
|
2008-06-26 17:20:08 +00:00
|
|
|
|
|
|
|
public void Save(string path)
|
|
|
|
{
|
2008-06-26 17:23:05 +00:00
|
|
|
if (Source is IniConfigSource)
|
2008-06-26 17:20:08 +00:00
|
|
|
{
|
2008-06-26 17:23:05 +00:00
|
|
|
IniConfigSource iniCon = (IniConfigSource)Source;
|
2008-06-26 17:20:08 +00:00
|
|
|
iniCon.Save(path);
|
|
|
|
}
|
2008-06-26 17:23:05 +00:00
|
|
|
else if (Source is XmlConfigSource)
|
2008-06-26 17:20:08 +00:00
|
|
|
{
|
2008-06-26 17:23:05 +00:00
|
|
|
XmlConfigSource xmlCon = (XmlConfigSource)Source;
|
2008-06-26 17:20:08 +00:00
|
|
|
xmlCon.Save(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-12-31 17:52:48 +00:00
|
|
|
}
|