Compare commits

...

13 Commits

Author SHA1 Message Date
MW 66dc459a06 Added PostInitialise method to IGridPlugin.
Changes it so the loading of IGridServiceModules is done in the loaders PostInitialise method so that all IGridPlugin are initialised before any IGridServerModules.
2009-05-15 12:09:29 +00:00
MW 78f4f49965 deleted duplicate file 2009-04-30 12:02:51 +00:00
MW 70f283e089 Applied patch from mantis #3387, which adds Dynamic plugin support to gridserver. Thanks mikkopa. 2009-04-30 12:02:03 +00:00
MW c7151a5a2b Applied patch from Mantis# 3387, which adds initial support for Dynamically loading IGridServiceModule "modules" in the userserver. Thank you mpallari. 2009-04-03 10:35:47 +00:00
MW da2cbb75b6 Added check so Util.ReadSettingsFromIniFile doesn't try to set static fields. 2009-02-28 16:41:26 +00:00
MW aa5b4b6437 Deleted the userserver project. As now the gridserver plugins and userserver plugins are loadable from the single server exe (gridserver.exe).
Which plugins it loads (either those for gridserver or those for userserver or both) is defined in the opensim.grid.ini file (see opensim.grid.ini.example). Also all config settings are now in that ini file rather than the old xml files. So edit that file with your changes, as the server no longer asks startup questions for those values.
And finally note all this is in a branch so no need for anyone to panic about all these changes.
2009-02-28 16:04:11 +00:00
MW 9b9456c985 GridConfig and UserConfig settings can now be loaded from nini files. 2009-02-28 14:22:36 +00:00
MW ce0e98ad30 Added support for Field/Properties of type uint to the Util.ReadSettingsFromIniFile method. 2009-02-28 14:12:18 +00:00
MW bb1823a7ad fixing the last commit 2009-02-28 13:16:07 +00:00
MW 21e9ad6150 Some small clean up of the Grid/User servers.
Added T ReadSettingsFromIniFile<T>(IConfig configSection, T settingsClass) to OpenSim.Framework.Util, which will try to read values for the public fields and properties (read/writable properties) in the settingsclass from the nini config section. By looking in the ConfigSection for entries matching the names of the properties/fields. It currently supports fields/properties of the types, string, bool, int, float. 
[Note this method used reflection so it comes with the normal performance overhead of that]
2009-02-28 13:08:16 +00:00
MW 4fc37a4abd renabling the loading of the data plugins in the gridserver. 2009-02-27 21:27:41 +00:00
MW 1e015a4cb8 Work on creating a shared generic base GridService server, that can load the modules from User, Grid and Messaging servers.
Started to change the configuration of the Grid server so it uses nini.
2009-02-27 21:22:38 +00:00
MW 29c4eef1fe Creating a new branch to try out ideas for creating a generic grid server that can load the modules of the grid , user and messaging services. So it would be possible to have a single service server combining all the services or still have the three separate ones 2009-02-27 16:40:00 +00:00
39 changed files with 1463 additions and 973 deletions

View File

@ -200,6 +200,7 @@ namespace OpenSim.Framework
m_librariesXMLFile = value;
}
}
protected string m_assetSetsXMLFile;
public string AssetSetsXMLFile
{

View File

@ -26,6 +26,7 @@
*/
using System;
using Nini.Config;
namespace OpenSim.Framework
{
@ -49,6 +50,11 @@ namespace OpenSim.Framework
public string UserRecvKey = String.Empty;
public string UserSendKey = String.Empty;
public GridConfig()
{
}
public GridConfig(string description, string filename)
{
configMember =
@ -56,6 +62,15 @@ namespace OpenSim.Framework
configMember.performConfigurationRetrieve();
}
public void LoadConfigurationFromNini(IConfigSource configSource)
{
IConfig config = configSource.Configs["GridServerConfig"];
if (config != null)
{
Util.ReadSettingsFromIniFile<GridConfig>(config, this);
}
}
public void loadConfigurationOptions()
{
configMember.addConfigurationOption("default_asset_server",

View File

@ -27,6 +27,7 @@
using System;
using System.IO;
using Nini.Config;
namespace OpenSim.Framework
{
@ -91,6 +92,15 @@ namespace OpenSim.Framework
configMember.performConfigurationRetrieve();
}
public void LoadConfigurationFromNini(IConfigSource configSource)
{
IConfig config = configSource.Configs["UserServerConfig"];
if (config != null)
{
Util.ReadSettingsFromIniFile<UserConfig>(config, this);
}
}
public void loadConfigurationOptions()
{
configMember.addConfigurationOption("default_startup_message",

View File

@ -26,6 +26,7 @@
*/
using System;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.IO;
@ -931,5 +932,76 @@ namespace OpenSim.Framework
return displayConnectionString;
}
public static T ReadSettingsFromIniFile<T>(IConfig config, T settingsClass)
{
Type settingsType = settingsClass.GetType();
FieldInfo[] fieldInfos = settingsType.GetFields();
foreach (FieldInfo fieldInfo in fieldInfos)
{
if (!fieldInfo.IsStatic)
{
if (fieldInfo.FieldType == typeof(System.String))
{
fieldInfo.SetValue(settingsClass, config.Get(fieldInfo.Name, (string)fieldInfo.GetValue(settingsClass)));
}
else if (fieldInfo.FieldType == typeof(System.Boolean))
{
fieldInfo.SetValue(settingsClass, config.GetBoolean(fieldInfo.Name, (bool)fieldInfo.GetValue(settingsClass)));
}
else if (fieldInfo.FieldType == typeof(System.Int32))
{
fieldInfo.SetValue(settingsClass, config.GetInt(fieldInfo.Name, (int)fieldInfo.GetValue(settingsClass)));
}
else if (fieldInfo.FieldType == typeof(System.Single))
{
fieldInfo.SetValue(settingsClass, config.GetFloat(fieldInfo.Name, (float)fieldInfo.GetValue(settingsClass)));
}
else if (fieldInfo.FieldType == typeof(System.UInt32))
{
fieldInfo.SetValue(settingsClass, System.Convert.ToUInt32(config.Get(fieldInfo.Name, ((uint)fieldInfo.GetValue(settingsClass)).ToString())));
}
else if (fieldInfo.FieldType == typeof(System.Uri))
{
fieldInfo.SetValue(settingsClass, new Uri(config.Get(fieldInfo.Name, (string)fieldInfo.GetValue(settingsClass))));
}
}
}
PropertyInfo[] propertyInfos = settingsType.GetProperties();
foreach (PropertyInfo propInfo in propertyInfos)
{
if ((propInfo.CanRead) && (propInfo.CanWrite))
{
if (propInfo.PropertyType == typeof(System.String))
{
propInfo.SetValue(settingsClass, config.Get(propInfo.Name, (string)propInfo.GetValue(settingsClass, null)), null);
}
else if (propInfo.PropertyType == typeof(System.Boolean))
{
propInfo.SetValue(settingsClass, config.GetBoolean(propInfo.Name, (bool)propInfo.GetValue(settingsClass, null)), null);
}
else if (propInfo.PropertyType == typeof(System.Int32))
{
propInfo.SetValue(settingsClass, config.GetInt(propInfo.Name, (int)propInfo.GetValue(settingsClass, null)), null);
}
else if (propInfo.PropertyType == typeof(System.Single))
{
propInfo.SetValue(settingsClass, config.GetFloat(propInfo.Name, (float)propInfo.GetValue(settingsClass, null)), null);
}
else if (propInfo.PropertyType == typeof(System.UInt32))
{
propInfo.SetValue(settingsClass, System.Convert.ToUInt32(config.Get(propInfo.Name, ((uint)propInfo.GetValue(settingsClass, null)).ToString())), null);
}
else if (propInfo.PropertyType == typeof(System.Uri))
{
propInfo.SetValue(settingsClass, new Uri(config.Get(propInfo.Name, (string)propInfo.GetValue(settingsClass, null))), null);
}
}
}
return settingsClass;
}
}
}

View File

@ -9,5 +9,6 @@ namespace OpenSim.Grid.Framework
void Initialise(IGridServiceCore core);
void PostInitialise();
void RegisterHandlers(BaseHttpServer httpServer);
string Name { get; }
}
}

View File

@ -0,0 +1,95 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Grid.Framework;
using log4net;
using System.Reflection;
using OpenSim.Framework.Servers;
namespace OpenSim.Grid.GridServer.ModuleLoader
{
public class GridModuleLoaderPlugin : IGridPlugin
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected List<IGridServiceModule> m_modules;
protected GridServerBase m_core;
#region IGridPlugin Members
public void Initialise(GridServerBase gridServer)
{
m_core = gridServer;
}
public void PostInitialise()
{
GridModuleLoader<IGridServiceModule> moduleLoader = new GridModuleLoader<IGridServiceModule>();
m_modules = moduleLoader.PickupModules(".");
InitializeModules();
PostInitializeModules();
RegisterModuleHandlers();
}
#endregion
protected void InitializeModules()
{
foreach (IGridServiceModule m in m_modules)
{
m_log.InfoFormat("[MODULES]: Initialising Grid Service Module {0}", m.Name);
m.Initialise(m_core);
}
}
protected void PostInitializeModules()
{
foreach (IGridServiceModule m in m_modules)
{
//m_log.InfoFormat("[MODULES]: Initialising Grid Service Module {0}", m.Name);
m.PostInitialise();
}
}
protected void RegisterModuleHandlers()
{
BaseHttpServer httpServer;
if (m_core.TryGet<BaseHttpServer>(out httpServer))
{
foreach (IGridServiceModule m in m_modules)
{
//m_log.InfoFormat("[MODULES]: Initialising Grid Service Module {0}", m.Name);
m.RegisterHandlers(httpServer);
}
}
}
#region IPlugin Members
public string Version
{
get { return "0.1"; }
}
public string Name
{
get { return "GridModuleLoaderPlugin"; }
}
public void Initialise()
{
}
#endregion
#region IDisposable Members
public void Dispose()
{
}
#endregion
}
}

