From dc2acaa8a887e986644480237910308701c84c1a Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 16 May 2007 21:10:45 +0000 Subject: [PATCH] Let stuff be broken! --- OpenGrid.Framework.Data.DB4o/DB4oUserData.cs | 19 +++- .../OpenGrid.Framework.Data.MSSQL.csproj | 35 +++--- .../MySQLUserData.cs | 68 ++++++++++++ .../OpenGrid.Framework.Data.MySQL.csproj | 38 ++++--- OpenGrid.Framework.Data/UserData.cs | 73 ++++++++++++- OpenGrid.Framework.Data/UserProfileData.cs | 1 + OpenGridServices.GridServer/GridManager.cs | 7 +- OpenGridServices.UserServer/Main.cs | 6 ++ .../OpenGridServices.UserServer.csproj | 48 +++++---- OpenGridServices.UserServer/UserManager.cs | 102 ++++++++++++++++++ OpenSim.Framework/UserProfileManager.cs | 6 +- prebuild.xml | 5 +- 12 files changed, 349 insertions(+), 59 deletions(-) create mode 100644 OpenGrid.Framework.Data.MySQL/MySQLUserData.cs create mode 100644 OpenGridServices.UserServer/UserManager.cs diff --git a/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs b/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs index c21d7e22d2..7dd4c51393 100644 --- a/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs +++ b/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs @@ -8,7 +8,12 @@ namespace OpenGrid.Framework.Data.DB4o { public class DB4oUserData : IUserData { - DB4oUserManager manager = new DB4oUserManager("userprofiles.yap"); + DB4oUserManager manager; + + public void Initialise() + { + manager = new DB4oUserManager("userprofiles.yap"); + } public UserProfileData getUserByUUID(LLUUID uuid) { @@ -33,7 +38,7 @@ namespace OpenGrid.Framework.Data.DB4o } public UserAgentData getAgentByUUID(LLUUID uuid) - { + { try { return getUserByUUID(uuid).currentAgent; @@ -71,5 +76,15 @@ namespace OpenGrid.Framework.Data.DB4o return true; } + + public string getName() + { + return "DB4o Userdata"; + } + + public string getVersion() + { + return "0.1"; + } } } diff --git a/OpenGrid.Framework.Data.MSSQL/OpenGrid.Framework.Data.MSSQL.csproj b/OpenGrid.Framework.Data.MSSQL/OpenGrid.Framework.Data.MSSQL.csproj index efb6a320d6..e6d4b49ad2 100644 --- a/OpenGrid.Framework.Data.MSSQL/OpenGrid.Framework.Data.MSSQL.csproj +++ b/OpenGrid.Framework.Data.MSSQL/OpenGrid.Framework.Data.MSSQL.csproj @@ -1,4 +1,4 @@ - + Local 8.0.50727 @@ -6,7 +6,8 @@ {0A563AC1-0000-0000-0000-000000000000} Debug AnyCPU - + + OpenGrid.Framework.Data.MSSQL @@ -15,9 +16,11 @@ IE50 false Library - + + OpenGrid.Framework.Data.MSSQL - + + @@ -28,7 +31,8 @@ TRACE;DEBUG - + + True 4096 False @@ -37,7 +41,8 @@ False False 4 - + + False @@ -46,7 +51,8 @@ TRACE - + + False 4096 True @@ -55,22 +61,23 @@ False False 4 - + + - + System.dll False - + System.Xml.dll False - + System.Data.dll False - + ..\bin\libsecondlife.dll False @@ -80,7 +87,7 @@ OpenGrid.Framework.Data {62CDF671-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False @@ -101,4 +108,4 @@ - + \ No newline at end of file diff --git a/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs b/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs new file mode 100644 index 0000000000..4f35a59478 --- /dev/null +++ b/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenGrid.Framework.Data; +using libsecondlife; + +namespace OpenGrid.Framework.Data.MySQL +{ + class MySQLUserData : IUserData + { + public MySQLManager manager; + + public void Initialise() + { + manager = new MySQLManager("host", "database", "user", "password", "false"); + } + + public UserProfileData getUserByName(string name) + { + return getUserByName(name.Split(' ')[0], name.Split(' ')[1]); + } + + public UserProfileData getUserByName(string user, string last) + { + return new UserProfileData(); + } + + public UserProfileData getUserByUUID(LLUUID uuid) + { + return new UserProfileData(); + } + + public UserAgentData getAgentByName(string name) + { + return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]); + } + + public UserAgentData getAgentByName(string user, string last) + { + return new UserAgentData(); + } + + public UserAgentData getAgentByUUID(LLUUID uuid) + { + return new UserAgentData(); + } + + public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount) + { + return false; + } + + public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item) + { + return false; + } + + public string getName() + { + return "MySQL Userdata Interface"; + } + + public string getVersion() + { + return "0.1"; + } + } +} diff --git a/OpenGrid.Framework.Data.MySQL/OpenGrid.Framework.Data.MySQL.csproj b/OpenGrid.Framework.Data.MySQL/OpenGrid.Framework.Data.MySQL.csproj index d9ee2122e0..67cdda62e0 100644 --- a/OpenGrid.Framework.Data.MySQL/OpenGrid.Framework.Data.MySQL.csproj +++ b/OpenGrid.Framework.Data.MySQL/OpenGrid.Framework.Data.MySQL.csproj @@ -1,4 +1,4 @@ - + Local 8.0.50727 @@ -6,7 +6,8 @@ {0F3C3AC1-0000-0000-0000-000000000000} Debug AnyCPU - + + OpenGrid.Framework.Data.MySQL @@ -15,9 +16,11 @@ IE50 false Library - + + OpenGrid.Framework.Data.MySQL - + + @@ -28,7 +31,8 @@ TRACE;DEBUG - + + True 4096 False @@ -37,7 +41,8 @@ False False 4 - + + False @@ -46,7 +51,8 @@ TRACE - + + False 4096 True @@ -55,26 +61,27 @@ False False 4 - + + - + System.dll False - + System.Xml.dll False - + System.Data.dll False - + ..\bin\libsecondlife.dll False - + ..\bin\MySql.Data.dll False @@ -84,7 +91,7 @@ OpenGrid.Framework.Data {62CDF671-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False @@ -94,6 +101,7 @@ Code + Code @@ -105,4 +113,4 @@ - + \ No newline at end of file diff --git a/OpenGrid.Framework.Data/UserData.cs b/OpenGrid.Framework.Data/UserData.cs index 6b4f2baa08..1b37957e3c 100644 --- a/OpenGrid.Framework.Data/UserData.cs +++ b/OpenGrid.Framework.Data/UserData.cs @@ -7,18 +7,83 @@ namespace OpenGrid.Framework.Data { public interface IUserData { - // Retrieval - // User Profiles + /// + /// Returns a user profile from a database via their UUID + /// + /// The accounts UUID + /// The user data profile UserProfileData getUserByUUID(LLUUID user); + + /// + /// Returns a users profile by searching their username + /// + /// The users username + /// The user data profile UserProfileData getUserByName(string name); + + /// + /// Returns a users profile by searching their username parts + /// + /// Account firstname + /// Account lastname + /// The user data profile UserProfileData getUserByName(string fname, string lname); - // User Agents + + /// + /// Returns the current agent for a user searching by it's UUID + /// + /// The users UUID + /// The current agent session UserAgentData getAgentByUUID(LLUUID user); + + /// + /// Returns the current session agent for a user searching by username + /// + /// The users account name + /// The current agent session UserAgentData getAgentByName(string name); + + /// + /// Returns the current session agent for a user searching by username parts + /// + /// The users first account name + /// The users account surname + /// The current agent session UserAgentData getAgentByName(string fname, string lname); - // Transactional + /// + /// Attempts to move currency units between accounts (NOT RELIABLE / TRUSTWORTHY. DONT TRY RUN YOUR OWN CURRENCY EXCHANGE WITH REAL VALUES) + /// + /// The account to transfer from + /// The account to transfer to + /// The amount to transfer + /// Successful? bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount); + + /// + /// Attempts to move inventory between accounts, if inventory is copyable it will be copied into the target account. + /// + /// User to transfer from + /// User to transfer to + /// Specified inventory item + /// Successful? bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID inventory); + + /// + /// Returns the plugin version + /// + /// Plugin version in MAJOR.MINOR.REVISION.BUILD format + string getVersion(); + + /// + /// Returns the plugin name + /// + /// Plugin name, eg MySQL User Provider + string getName(); + + /// + /// Initialises the plugin (artificial constructor) + /// + void Initialise(); } } diff --git a/OpenGrid.Framework.Data/UserProfileData.cs b/OpenGrid.Framework.Data/UserProfileData.cs index 8d72c6baf0..3d8eec4a9d 100644 --- a/OpenGrid.Framework.Data/UserProfileData.cs +++ b/OpenGrid.Framework.Data/UserProfileData.cs @@ -12,6 +12,7 @@ namespace OpenGrid.Framework.Data public string surname; // The users surname (can be used to indicate user class - eg 'Test User' or 'Test Admin') public string passwordHash; // Hash of the users password + public string passwordSalt; // Salt for the users password public ulong homeRegion; // RegionHandle of home public LLVector3 homeLocation; // Home Location inside the sim diff --git a/OpenGridServices.GridServer/GridManager.cs b/OpenGridServices.GridServer/GridManager.cs index db864da1d6..1fc7c317b9 100644 --- a/OpenGridServices.GridServer/GridManager.cs +++ b/OpenGridServices.GridServer/GridManager.cs @@ -383,6 +383,11 @@ namespace OpenGridServices.GridServer TheSim.serverURI = "http://" + TheSim.serverIP + ":" + TheSim.serverPort + "/"; + if (TheSim.serverIP.StartsWith("172.16") || TheSim.serverIP.StartsWith("192.168") || TheSim.serverIP.StartsWith("10.") || TheSim.serverIP.StartsWith("0.") || TheSim.serverIP.StartsWith("255.")) + { + return "ERROR! Servers must register with public addresses."; + } + try { OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Attempting to add a new region to the grid - " + _plugins.Count + " storage provider(s) registered."); @@ -402,7 +407,7 @@ namespace OpenGridServices.GridServer } catch (Exception e) { - return "ERROR! could not save to database! (" + e.ToString() + ")"; + return "ERROR! Could not save to database! (" + e.ToString() + ")"; } } diff --git a/OpenGridServices.UserServer/Main.cs b/OpenGridServices.UserServer/Main.cs index ed7b7688dc..1c6ad8ce58 100644 --- a/OpenGridServices.UserServer/Main.cs +++ b/OpenGridServices.UserServer/Main.cs @@ -50,6 +50,8 @@ namespace OpenGridServices.UserServer private string ConfigDll = "OpenUser.Config.UserConfigDb4o.dll"; private UserConfig Cfg; + public UserManager m_userManager; // Replaces below. + private UserProfileManager m_userProfileManager; public Dictionary UserSessions = new Dictionary(); @@ -62,6 +64,7 @@ namespace OpenGridServices.UserServer Console.WriteLine("Starting...\n"); OpenUser_Main userserver = new OpenUser_Main(); + userserver.Startup(); userserver.Work(); } @@ -88,6 +91,9 @@ namespace OpenGridServices.UserServer Cfg = this.LoadConfigDll(this.ConfigDll); Cfg.InitConfig(); + MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Establishing data connection"); + m_userManager = new UserManager(); + MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Creating user profile manager"); m_userProfileManager = new UserProfileManager(); m_userProfileManager.InitUserProfiles(); diff --git a/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj b/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj index 888b62dc92..75642b3511 100644 --- a/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj +++ b/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj @@ -1,4 +1,4 @@ - + Local 8.0.50727 @@ -6,7 +6,8 @@ {66591469-0000-0000-0000-000000000000} Debug AnyCPU - + + OpenGridServices.UserServer @@ -15,9 +16,11 @@ IE50 false Exe - + + OpenGridServices.UserServer - + + @@ -28,7 +31,8 @@ TRACE;DEBUG - + + True 4096 False @@ -37,7 +41,8 @@ False False 4 - + + False @@ -46,7 +51,8 @@ TRACE - + + False 4096 True @@ -55,54 +61,59 @@ False False 4 - + + - + System.dll False - + System.Data.dll False - + System.Xml.dll False - + ..\bin\libsecondlife.dll False - + ..\bin\Db4objects.Db4o.dll False + + {62CDF671-0000-0000-0000-000000000000} + OpenGrid.Framework.Data + OpenSim.Framework {8ACA2445-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False OpenSim.Framework.Console {A7CD0630-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False OpenSim.Servers {8BB20F0A-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False XMLRPC {8E81D43C-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False @@ -112,6 +123,7 @@ Code + @@ -120,4 +132,4 @@ - + \ No newline at end of file diff --git a/OpenGridServices.UserServer/UserManager.cs b/OpenGridServices.UserServer/UserManager.cs new file mode 100644 index 0000000000..7473685cb1 --- /dev/null +++ b/OpenGridServices.UserServer/UserManager.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenGrid.Framework.Data; +using libsecondlife; +using System.Reflection; + +using System.Xml; +using Nwc.XmlRpc; +using OpenSim.Framework.Sims; +using OpenSim.Framework.Inventory; +using OpenSim.Framework.Utilities; + +namespace OpenGridServices.UserServer +{ + public class UserManager + { + Dictionary _plugins = new Dictionary(); + + /// + /// Adds a new user server plugin - user servers will be requested in the order they were loaded. + /// + /// The filename to the user server plugin DLL + public void AddPlugin(string FileName) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Storage: Attempting to load " + FileName); + Assembly pluginAssembly = Assembly.LoadFrom(FileName); + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Storage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("IUserData", true); + + if (typeInterface != null) + { + IUserData plug = (IUserData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + plug.Initialise(); + this._plugins.Add(plug.getName(), plug); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Storage: Added IUserData Interface"); + } + + typeInterface = null; + } + } + + pluginAssembly = null; + } + + public UserProfileData getUserProfile(LLUUID uuid) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + return plugin.Value.getUserByUUID(uuid); + } + catch (Exception e) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + return null; + } + + public UserProfileData getUserProfile(string name) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + return plugin.Value.getUserByName(name); + } + catch (Exception e) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + return null; + } + + public UserProfileData getUserProfile(string fname, string lname) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + return plugin.Value.getUserByName(fname,lname); + } + catch (Exception e) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + return null; + } + } +} diff --git a/OpenSim.Framework/UserProfileManager.cs b/OpenSim.Framework/UserProfileManager.cs index 5752f8cbf5..18b3513a79 100644 --- a/OpenSim.Framework/UserProfileManager.cs +++ b/OpenSim.Framework/UserProfileManager.cs @@ -259,9 +259,9 @@ namespace OpenSim.Framework.User SimParams["lastname"] = theUser.lastname; SimParams["agent_id"] = theUser.UUID.ToString(); SimParams["circuit_code"] = (Int32)circode; - SimParams["startpos_x"] = theUser.homepos.X.ToString(); - SimParams["startpos_y"] = theUser.homepos.Y.ToString(); - SimParams["startpos_z"] = theUser.homepos.Z.ToString(); + SimParams["startpos_x"] = theUser.homepos.X.ToString(); + SimParams["startpos_y"] = theUser.homepos.Y.ToString(); + SimParams["startpos_z"] = theUser.homepos.Z.ToString(); ArrayList SendParams = new ArrayList(); SendParams.Add(SimParams); diff --git a/prebuild.xml b/prebuild.xml index 009721a5a6..ae19e7a5ac 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -494,8 +494,9 @@ - - + + +