View File

@ -39,9 +39,9 @@ using OpenSim.Grid.Framework;
namespace OpenSim.Grid.GridServer.Modules
{
public class GridMessagingModule : IMessagingServerDiscovery
public class GridMessagingModule : IMessagingServerDiscovery, IGridServiceModule
{
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected IRegionProfileService m_gridDBService;
protected IGridServiceCore m_gridCore;
@ -62,27 +62,28 @@ namespace OpenSim.Grid.GridServer.Modules
{
}
public void Initialise(string opensimVersion, IRegionProfileService gridDBService, IGridServiceCore gridCore, GridConfig config)
public void Initialise(IGridServiceCore core)
{
//m_opensimVersion = opensimVersion;
m_gridDBService = gridDBService;
m_gridCore = gridCore;
m_config = config;
m_gridCore = core;
m_gridCore.RegisterInterface<IMessagingServerDiscovery>(this);
RegisterHandlers();
}
public void PostInitialise()
{
if (m_gridCore.TryGet<IRegionProfileService>(out m_gridDBService) &&
m_gridCore.TryGet<GridConfig>(out m_config))
{
;
}
else
{
m_log.Error("[GridMessagingModule] Failed to post initialize module");
}
}
public void RegisterHandlers()
public void RegisterHandlers(BaseHttpServer httpServer)
{
//have these in separate method as some servers restart the http server and reregister all the handlers.
m_httpServer = m_gridCore.GetHttpServer();
m_httpServer = httpServer;
// Message Server ---> Grid Server
m_httpServer.AddXmlRPCHandler("register_messageserver", XmlRPCRegisterMessageServer);
@ -158,5 +159,14 @@ namespace OpenSim.Grid.GridServer.Modules
m_messageServers.Remove(m);
}
}
public void Close()
{
}
public string Name
{
get { return "GridMessagingModule"; }
}
}
}

View File

@ -41,7 +41,7 @@ using OpenSim.Grid.Framework;
namespace OpenSim.Grid.GridServer.Modules
{
public class GridRestModule
public class GridRestModule : IGridServiceModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -67,24 +67,34 @@ namespace OpenSim.Grid.GridServer.Modules
{
}
public void Initialise(string opensimVersion, GridDBService gridDBService, IGridServiceCore gridCore, GridConfig config)
#region IGridServiceModule Members
public void Close()
{
//m_opensimVersion = opensimVersion;
m_gridDBService = gridDBService;
m_gridCore = gridCore;
m_config = config;
RegisterHandlers();
throw new NotImplementedException();
}
public void Initialise(IGridServiceCore core)
{
m_gridCore = core;
}
public void PostInitialise()
{
IRegionProfileService dbService;
if (m_gridCore.TryGet<IRegionProfileService>(out dbService) &&
m_gridCore.TryGet<GridConfig>(out m_config))
{
if (dbService is GridDBService)
m_gridDBService = (GridDBService)dbService;
}
else
m_log.Warn("[GridRestModule]: Could not get modules from core");
}
public void RegisterHandlers()
public void RegisterHandlers(BaseHttpServer httpServer)
{
//have these in separate method as some servers restart the http server and reregister all the handlers.
m_httpServer = m_gridCore.GetHttpServer();
m_httpServer = httpServer;
m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/sims/", RestGetSimMethod));
m_httpServer.AddStreamHandler(new RestStreamHandler("POST", "/sims/", RestSetSimMethod));
@ -93,6 +103,13 @@ namespace OpenSim.Grid.GridServer.Modules
m_httpServer.AddStreamHandler(new RestStreamHandler("POST", "/regions/", RestSetRegionMethod));
}
public string Name
{
get { return "GridRestModule"; }
}
#endregion
/// <summary>
/// Performs a REST Get Operation
/// </summary>

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Reflection;
using System.Text;
using log4net;
using OpenSim.Data;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Grid.Framework;
@ -33,7 +34,7 @@ namespace OpenSim.Grid.GridServer.Modules
public void Initialise(GridServerBase gridServer)
{
m_core = gridServer;
m_config = gridServer.Config;
m_config = gridServer.GConfig;
m_version = gridServer.Version;
m_console = MainConsole.Instance;
@ -42,6 +43,10 @@ namespace OpenSim.Grid.GridServer.Modules
SetupGridServices();
}
public void PostInitialise()
{
}
#endregion
#region IPlugin Members
@ -71,19 +76,8 @@ namespace OpenSim.Grid.GridServer.Modules
//Register the database access service so modules can fetch it
// RegisterInterface<GridDBService>(m_gridDBService);
m_gridMessageModule = new GridMessagingModule();
m_gridMessageModule.Initialise(m_version, m_gridDBService, m_core, m_config);
m_gridXmlRpcModule = new GridXmlRpcModule();
m_gridXmlRpcModule.Initialise(m_version, m_gridDBService, m_core, m_config);
m_gridRestModule = new GridRestModule();
m_gridRestModule.Initialise(m_version, m_gridDBService, m_core, m_config);
m_gridMessageModule.PostInitialise();
m_gridXmlRpcModule.PostInitialise();
m_gridRestModule.PostInitialise();
m_core.RegisterInterface<IRegionProfileService>(m_gridDBService);
m_core.RegisterInterface<GridConfig>(m_config);
}
#region Console Command Handlers

View File

@ -42,7 +42,7 @@ using OpenSim.Grid.Framework;
namespace OpenSim.Grid.GridServer.Modules
{
public class GridXmlRpcModule
public class GridXmlRpcModule : IGridServiceModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -69,28 +69,27 @@ namespace OpenSim.Grid.GridServer.Modules
{
}
public void Initialise(string opensimVersion, IRegionProfileService gridDBService, IGridServiceCore gridCore, GridConfig config)
#region IGridServiceModule Members
public void Initialise(IGridServiceCore core)
{
m_opensimVersion = opensimVersion;
m_gridDBService = gridDBService;
m_gridCore = gridCore;
m_config = config;
RegisterHandlers();
m_gridCore = core;
}
public void PostInitialise()
{
IMessagingServerDiscovery messagingModule;
if (m_gridCore.TryGet<IMessagingServerDiscovery>(out messagingModule))
if (m_gridCore.TryGet<IMessagingServerDiscovery>(out messagingModule) &&
m_gridCore.TryGet<IRegionProfileService>(out m_gridDBService) &&
m_gridCore.TryGet<GridConfig>(out m_config))
{
m_messagingServerMapper = messagingModule;
}
}
public void RegisterHandlers()
public void RegisterHandlers(BaseHttpServer httpServer)
{
//have these in separate method as some servers restart the http server and reregister all the handlers.
m_httpServer = m_gridCore.GetHttpServer();
m_httpServer = httpServer;
m_httpServer.AddXmlRPCHandler("simulator_login", XmlRpcSimulatorLoginMethod);
m_httpServer.AddXmlRPCHandler("simulator_data_request", XmlRpcSimulatorDataRequestMethod);
@ -99,6 +98,17 @@ namespace OpenSim.Grid.GridServer.Modules
m_httpServer.AddXmlRPCHandler("search_for_region_by_name", XmlRpcSearchForRegionMethod);
}
public string Name
{
get { return "GridXmlRpcModule"; }
}
public void Close()
{
}
#endregion
/// <summary>
/// Returns a XML String containing a list of the neighbouring regions
/// </summary>

View File

@ -6,6 +6,6 @@
<Addin id="OpenSim.Grid.GridServer" version="0.5" />
</Dependencies>
<Extension path = "/OpenSim/GridServer">
<Plugin id="GridServerModules" type="OpenSim.Grid.GridServer.Modules.GridServerPlugin" />
<Plugin id="GridServerPlugin" type="OpenSim.Grid.GridServer.Modules.GridServerPlugin" />
</Extension>
</Addin>

View File

@ -0,0 +1,250 @@
/*
* 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 OpenSimulator 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.
*/
using System;
using System.IO;
using System.Reflection;
using System.Threading;
using System.Xml;
using log4net;
using Nini.Config;
using OpenSim.Framework;
namespace OpenSim.Grid.GridServer
{
public class GridConfigurationLoader
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected OpenSimConfigSource m_config;
public GridConfigurationLoader()
{
}
public OpenSimConfigSource LoadConfigSettings(IConfigSource configSource)
{
bool iniFileExists = false;
IConfig startupConfig = configSource.Configs["Startup"];
string masterFileName = startupConfig.GetString("inimaster", "");
string masterfilePath = Path.Combine(Util.configDir(), masterFileName);
string iniDirName = startupConfig.GetString("inidirectory", "GridConfig");
string iniDirPath = Path.Combine(Util.configDir(), iniDirName);
string iniFileName = startupConfig.GetString("inifile", "OpenSim.Grid.ini");
string iniFilePath = Path.Combine(Util.configDir(), iniFileName);
string xmlPath = Path.Combine(Util.configDir(), "OpenSim.Grid.xml");
m_config = new OpenSimConfigSource();
m_config.Source = new IniConfigSource();
m_config.Source.Merge(DefaultConfig());
m_log.Info("[CONFIG] Reading configuration settings");
Uri configUri;
//check for master .INI file (name passed in command line, no default), or XML over http
if (masterFileName.Length > 0) // If a master file name is given ...
{
m_log.InfoFormat("[CONFIG] Reading config master file {0}", masterfilePath);
bool isMasterUri = Uri.TryCreate(masterFileName, UriKind.Absolute, out configUri) && configUri.Scheme == Uri.UriSchemeHttp;
if (!ReadConfig(masterFileName, masterfilePath, m_config, isMasterUri))
{
m_log.FatalFormat("[CONFIG] Could not open master config file {0}", masterfilePath);
}
}
if (Directory.Exists(iniDirName))
{
m_log.InfoFormat("Searching folder: {0} , for config ini files", iniDirName);
string[] fileEntries = Directory.GetFiles(iniDirName);
foreach (string filePath in fileEntries)
{
// m_log.InfoFormat("reading ini file < {0} > from config dir", filePath);
ReadConfig(Path.GetFileName(filePath), filePath, m_config, false);
}
}
// Check for .INI file (either default or name passed on command
// line) or XML config source over http
bool isIniUri = Uri.TryCreate(iniFileName, UriKind.Absolute, out configUri) && configUri.Scheme == Uri.UriSchemeHttp;
iniFileExists = ReadConfig(iniFileName, iniFilePath, m_config, isIniUri);
if (!iniFileExists)
{
// check for a xml config file
if (File.Exists(xmlPath))
{
iniFilePath = xmlPath;
m_log.InfoFormat("Reading XML configuration from {0}", Path.GetFullPath(xmlPath));
iniFileExists = true;
m_config.Source = new XmlConfigSource();
m_config.Source.Merge(new XmlConfigSource(iniFilePath));
}
}
m_config.Source.Merge(configSource);
if (!iniFileExists)
{
m_log.FatalFormat("[CONFIG] Could not load any configuration");
if (!isIniUri)
m_log.FatalFormat("[CONFIG] Tried to load {0}, ", Path.GetFullPath(iniFilePath));
else
m_log.FatalFormat("[CONFIG] Tried to load from URI {0}, ", iniFileName);
m_log.FatalFormat("[CONFIG] and XML source {0}", Path.GetFullPath(xmlPath));
m_log.FatalFormat("[CONFIG] Did you copy the OpenSim.Grid.ini.example file to OpenSim.Grid.ini?");
Environment.Exit(1);
}
ReadConfigSettings();
return m_config;
}
/// <summary>
/// Provide same ini loader functionality for standard ini and master ini - file system or XML over http
/// </summary>
/// <param name="iniName">The name of the ini to load</param>
/// <param name="iniPath">Full path to the ini</param>
/// <param name="m_config">The current configuration source</param>
/// <param name="isUri">Boolean representing whether the ini source is a URI path over http or a file on the system</param>
/// <returns></returns>
private bool ReadConfig(string iniName, string iniPath, OpenSimConfigSource m_config, bool isUri)
{
bool success = false;
if (!isUri && File.Exists(iniPath))
{
m_log.InfoFormat("[CONFIG] Reading configuration file {0}", Path.GetFullPath(iniPath));
// From reading Nini's code, it seems that later merged keys replace earlier ones.
m_config.Source.Merge(new IniConfigSource(iniPath));
success = true;
}
else
{
if (isUri)
{
m_log.InfoFormat("[CONFIG] {0} is a http:// URI, fetching ...", iniName);
// The ini file path is a http URI
// Try to read it
try
{
XmlReader r = XmlReader.Create(iniName);
XmlConfigSource cs = new XmlConfigSource(r);
m_config.Source.Merge(cs);
success = true;
m_log.InfoFormat("[CONFIG] Loaded config from {0}", iniName);
}
catch (Exception e)
{
m_log.FatalFormat("[CONFIG] Exception reading config from URI {0}\n" + e.ToString(), iniName);
Environment.Exit(1);
}
}
}
return success;
}
/// <summary>
/// Setup a default config values in case they aren't present in the ini file
/// </summary>
/// <returns></returns>
public static IConfigSource DefaultConfig()
{
IConfigSource defaultConfig = new IniConfigSource();
{
IConfig config = defaultConfig.Configs["Startup"];
if (null == config)
config = defaultConfig.AddConfig("Startup");
config.Set("LoadPlugins", "GridServerPlugin,UserServerPlugin");
config.Set("HttpPort", "8051");
}
{
IConfig config = defaultConfig.Configs["GridServices"];
if (null == config)
config = defaultConfig.AddConfig("GridServices");
config.Set("enable", false);
}
return defaultConfig;
}
protected virtual void ReadConfigSettings()
{
IConfig startupConfig = m_config.Source.Configs["Startup"];
if (startupConfig != null)
{
}
IConfig standaloneConfig = m_config.Source.Configs["StandAlone"];
if (standaloneConfig != null)
{
}
}
}
public class OpenSimConfigSource
{
public IConfigSource Source;
public void Save(string path)
{
if (Source is IniConfigSource)
{
IniConfigSource iniCon = (IniConfigSource)Source;
iniCon.Save(path);
}
else if (Source is XmlConfigSource)
{
XmlConfigSource xmlCon = (XmlConfigSource)Source;
xmlCon.Save(path);
}
}
}
}

View File

@ -31,6 +31,7 @@ using System.IO;
using System.Reflection;
using System.Timers;
using log4net;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Framework.Servers;
@ -44,11 +45,25 @@ namespace OpenSim.Grid.GridServer
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected GridConfig m_config;
protected GridConfig m_gconfig;
protected UserConfig m_uconfig;
public GridConfig Config
protected GridConfigurationLoader m_configLoader;
protected OpenSimConfigSource m_configSource;
public OpenSimConfigSource ConfigSource
{
get { return m_config; }
get { return m_configSource; }
}
public GridConfig GConfig
{
get { return m_gconfig; }
}
public UserConfig UConfig
{
get { return m_uconfig; }
}
public string Version
@ -68,23 +83,61 @@ namespace OpenSim.Grid.GridServer
}
}
public GridServerBase()
public GridServerBase(IConfigSource configSource)
{
m_console = new ConsoleBase("Grid");
MainConsole.Instance = m_console;
m_configLoader = new GridConfigurationLoader();
m_configSource = m_configLoader.LoadConfigSettings(configSource);
}
protected override void StartupSpecific()
{
m_config = new GridConfig("GRID SERVER", (Path.Combine(Util.configDir(), "GridServer_Config.xml")));
uint httpPort = 8051;
m_log.Info("[GRID]: Starting HTTP process");
m_httpServer = new BaseHttpServer(m_config.HttpPort);
// m_gconfig = new GridConfig("GRID SERVER", (Path.Combine(Util.configDir(), "GridServer_Config.xml")));
LoadPlugins();
//m_uconfig = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml")));
m_httpServer.Start();
m_uconfig = new UserConfig();
m_uconfig.LoadConfigurationFromNini(m_configSource.Source);
m_gconfig = new GridConfig();
m_gconfig.LoadConfigurationFromNini(m_configSource.Source);
Console.WriteLine("grid server database provider is {0} ", m_gconfig.DatabaseProvider);
IConfig startupConfig = m_configSource.Source.Configs["Startup"];
if (startupConfig != null)
{
httpPort = Convert.ToUInt32(startupConfig.GetString("HttpPort", "8051"));
m_log.InfoFormat("[GRID]: Starting HTTP process on port {0}", httpPort);
m_httpServer = new BaseHttpServer(httpPort);
RegisterInterface<BaseHttpServer>(m_httpServer);
string pluginsToLoad = startupConfig.GetString("LoadPlugins", "");
if (!String.IsNullOrEmpty(pluginsToLoad))
{
LoadPlugins(pluginsToLoad);
}
else
{
LoadPlugins();
}
foreach (IGridPlugin plugin in m_plugins)
{
plugin.PostInitialise();
}
m_httpServer.Start();
}
base.StartupSpecific();
}
@ -97,6 +150,18 @@ namespace OpenSim.Grid.GridServer
m_plugins = loader.Plugins;
}
protected virtual void LoadPlugins(string pluginNames)
{
PluginLoader<IGridPlugin> loader =
new PluginLoader<IGridPlugin>(new GridPluginInitialiser(this));
PluginIdFilter filer = new PluginIdFilter(pluginNames);
loader.Add("/OpenSim/GridServer", filer);
loader.Load();
m_plugins = loader.Plugins;
}
public override void ShutdownSpecific()
{
foreach (IGridPlugin plugin in m_plugins) plugin.Dispose();

View File

@ -33,6 +33,7 @@ namespace OpenSim.Grid.GridServer
public interface IGridPlugin : IPlugin
{
void Initialise(GridServerBase gridServer);
void PostInitialise();
}
public class GridPluginInitialiser : PluginInitialiserBase

View File

@ -26,6 +26,7 @@
*/
using log4net.Config;
using Nini.Config;
namespace OpenSim.Grid.GridServer
{
@ -35,7 +36,18 @@ namespace OpenSim.Grid.GridServer
{
XmlConfigurator.Configure();
GridServerBase app = new GridServerBase();
ArgvConfigSource configSource = new ArgvConfigSource(args);
configSource.Alias.AddAlias("On", true);
configSource.Alias.AddAlias("Off", false);
configSource.Alias.AddAlias("True", true);
configSource.Alias.AddAlias("False", false);
configSource.AddSwitch("Startup", "inifile");
configSource.AddSwitch("Startup", "inimaster");
configSource.AddSwitch("Startup", "inidirectory");
GridServerBase app = new GridServerBase(configSource);
// if (args.Length > 0 && args[0] == "-setuponly")
// {

View File

@ -41,7 +41,7 @@ using OpenSim.Grid.Framework;
namespace OpenSim.Grid.UserServer.Modules
{
public class GridInfoServiceModule
public class GridInfoServiceModule : IGridServiceModule
{
protected IGridServiceCore m_core;
protected GridInfoService m_gridInfoService;
@ -73,5 +73,10 @@ namespace OpenSim.Grid.UserServer.Modules
public void Close()
{
}
public string Name
{
get { return "GridInfoServiceModule"; }
}
}
}

View File

@ -66,7 +66,7 @@ namespace OpenSim.Grid.UserServer.Modules
public delegate void RegionShutdownDelegate(UUID regionID);
public class MessageServersConnector
public class MessageServersConnector : IGridServiceModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -508,5 +508,15 @@ namespace OpenSim.Grid.UserServer.Modules
response.Value = result;
return response;
}
public void Close()
{
}
public string Name
{
get { return "MessageServersConnector"; }
}
}
}

View File

@ -0,0 +1,11 @@
<Addin id="OpenSim.Grid.UserServer.Modules" version="0.1">
<Runtime>
<Import assembly="OpenSim.Grid.UserServer.Modules.dll"/>
</Runtime>
<Dependencies>
<Addin id="OpenSim.Grid.GridServer" version="0.5" />
</Dependencies>
<Extension path = "/OpenSim/GridServer">
<Plugin id="UserServerPlugin" type="OpenSim.Grid.UserServer.Modules.UserServerPlugin" />
</Extension>
</Addin>

View File

@ -41,7 +41,7 @@ namespace OpenSim.Grid.UserServer.Modules
{
public delegate void logOffUser(UUID AgentID);
public class UserManager
public class UserManager : IGridServiceModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -50,24 +50,22 @@ namespace OpenSim.Grid.UserServer.Modules
private UserDataBaseService m_userDataBaseService;
private BaseHttpServer m_httpServer;
private IGridServiceCore m_core;
/// <summary>
///
/// </summary>
/// <param name="userDataBaseService"></param>
public UserManager( UserDataBaseService userDataBaseService)
public UserManager()
{
m_userDataBaseService = userDataBaseService;
}
public void Initialise(IGridServiceCore core)
{
m_core = core;
m_core.RegisterInterface<UserManager>(this);
}
public void PostInitialise()
{
if (!m_core.TryGet<UserDataBaseService>(out m_userDataBaseService))
m_log.Error("[UserManager]: Failed to fetch database plugin");
}
public void RegisterHandlers(BaseHttpServer httpServer)
@ -685,6 +683,15 @@ namespace OpenSim.Grid.UserServer.Modules
public void HandleRegionShutdown(UUID regionID)
{
m_userDataBaseService.LogoutUsers(regionID);
}
}
public void Close()
{
}
public string Name
{
get { return "UserManager"; }
}
}
}

View File

@ -39,26 +39,27 @@ using OpenSim.Grid.Framework;
namespace OpenSim.Grid.UserServer.Modules
{
public class UserServerAvatarAppearanceModule
public class UserServerAvatarAppearanceModule : IGridServiceModule
{
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private UserDataBaseService m_userDataBaseService;
private BaseHttpServer m_httpServer;
private IGridServiceCore m_core;
public UserServerAvatarAppearanceModule(UserDataBaseService userDataBaseService)
public UserServerAvatarAppearanceModule()
{
m_userDataBaseService = userDataBaseService;
}
public void Initialise(IGridServiceCore core)
{
m_core = core;
}
public void PostInitialise()
{
if (!m_core.TryGet<UserDataBaseService>(out m_userDataBaseService))
m_log.Error("[UserServerAvatarAppearanceModule]: Failed to fetch database plugin");
}
public void RegisterHandlers(BaseHttpServer httpServer)
@ -121,5 +122,14 @@ namespace OpenSim.Grid.UserServer.Modules
response.Value = responseData;
return response;
}
public void Close()
{
}
public string Name
{
get { return "UserServerAvatarAppearanceModule"; }
}
}
}

View File

@ -1,374 +1,383 @@
/*
* 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.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using log4net;
using log4net.Config;
using OpenMetaverse;
using OpenSim.Data;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Statistics;
using OpenSim.Grid.Communications.OGS1;
using OpenSim.Grid.Framework;
using OpenSim.Grid.UserServer.Modules;
namespace OpenSim.Grid.UserServer
{
public class UserServerCommandModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected ConsoleBase m_console;
protected UserConfig m_cfg;
protected UserDataBaseService m_userDataBaseService;
protected UserLoginService m_loginService;
protected UUID m_lastCreatedUser = UUID.Random();
protected IGridServiceCore m_core;
public UserServerCommandModule()
{
}
public void Initialise(IGridServiceCore core)
{
m_core = core;
}
public void PostInitialise()
{
UserConfig cfg;
if (m_core.TryGet<UserConfig>(out cfg))
{
m_cfg = cfg;
}
UserDataBaseService userDBservice;
if (m_core.TryGet<UserDataBaseService>(out userDBservice))
{
m_userDataBaseService = userDBservice;
}
UserLoginService loginService;
if (m_core.TryGet<UserLoginService>(out loginService))
{
m_loginService = loginService;
}
ConsoleBase console;
if ((m_core.TryGet<ConsoleBase>(out console)) && (m_cfg != null)
&& (m_userDataBaseService != null) && (m_loginService != null))
{
RegisterConsoleCommands(console);
}
}
public void RegisterHandlers(BaseHttpServer httpServer)
{
}
private void RegisterConsoleCommands(ConsoleBase console)
{
m_console = console;
m_console.Commands.AddCommand("userserver", false, "create user",
"create user [<first> [<last> [<x> <y> [email]]]]",
"Create a new user account", RunCommand);
m_console.Commands.AddCommand("userserver", false, "reset user password",
"reset user password [<first> [<last> [<new password>]]]",
"Reset a user's password", RunCommand);
m_console.Commands.AddCommand("userserver", false, "login level",
"login level <level>",
"Set the minimum user level to log in", HandleLoginCommand);
m_console.Commands.AddCommand("userserver", false, "login reset",
"login reset",
"Reset the login level to allow all users",
HandleLoginCommand);
m_console.Commands.AddCommand("userserver", false, "login text",
"login text <text>",
"Set the text users will see on login", HandleLoginCommand);
m_console.Commands.AddCommand("userserver", false, "test-inventory",
"test-inventory",
"Perform a test inventory transaction", RunCommand);
m_console.Commands.AddCommand("userserver", false, "logoff-user",
"logoff-user <first> <last> <message>",
"Log off a named user", RunCommand);
}
#region Console Command Handlers
public void do_create(string[] args)
{
switch (args[0])
{
case "user":
CreateUser(args);
break;
}
}
/// <summary>
/// Execute switch for some of the reset commands
/// </summary>
/// <param name="args"></param>
protected void Reset(string[] args)
{
if (args.Length == 0)
return;
switch (args[0])
{
case "user":
switch (args[1])
{
case "password":
ResetUserPassword(args);
break;
}
break;
}
}
/// <summary>
/// Create a new user
/// </summary>
/// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param>
protected void CreateUser(string[] cmdparams)
{
string firstName;
string lastName;
string password;
string email;
uint regX = 1000;
uint regY = 1000;
if (cmdparams.Length < 2)
firstName = MainConsole.Instance.CmdPrompt("First name", "Default");
else firstName = cmdparams[1];
if (cmdparams.Length < 3)
lastName = MainConsole.Instance.CmdPrompt("Last name", "User");
else lastName = cmdparams[2];
if (cmdparams.Length < 4)
password = MainConsole.Instance.PasswdPrompt("Password");
else password = cmdparams[3];
if (cmdparams.Length < 5)
regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString()));
else regX = Convert.ToUInt32(cmdparams[4]);
if (cmdparams.Length < 6)
regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString()));
else regY = Convert.ToUInt32(cmdparams[5]);
if (cmdparams.Length < 7)
email = MainConsole.Instance.CmdPrompt("Email", "");
else email = cmdparams[6];
if (null == m_userDataBaseService.GetUserProfile(firstName, lastName))
{
m_lastCreatedUser = m_userDataBaseService.AddUser(firstName, lastName, password, email, regX, regY);
}
else
{
m_log.ErrorFormat("[USERS]: A user with the name {0} {1} already exists!", firstName, lastName);
}
}
/// <summary>
/// Reset a user password.
/// </summary>
/// <param name="cmdparams"></param>
private void ResetUserPassword(string[] cmdparams)
{
string firstName;
string lastName;
string newPassword;
if (cmdparams.Length < 3)
firstName = MainConsole.Instance.CmdPrompt("First name");
else firstName = cmdparams[2];
if (cmdparams.Length < 4)
lastName = MainConsole.Instance.CmdPrompt("Last name");
else lastName = cmdparams[3];
if (cmdparams.Length < 5)
newPassword = MainConsole.Instance.PasswdPrompt("New password");
else newPassword = cmdparams[4];
m_userDataBaseService.ResetUserPassword(firstName, lastName, newPassword);
}
/*
private void HandleTestCommand(string module, string[] cmd)
{
m_log.Info("test command received");
}
*/
private void HandleLoginCommand(string module, string[] cmd)
{
string subcommand = cmd[1];
switch (subcommand)
{
case "level":
// Set the minimal level to allow login
// Useful to allow grid update without worrying about users.
// or fixing critical issues
//
if (cmd.Length > 2)
{
int level = Convert.ToInt32(cmd[2]);
m_loginService.setloginlevel(level);
}
break;
case "reset":
m_loginService.setloginlevel(0);
break;
case "text":
if (cmd.Length > 2)
{
m_loginService.setwelcometext(cmd[2]);
}
break;
}
}
public void RunCommand(string module, string[] cmd)
{
List<string> args = new List<string>(cmd);
string command = cmd[0];
args.RemoveAt(0);
string[] cmdparams = args.ToArray();
switch (command)
{
case "create":
do_create(cmdparams);
break;
case "reset":
Reset(cmdparams);
break;
case "test-inventory":
// RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>();
// requester.ReturnResponseVal = TestResponse;
// requester.BeginPostObject<UUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
SynchronousRestObjectPoster.BeginPostObject<UUID, List<InventoryFolderBase>>(
"POST", m_cfg.InventoryUrl + "RootFolders/", m_lastCreatedUser);
break;
case "logoff-user":
if (cmdparams.Length >= 3)
{
string firstname = cmdparams[0];
string lastname = cmdparams[1];
string message = "";
for (int i = 2; i < cmdparams.Length; i++)
message += " " + cmdparams[i];
UserProfileData theUser = null;
try
{
theUser = m_loginService.GetTheUser(firstname, lastname);
}
catch (Exception)
{
m_log.Error("[LOGOFF]: Error getting user data from the database.");
}
if (theUser != null)
{
if (theUser.CurrentAgent != null)
{
if (theUser.CurrentAgent.AgentOnline)
{
m_log.Info("[LOGOFF]: Logging off requested user!");
m_loginService.LogOffUser(theUser, message);
theUser.CurrentAgent.AgentOnline = false;
m_loginService.CommitAgent(ref theUser);
}
else
{
m_log.Info(
"[LOGOFF]: User Doesn't appear to be online, sending the logoff message anyway.");
m_loginService.LogOffUser(theUser, message);
theUser.CurrentAgent.AgentOnline = false;
m_loginService.CommitAgent(ref theUser);
}
}
else
{
m_log.Error(
"[LOGOFF]: Unable to logoff-user. User doesn't have an agent record so I can't find the simulator to notify");
}
}
else
{
m_log.Info("[LOGOFF]: User doesn't exist in the database");
}
}
else
{
m_log.Error(
"[LOGOFF]: Invalid amount of parameters. logoff-user takes at least three. Firstname, Lastname, and message");
}
break;
}
}
}
#endregion
}
/*
* 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.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using log4net;
using log4net.Config;
using OpenMetaverse;
using OpenSim.Data;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Statistics;
using OpenSim.Grid.Communications.OGS1;
using OpenSim.Grid.Framework;
namespace OpenSim.Grid.UserServer.Modules
{
public class UserServerCommandModule : IGridServiceModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected ConsoleBase m_console;
protected UserConfig m_cfg;
protected UserDataBaseService m_userDataBaseService;
protected UserLoginService m_loginService;
protected UUID m_lastCreatedUser = UUID.Random();
protected IGridServiceCore m_core;
public UserServerCommandModule()
{
}
public void Initialise(IGridServiceCore core)
{
m_core = core;
}
public void PostInitialise()
{
UserConfig cfg;
if (m_core.TryGet<UserConfig>(out cfg))
{
m_cfg = cfg;
}
UserDataBaseService userDBservice;
if (m_core.TryGet<UserDataBaseService>(out userDBservice))
{
m_userDataBaseService = userDBservice;
}
UserLoginService loginService;
if (m_core.TryGet<UserLoginService>(out loginService))
{
m_loginService = loginService;
}
ConsoleBase console;
if ((m_core.TryGet<ConsoleBase>(out console)) && (m_cfg != null)
&& (m_userDataBaseService != null) && (m_loginService != null))
{
RegisterConsoleCommands(console);
}
}
public void RegisterHandlers(BaseHttpServer httpServer)
{
}
private void RegisterConsoleCommands(ConsoleBase console)
{
m_console = console;
m_console.Commands.AddCommand("userserver", false, "create user",
"create user [<first> [<last> [<x> <y> [email]]]]",
"Create a new user account", RunCommand);
m_console.Commands.AddCommand("userserver", false, "reset user password",
"reset user password [<first> [<last> [<new password>]]]",
"Reset a user's password", RunCommand);
m_console.Commands.AddCommand("userserver", false, "login level",
"login level <level>",
"Set the minimum user level to log in", HandleLoginCommand);
m_console.Commands.AddCommand("userserver", false, "login reset",
"login reset",
"Reset the login level to allow all users",
HandleLoginCommand);
m_console.Commands.AddCommand("userserver", false, "login text",
"login text <text>",
"Set the text users will see on login", HandleLoginCommand);
m_console.Commands.AddCommand("userserver", false, "test-inventory",
"test-inventory",
"Perform a test inventory transaction", RunCommand);
m_console.Commands.AddCommand("userserver", false, "logoff-user",
"logoff-user <first> <last> <message>",
"Log off a named user", RunCommand);
}
#region Console Command Handlers
public void do_create(string[] args)
{
switch (args[0])
{
case "user":
CreateUser(args);
break;
}
}
/// <summary>
/// Execute switch for some of the reset commands
/// </summary>
/// <param name="args"></param>
protected void Reset(string[] args)
{
if (args.Length == 0)
return;
switch (args[0])
{
case "user":
switch (args[1])
{
case "password":
ResetUserPassword(args);
break;
}
break;
}
}
/// <summary>
/// Create a new user
/// </summary>
/// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param>
protected void CreateUser(string[] cmdparams)
{
string firstName;
string lastName;
string password;
string email;
uint regX = 1000;
uint regY = 1000;
if (cmdparams.Length < 2)
firstName = MainConsole.Instance.CmdPrompt("First name", "Default");
else firstName = cmdparams[1];
if (cmdparams.Length < 3)
lastName = MainConsole.Instance.CmdPrompt("Last name", "User");
else lastName = cmdparams[2];
if (cmdparams.Length < 4)
password = MainConsole.Instance.PasswdPrompt("Password");
else password = cmdparams[3];
if (cmdparams.Length < 5)
regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString()));
else regX = Convert.ToUInt32(cmdparams[4]);
if (cmdparams.Length < 6)
regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString()));
else regY = Convert.ToUInt32(cmdparams[5]);
if (cmdparams.Length < 7)
email = MainConsole.Instance.CmdPrompt("Email", "");
else email = cmdparams[6];
if (null == m_userDataBaseService.GetUserProfile(firstName, lastName))
{
m_lastCreatedUser = m_userDataBaseService.AddUser(firstName, lastName, password, email, regX, regY);
}
else
{
m_log.ErrorFormat("[USERS]: A user with the name {0} {1} already exists!", firstName, lastName);
}
}
/// <summary>
/// Reset a user password.
/// </summary>
/// <param name="cmdparams"></param>
private void ResetUserPassword(string[] cmdparams)
{
string firstName;
string lastName;
string newPassword;
if (cmdparams.Length < 3)
firstName = MainConsole.Instance.CmdPrompt("First name");
else firstName = cmdparams[2];
if (cmdparams.Length < 4)
lastName = MainConsole.Instance.CmdPrompt("Last name");
else lastName = cmdparams[3];
if (cmdparams.Length < 5)
newPassword = MainConsole.Instance.PasswdPrompt("New password");
else newPassword = cmdparams[4];
m_userDataBaseService.ResetUserPassword(firstName, lastName, newPassword);
}
/*
private void HandleTestCommand(string module, string[] cmd)
{
m_log.Info("test command received");
}
*/
private void HandleLoginCommand(string module, string[] cmd)
{
string subcommand = cmd[1];
switch (subcommand)
{
case "level":
// Set the minimal level to allow login
// Useful to allow grid update without worrying about users.
// or fixing critical issues
//
if (cmd.Length > 2)
{
int level = Convert.ToInt32(cmd[2]);
m_loginService.setloginlevel(level);
}
break;
case "reset":
m_loginService.setloginlevel(0);
break;
case "text":
if (cmd.Length > 2)
{
m_loginService.setwelcometext(cmd[2]);
}
break;
}
}
public void RunCommand(string module, string[] cmd)
{
List<string> args = new List<string>(cmd);
string command = cmd[0];
args.RemoveAt(0);
string[] cmdparams = args.ToArray();
switch (command)
{
case "create":
do_create(cmdparams);
break;
case "reset":
Reset(cmdparams);
break;
case "test-inventory":
// RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>();
// requester.ReturnResponseVal = TestResponse;
// requester.BeginPostObject<UUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
SynchronousRestObjectPoster.BeginPostObject<UUID, List<InventoryFolderBase>>(
"POST", m_cfg.InventoryUrl + "RootFolders/", m_lastCreatedUser);
break;
case "logoff-user":
if (cmdparams.Length >= 3)
{
string firstname = cmdparams[0];
string lastname = cmdparams[1];
string message = "";
for (int i = 2; i < cmdparams.Length; i++)
message += " " + cmdparams[i];
UserProfileData theUser = null;
try
{
theUser = m_loginService.GetTheUser(firstname, lastname);
}
catch (Exception)
{
m_log.Error("[LOGOFF]: Error getting user data from the database.");
}
if (theUser != null)
{
if (theUser.CurrentAgent != null)
{
if (theUser.CurrentAgent.AgentOnline)
{
m_log.Info("[LOGOFF]: Logging off requested user!");
m_loginService.LogOffUser(theUser, message);
theUser.CurrentAgent.AgentOnline = false;
m_loginService.CommitAgent(ref theUser);
}
else
{
m_log.Info(
"[LOGOFF]: User Doesn't appear to be online, sending the logoff message anyway.");
m_loginService.LogOffUser(theUser, message);
theUser.CurrentAgent.AgentOnline = false;
m_loginService.CommitAgent(ref theUser);
}
}
else
{
m_log.Error(
"[LOGOFF]: Unable to logoff-user. User doesn't have an agent record so I can't find the simulator to notify");
}
}
else
{
m_log.Info("[LOGOFF]: User doesn't exist in the database");
}
}
else
{
m_log.Error(
"[LOGOFF]: Invalid amount of parameters. logoff-user takes at least three. Firstname, Lastname, and message");
}
break;
}
}
#endregion
public void Close()
{
}
public string Name
{
get { return "UserServerCommandModule"; }
}
}
}

View File

@ -1,141 +1,151 @@
/*
* 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.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using log4net;
using log4net.Config;
using OpenMetaverse;
using OpenSim.Data;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Statistics;
using OpenSim.Grid.Communications.OGS1;
using OpenSim.Grid.Framework;
using OpenSim.Grid.UserServer.Modules;
namespace OpenSim.Grid.UserServer
{
//Do we actually need these event dispatchers?
//shouldn't the other modules just directly register event handlers to each other?
public class UserServerEventDispatchModule
{
protected UserManager m_userManager;
protected MessageServersConnector m_messagesService;
protected UserLoginService m_loginService;
public UserServerEventDispatchModule(UserManager userManager, MessageServersConnector messagesService, UserLoginService loginService)
{
m_userManager = userManager;
m_messagesService = messagesService;
m_loginService = loginService;
}
public void Initialise(IGridServiceCore core)
{
}
public void PostInitialise()
{
m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation;
m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff;
m_messagesService.OnAgentLocation += HandleAgentLocation;
m_messagesService.OnAgentLeaving += HandleAgentLeaving;
m_messagesService.OnRegionStartup += HandleRegionStartup;
m_messagesService.OnRegionShutdown += HandleRegionShutdown;
}
public void RegisterHandlers(BaseHttpServer httpServer)
{
}
public void Close()
{
m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation;
}
#region Event Handlers
public void NotifyMessageServersUserLoggOff(UUID agentID)
{
m_messagesService.TellMessageServersAboutUserLogoff(agentID);
}
public void NotifyMessageServersUserLoggedInToLocation(UUID agentID, UUID sessionID, UUID RegionID,
ulong regionhandle, float positionX, float positionY,
float positionZ, string firstname, string lastname)
{
m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, positionX,
positionY, positionZ, firstname, lastname);
}
public void HandleAgentLocation(UUID agentID, UUID regionID, ulong regionHandle)
{
m_userManager.HandleAgentLocation(agentID, regionID, regionHandle);
}
public void HandleAgentLeaving(UUID agentID, UUID regionID, ulong regionHandle)
{
m_userManager.HandleAgentLeaving(agentID, regionID, regionHandle);
}
public void HandleRegionStartup(UUID regionID)
{
// This might seem strange, that we send this back to the
// server it came from. But there is method to the madness.
// There can be multiple user servers on the same database,
// and each can have multiple messaging servers. So, we send
// it to all known user servers, who send it to all known
// message servers. That way, we should be able to finally
// update presence to all regions and thereby all friends
//
m_userManager.HandleRegionStartup(regionID);
m_messagesService.TellMessageServersAboutRegionShutdown(regionID);
}
public void HandleRegionShutdown(UUID regionID)
{
// This might seem strange, that we send this back to the
// server it came from. But there is method to the madness.
// There can be multiple user servers on the same database,
// and each can have multiple messaging servers. So, we send
// it to all known user servers, who send it to all known
// message servers. That way, we should be able to finally
// update presence to all regions and thereby all friends
//
m_userManager.HandleRegionShutdown(regionID);
m_messagesService.TellMessageServersAboutRegionShutdown(regionID);
}
#endregion
}
}
/*
* 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.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using log4net;
using log4net.Config;
using OpenMetaverse;
using OpenSim.Data;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Statistics;
using OpenSim.Grid.Communications.OGS1;
using OpenSim.Grid.Framework;
namespace OpenSim.Grid.UserServer.Modules
{
//Do we actually need these event dispatchers?
//shouldn't the other modules just directly register event handlers to each other?
public class UserServerEventDispatchModule : IGridServiceModule
{
protected UserManager m_userManager;
protected MessageServersConnector m_messagesService;
protected UserLoginService m_loginService;
private IGridServiceCore m_core;
public UserServerEventDispatchModule()
{
}
public void Initialise(IGridServiceCore core)
{
m_core = core;
}
public void PostInitialise()
{
if (m_core.TryGet<UserManager>(out m_userManager) &&
m_core.TryGet<MessageServersConnector>(out m_messagesService) &&
m_core.TryGet<UserLoginService>(out m_loginService))
{
m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation;
m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff;
m_messagesService.OnAgentLocation += HandleAgentLocation;
m_messagesService.OnAgentLeaving += HandleAgentLeaving;
m_messagesService.OnRegionStartup += HandleRegionStartup;
m_messagesService.OnRegionShutdown += HandleRegionShutdown;
}
}
public void RegisterHandlers(BaseHttpServer httpServer)
{
}
public void Close()
{
m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation;
}
#region Event Handlers
public void NotifyMessageServersUserLoggOff(UUID agentID)
{
m_messagesService.TellMessageServersAboutUserLogoff(agentID);
}
public void NotifyMessageServersUserLoggedInToLocation(UUID agentID, UUID sessionID, UUID RegionID,
ulong regionhandle, float positionX, float positionY,
float positionZ, string firstname, string lastname)
{
m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, positionX,
positionY, positionZ, firstname, lastname);
}
public void HandleAgentLocation(UUID agentID, UUID regionID, ulong regionHandle)
{
m_userManager.HandleAgentLocation(agentID, regionID, regionHandle);
}
public void HandleAgentLeaving(UUID agentID, UUID regionID, ulong regionHandle)
{
m_userManager.HandleAgentLeaving(agentID, regionID, regionHandle);
}
public void HandleRegionStartup(UUID regionID)
{
// This might seem strange, that we send this back to the
// server it came from. But there is method to the madness.
// There can be multiple user servers on the same database,
// and each can have multiple messaging servers. So, we send
// it to all known user servers, who send it to all known
// message servers. That way, we should be able to finally
// update presence to all regions and thereby all friends
//
m_userManager.HandleRegionStartup(regionID);
m_messagesService.TellMessageServersAboutRegionShutdown(regionID);
}
public void HandleRegionShutdown(UUID regionID)
{
// This might seem strange, that we send this back to the
// server it came from. But there is method to the madness.
// There can be multiple user servers on the same database,
// and each can have multiple messaging servers. So, we send
// it to all known user servers, who send it to all known
// message servers. That way, we should be able to finally
// update presence to all regions and thereby all friends
//
m_userManager.HandleRegionShutdown(regionID);
m_messagesService.TellMessageServersAboutRegionShutdown(regionID);
}
#endregion
public string Name
{
get { return "UserServerEventDispatchModule"; }
}
}
}

View File

@ -36,30 +36,32 @@ using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Servers;
using OpenSim.Grid.Framework;
using OpenSim.Grid.GridServer;
namespace OpenSim.Grid.UserServer.Modules
{
public class UserServerFriendsModule
public class UserServerFriendsModule : IGridServiceModule
{
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private UserDataBaseService m_userDataBaseService;
private BaseHttpServer m_httpServer;
private IGridServiceCore m_core;
public UserServerFriendsModule(UserDataBaseService userDataBaseService)
public UserServerFriendsModule()
{
m_userDataBaseService = userDataBaseService;
}
public void Initialise(IGridServiceCore core)
{
m_core = core;
}
public void PostInitialise()
{
if (!m_core.TryGet<UserDataBaseService>(out m_userDataBaseService))
m_log.Error("[UserServerFriendsModule]: Failed to fetch database plugin");
}
public void RegisterHandlers(BaseHttpServer httpServer)
@ -170,5 +172,14 @@ namespace OpenSim.Grid.UserServer.Modules
return FriendListItemListtoXmlRPCResponse(returndata);
}
public void Close()
{
}
public string Name
{
get { return "UserServerFriendsModule"; }
}
}
}
}

View File

@ -0,0 +1,170 @@
/*
* 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.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using log4net;
using log4net.Config;
using OpenMetaverse;
using OpenSim.Data;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Statistics;
using OpenSim.Grid.Communications.OGS1;
using OpenSim.Grid.Framework;
using OpenSim.Grid.GridServer;
namespace OpenSim.Grid.UserServer.Modules
{
public class UserServerPlugin : IGridPlugin
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected UserConfig m_cfg;
protected UserDataBaseService m_userDataBaseService;
public UserLoginService m_loginService;
protected BaseHttpServer m_httpServer;
protected IGridServiceCore m_core;
protected ConsoleBase m_console;
protected List<IGridServiceModule> m_modules;
public UserServerPlugin()
{
}
#region IGridPlugin Members
public void Initialise(GridServerBase gridServer)
{
Initialise(gridServer.HttpServer, gridServer, gridServer.UConfig);
}
public void PostInitialise()
{
}
#endregion
public void Initialise(BaseHttpServer httpServer, IGridServiceCore core, UserConfig config)
{
m_httpServer = httpServer;
m_core = core;
m_cfg = config;
m_console = MainConsole.Instance;
IInterServiceInventoryServices inventoryService = StartupCoreComponents();
//setup services/modules
StartupUserServerModules();
StartOtherComponents(inventoryService);
}
protected virtual IInterServiceInventoryServices StartupCoreComponents()
{
m_core.RegisterInterface<ConsoleBase>(m_console);
m_core.RegisterInterface<UserConfig>(m_cfg);
//Should be in modules?
IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(m_cfg.InventoryUrl);
// IRegionProfileRouter regionProfileService = new RegionProfileServiceProxy();
m_core.RegisterInterface<IInterServiceInventoryServices>(inventoryService);
// RegisterInterface<IRegionProfileRouter>(regionProfileService);
return inventoryService;
}
/// <summary>
/// Start up the user manager
/// </summary>
/// <param name="inventoryService"></param>
protected virtual void StartupUserServerModules()
{
m_log.Info("[STARTUP]: Establishing data connection");
//setup database access service, for now this has to be created before the other modules.
m_userDataBaseService = new UserDataBaseService();
m_userDataBaseService.Initialise(m_core);
}
protected virtual void StartOtherComponents(IInterServiceInventoryServices inventoryService)
{
m_loginService = new UserLoginService(
m_userDataBaseService, inventoryService, new LibraryRootFolder(m_cfg.LibraryXmlfile), m_cfg, m_cfg.DefaultStartupMsg, new RegionProfileServiceProxy());
//
// Get the minimum defaultLevel to access to the grid
//
m_loginService.setloginlevel((int)m_cfg.DefaultUserLevel);
m_core.RegisterInterface<UserLoginService>(m_loginService); //TODO: should be done in the login service
m_loginService.RegisterHandlers(m_httpServer, m_cfg.EnableLLSDLogin, true);
}
#region IPlugin Members
public string Version
{
get { return "0.0"; }
}
public string Name
{
get { return "UserServerPlugin"; }
}
public void Initialise()
{
}
#endregion
#region IDisposable Members
public void Dispose()
{
}
#endregion
}
}

View File

@ -1,270 +0,0 @@
/*
* 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.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using log4net;
using log4net.Config;
using OpenMetaverse;
using OpenSim.Data;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Statistics;
using OpenSim.Grid.Communications.OGS1;
using OpenSim.Grid.Framework;
using OpenSim.Grid.UserServer.Modules;
namespace OpenSim.Grid.UserServer
{
/// <summary>
/// Grid user server main class
/// </summary>
public class OpenUser_Main : BaseOpenSimServer, IGridServiceCore
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected UserConfig Cfg;
protected UserDataBaseService m_userDataBaseService;
public UserManager m_userManager;
protected UserServerAvatarAppearanceModule m_avatarAppearanceModule;
protected UserServerFriendsModule m_friendsModule;
public UserLoginService m_loginService;
public MessageServersConnector m_messagesService;
protected GridInfoServiceModule m_gridInfoService;
protected UserServerCommandModule m_consoleCommandModule;
protected UserServerEventDispatchModule m_eventDispatcher;
public static void Main(string[] args)
{
XmlConfigurator.Configure();
m_log.Info("Launching UserServer...");
OpenUser_Main userserver = new OpenUser_Main();
userserver.Startup();
userserver.Work();
}
public OpenUser_Main()
{
m_console = new ConsoleBase("User");
MainConsole.Instance = m_console;
}
public void Work()
{
m_console.Notice("Enter help for a list of commands\n");
while (true)
{
m_console.Prompt();
}
}
protected override void StartupSpecific()
{
IInterServiceInventoryServices inventoryService = StartupCoreComponents();
m_stats = StatsManager.StartCollectingUserStats();
//setup services/modules
StartupUserServerModules();
StartOtherComponents(inventoryService);
//PostInitialise the modules
PostInitialiseModules();
//register http handlers and start http server
m_log.Info("[STARTUP]: Starting HTTP process");
RegisterHttpHandlers();
m_httpServer.Start();
base.StartupSpecific();
}
protected virtual IInterServiceInventoryServices StartupCoreComponents()
{
Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml")));
m_httpServer = new BaseHttpServer(Cfg.HttpPort);
RegisterInterface<ConsoleBase>(m_console);
RegisterInterface<UserConfig>(Cfg);
//Should be in modules?
IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl);
// IRegionProfileRouter regionProfileService = new RegionProfileServiceProxy();
RegisterInterface<IInterServiceInventoryServices>(inventoryService);
// RegisterInterface<IRegionProfileRouter>(regionProfileService);
return inventoryService;
}
/// <summary>
/// Start up the user manager
/// </summary>
/// <param name="inventoryService"></param>
protected virtual void StartupUserServerModules()
{
m_log.Info("[STARTUP]: Establishing data connection");
//setup database access service, for now this has to be created before the other modules.
m_userDataBaseService = new UserDataBaseService();
m_userDataBaseService.Initialise(this);
//TODO: change these modules so they fetch the databaseService class in the PostInitialise method
m_userManager = new UserManager(m_userDataBaseService);
m_userManager.Initialise(this);
m_avatarAppearanceModule = new UserServerAvatarAppearanceModule(m_userDataBaseService);
m_avatarAppearanceModule.Initialise(this);
m_friendsModule = new UserServerFriendsModule(m_userDataBaseService);
m_friendsModule.Initialise(this);
m_consoleCommandModule = new UserServerCommandModule();
m_consoleCommandModule.Initialise(this);
m_messagesService = new MessageServersConnector();
m_messagesService.Initialise(this);
m_gridInfoService = new GridInfoServiceModule();
m_gridInfoService.Initialise(this);
}
protected virtual void StartOtherComponents(IInterServiceInventoryServices inventoryService)
{
StartupLoginService(inventoryService);
//
// Get the minimum defaultLevel to access to the grid
//
m_loginService.setloginlevel((int)Cfg.DefaultUserLevel);
RegisterInterface<UserLoginService>(m_loginService); //TODO: should be done in the login service
m_eventDispatcher = new UserServerEventDispatchModule(m_userManager, m_messagesService, m_loginService);
m_eventDispatcher.Initialise(this);
}
/// <summary>
/// Start up the login service
/// </summary>
/// <param name="inventoryService"></param>
protected virtual void StartupLoginService(IInterServiceInventoryServices inventoryService)
{
m_loginService = new UserLoginService(
m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy());
}
protected virtual void PostInitialiseModules()
{
m_consoleCommandModule.PostInitialise(); //it will register its Console command handlers in here
m_userDataBaseService.PostInitialise();
m_messagesService.PostInitialise();
m_eventDispatcher.PostInitialise(); //it will register event handlers in here
m_gridInfoService.PostInitialise();
m_userManager.PostInitialise();
m_avatarAppearanceModule.PostInitialise();
m_friendsModule.PostInitialise();
}
protected virtual void RegisterHttpHandlers()
{
m_loginService.RegisterHandlers(m_httpServer, Cfg.EnableLLSDLogin, true);
m_userManager.RegisterHandlers(m_httpServer);
m_friendsModule.RegisterHandlers(m_httpServer);
m_avatarAppearanceModule.RegisterHandlers(m_httpServer);
m_messagesService.RegisterHandlers(m_httpServer);
m_gridInfoService.RegisterHandlers(m_httpServer);
}
public override void ShutdownSpecific()
{
m_eventDispatcher.Close();
}
#region IUGAIMCore
protected Dictionary<Type, object> m_moduleInterfaces = new Dictionary<Type, object>();
/// <summary>
/// Register an Module interface.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="iface"></param>
public void RegisterInterface<T>(T iface)
{
lock (m_moduleInterfaces)
{
if (!m_moduleInterfaces.ContainsKey(typeof(T)))
{
m_moduleInterfaces.Add(typeof(T), iface);
}
}
}
public bool TryGet<T>(out T iface)
{
if (m_moduleInterfaces.ContainsKey(typeof(T)))
{
iface = (T)m_moduleInterfaces[typeof(T)];
return true;
}
iface = default(T);
return false;
}
public T Get<T>()
{
return (T)m_moduleInterfaces[typeof(T)];
}
public BaseHttpServer GetHttpServer()
{
return m_httpServer;
}
#endregion
public void TestResponse(List<InventoryFolderBase> resp)
{
m_console.Notice("response got");
}
}
}

View File

@ -1,63 +0,0 @@
/*
* 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.
*/
using System.Reflection;
using System.Runtime.InteropServices;
// General information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly : AssemblyTitle("OGS-UserServer")]
[assembly : AssemblyDescription("")]
[assembly : AssemblyConfiguration("")]
[assembly : AssemblyCompany("http://opensimulator.org")]
[assembly : AssemblyProduct("OGS-UserServer")]
[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")]
[assembly : AssemblyTrademark("")]
[assembly : AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly : ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly : Guid("e266513a-090b-4d38-80f6-8599eef68c8c")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly : AssemblyVersion("0.6.3.*")]
[assembly : AssemblyFileVersion("1.0.0.0")]

View File

@ -93,8 +93,11 @@ namespace OpenSim
string[] fileEntries = Directory.GetFiles(iniDirName);
foreach (string filePath in fileEntries)
{
// m_log.InfoFormat("reading ini file < {0} > from config dir", filePath);
ReadConfig(Path.GetFileName(filePath), filePath, m_config, false);
if (Path.GetExtension(filePath).ToLower() == ".ini")
{
// m_log.InfoFormat("reading ini file < {0} > from config dir", filePath);
ReadConfig(Path.GetFileName(filePath), filePath, m_config, false);
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

2
bin/OpenSim.Grid.ini Normal file
View File

@ -0,0 +1,2 @@
[Startup]
HttpPort=8051

View File

@ -0,0 +1,30 @@
[Startup]
HttpPort = 8001
LoadPlugins = "GridServerPlugin,UserServerPlugin,GridModuleLoaderPlugin"
[UserServerConfig]
DatabaseProvider = "OpenSim.Data.MySql.dll"
DatabaseConnect = ""
DefaultStartupMsg = "Welcome to opensim"
DefaultX = 1000
DefaultY = 1000
GridRecvKey = "key"
GridSendKey = "key"
HttpSSL = false
DefaultUserLevel = 0
LibraryXmlfile = ".\inventory\Libraries.xml"
InventoryUrl = "http://127.0.0.1:8004/"
GridServerURL = "http://127.0.0.1:8001/"
EnableLLSDLogin = true
[GridServerConfig]
DatabaseProvider = "OpenSim.Data.MySql.dll"
DatabaseConnect = ""
DefaultAssetServer = "http://127.0.0.1:8003/"
DefaultUserServer = "http://127.0.0.1:8001/"
SimRecvKey = "key"
SimSendKey = "key"
UserRecvKey = "key"
UserSendKey = "key"
AssetRecvKey = "key"
AssetSendKey = "key"

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -742,6 +742,7 @@
<Reference name="OpenMetaverse.dll"/>
<Reference name="XMLRPC.dll"/>
<Reference name="log4net.dll"/>
<Reference name="Nini.dll" />
<Files>
<Match pattern="*.cs" recurse="true"/>
@ -783,6 +784,32 @@
</Files>
</Project>
<Project name="OpenSim.Grid.GridServer.ModuleLoader" path="OpenSim/Grid/GridServer.ModuleLoader" type="Library">
<Configuration name="Debug">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<ReferencePath>../../../bin/</ReferencePath>
<Reference name="System"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Grid.Framework"/>
<Reference name="OpenSim.Grid.GridServer"/>
<Reference name="log4net.dll"/>
<Files>
<Match pattern="*.cs" recurse="true"/>
<Match pattern="*.addin.xml" path="Resources" buildAction="EmbeddedResource" recurse="true"/>
</Files>
</Project>
<Project name="OpenSim.Grid.AssetServer" path="OpenSim/Grid/AssetServer" type="Exe">
<Configuration name="Debug">
@ -955,6 +982,7 @@
<Reference name="OpenSim.Framework.Statistics"/>
<Reference name="OpenSim.Grid.Framework"/>
<Reference name="OpenSim.Grid.Communications.OGS1"/>
<Reference name="OpenSim.Grid.GridServer"/>
<Reference name="OpenMetaverseTypes.dll"/>
<Reference name="OpenMetaverse.StructuredData.dll"/>
<Reference name="XMLRPC.dll"/>
@ -963,47 +991,11 @@
<Files>
<Match pattern="*.cs" recurse="true"/>
<Match path="Resources" pattern="*.addin.xml" buildAction="EmbeddedResource" recurse="true" />
</Files>
</Project>
<Project name="OpenSim.Grid.UserServer" path="OpenSim/Grid/UserServer" type="Exe">
<Configuration name="Debug">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<ReferencePath>../../../bin/</ReferencePath>
<Reference name="System"/>
<Reference name="System.Data"/>
<Reference name="System.Xml"/>
<Reference name="System.Web"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Communications"/>
<Reference name="OpenSim.Data"/>
<Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Framework.Statistics"/>
<Reference name="OpenSim.Grid.Communications.OGS1"/>
<Reference name="OpenSim.Grid.Framework"/>
<Reference name="OpenSim.Grid.UserServer.Modules"/>
<Reference name="OpenMetaverseTypes.dll"/>
<Reference name="OpenMetaverse.StructuredData.dll"/>
<Reference name="XMLRPC.dll"/>
<Reference name="log4net.dll"/>
<Reference name="DotNetOpenId.dll"/>
<Files>
<Match pattern="*.cs" recurse="true"/>
</Files>
</Project>
<Project name="OpenSim.Grid.InventoryServer" path="OpenSim/Grid/InventoryServer" type="Exe">
<Configuration name="Debug">
<Options>