From 3ac43d012031cae8189111d96b7350b3e931836c Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Mon, 24 Sep 2007 23:58:43 +0000 Subject: * Removed some more fields from CommunicationsLocal * added OnLoginToRegion to CommunicationsLocal --- .../Communications/Local/CommunicationsLocal.cs | 35 +-- .../Communications/Local/LocalBackEndServices.cs | 6 +- .../Communications/Local/LocalLoginService.cs | 339 +++++++++++---------- .../Region/Communications/OGS1/OGS1GridServices.cs | 22 +- .../Communications/OGS1/OGS1InventoryService.cs | 2 +- 5 files changed, 196 insertions(+), 208 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs index eed21a4..a00b35f 100644 --- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs +++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs @@ -38,43 +38,26 @@ using OpenSim.Framework.Utilities; namespace OpenSim.Region.Communications.Local { public class CommunicationsLocal : CommunicationsManager - { - public LocalBackEndServices InstanceServices; - - public LocalLoginService LoginServices; - - protected LocalSettings m_settings; - - protected CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache) - : base(serversInfo, httpServer, assetCache) - { - - } - + { public CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache, LocalSettings settings) : base(serversInfo, httpServer, assetCache) { - m_settings = settings; - LocalInventoryService inventoryService = new LocalInventoryService(); - inventoryService.AddPlugin(m_settings.InventoryPlugin); + inventoryService.AddPlugin(settings.InventoryPlugin); m_inventoryService = inventoryService; LocalUserServices userService = new LocalUserServices(this, serversInfo); - userService.AddPlugin(m_settings.UserDatabasePlugin); + userService.AddPlugin(settings.UserDatabasePlugin); m_userService = userService; - InstanceServices = new LocalBackEndServices(); - m_gridService = InstanceServices; - m_interRegion = InstanceServices; + LocalBackEndServices backendService = new LocalBackEndServices(); + m_gridService = backendService; + m_interRegion = backendService; - LoginServices = new LocalLoginService(userService, m_settings.WelcomeMessage, this, serversInfo, m_settings.AccountAuthentication); - httpServer.AddXmlRPCHandler("login_to_simulator", LoginServices.XmlRpcLoginMethod); - } + LocalLoginService loginService = new LocalLoginService(userService, settings.WelcomeMessage, this, serversInfo, settings.AccountAuthentication); + loginService.OnLoginToRegion += backendService.AddNewSession; - internal void InformRegionOfLogin(ulong regionHandle, Login login) - { - this.InstanceServices.AddNewSession(regionHandle, login); + httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod); } public void doCreate(string[] cmmdParams) diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs index 706be09..3e23963 100644 --- a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs +++ b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs @@ -187,7 +187,7 @@ namespace OpenSim.Region.Communications.Local /// /// /// - public bool AddNewSession(ulong regionHandle, Login loginData) + public void AddNewSession(ulong regionHandle, Login loginData) { AgentCircuitData agent = new AgentCircuitData(); agent.AgentID = loginData.Agent; @@ -204,11 +204,7 @@ namespace OpenSim.Region.Communications.Local if (this.regionHosts.ContainsKey(regionHandle)) { this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agent); - return true; } - - // region not found - return false; } } } diff --git a/OpenSim/Region/Communications/Local/LocalLoginService.cs b/OpenSim/Region/Communications/Local/LocalLoginService.cs index ed1858d..ab8e397 100644 --- a/OpenSim/Region/Communications/Local/LocalLoginService.cs +++ b/OpenSim/Region/Communications/Local/LocalLoginService.cs @@ -1,166 +1,173 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using libsecondlife; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Data; -using OpenSim.Framework.Types; -using OpenSim.Framework.UserManagement; -using OpenSim.Framework.Utilities; -using OpenSim.Framework.Inventory; - -namespace OpenSim.Region.Communications.Local -{ - public class LocalLoginService : LoginService - { - private CommunicationsLocal m_Parent; - - private NetworkServersInfo serversInfo; - private uint defaultHomeX; - private uint defaultHomeY; - private bool authUsers = false; - - public LocalLoginService(UserManagerBase userManager, string welcomeMess, CommunicationsLocal parent, NetworkServersInfo serversInfo, bool authenticate) - : base(userManager, welcomeMess) - { - m_Parent = parent; - this.serversInfo = serversInfo; - defaultHomeX = this.serversInfo.DefaultHomeLocX; - defaultHomeY = this.serversInfo.DefaultHomeLocY; - this.authUsers = authenticate; - } - - - public override UserProfileData GetTheUser(string firstname, string lastname) - { - UserProfileData profile = this.m_userManager.GetUserProfile(firstname, lastname); - if (profile != null) - { - - return profile; - } - - if (!authUsers) - { - //no current user account so make one - Console.WriteLine("No User account found so creating a new one "); - this.m_userManager.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY); - - profile = this.m_userManager.GetUserProfile(firstname, lastname); - if (profile != null) - { - m_Parent.InventoryService.CreateNewUserInventory(profile.UUID); - } - - return profile; - } - return null; - } - - public override bool AuthenticateUser(UserProfileData profile, string password) - { - if (!authUsers) - { - //for now we will accept any password in sandbox mode - Console.WriteLine("authorising user"); - return true; - } - else - { - Console.WriteLine("Authenticating " + profile.username + " " + profile.surname); - - password = password.Remove(0, 3); //remove $1$ - - string s = Util.Md5Hash(password + ":" + profile.passwordSalt); - - return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); - } - } - - public override void CustomiseResponse(LoginResponse response, UserProfileData theUser) - { - ulong currentRegion = theUser.currentAgent.currentHandle; - RegionInfo reg = m_Parent.GridService.RequestNeighbourInfo(currentRegion); - - if (reg != null) - { - response.Home = "{'region_handle':[r" + (reg.RegionLocX * 256).ToString() + ",r" + (reg.RegionLocY * 256).ToString() + "], " + - "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + - "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}"; - string capsPath = Util.GetRandomCapsPath(); - response.SimAddress = reg.ExternalEndPoint.Address.ToString(); - response.SimPort = (Int32)reg.ExternalEndPoint.Port; - response.RegionX = reg.RegionLocX; - response.RegionY = reg.RegionLocY; - - response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CAPS/" + capsPath + "0000/"; - // response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CapsSeed/" + capsPath + "0000/"; - theUser.currentAgent.currentRegion = reg.SimUUID; - theUser.currentAgent.currentHandle = reg.RegionHandle; - - Login _login = new Login(); - //copy data to login object - _login.First = response.Firstname; - _login.Last = response.Lastname; - _login.Agent = response.AgentID; - _login.Session = response.SessionID; - _login.SecureSession = response.SecureSessionID; - _login.CircuitCode = (uint)response.CircuitCode; - _login.CapsPath = capsPath; - - m_Parent.InformRegionOfLogin(currentRegion, _login); - } - else - { - Console.WriteLine("not found region " + currentRegion); - } - - } - - protected override InventoryData CreateInventoryData(LLUUID userID) - { - List folders = m_Parent.InventoryService.RequestFirstLevelFolders(userID); - if (folders.Count > 0) - { - LLUUID rootID = LLUUID.Zero; - ArrayList AgentInventoryArray = new ArrayList(); - Hashtable TempHash; - foreach (InventoryFolderBase InvFolder in folders) - { - if (InvFolder.parentID == LLUUID.Zero) - { - rootID = InvFolder.folderID; - } - TempHash = new Hashtable(); - TempHash["name"] = InvFolder.name; - TempHash["parent_id"] = InvFolder.parentID.ToStringHyphenated(); - TempHash["version"] = (Int32)InvFolder.version; - TempHash["type_default"] = (Int32)InvFolder.type; - TempHash["folder_id"] = InvFolder.folderID.ToStringHyphenated(); - AgentInventoryArray.Add(TempHash); - } - return new InventoryData(AgentInventoryArray, rootID); - } - else - { - AgentInventory userInventory = new AgentInventory(); - userInventory.CreateRootFolder(userID, false); - - ArrayList AgentInventoryArray = new ArrayList(); - Hashtable TempHash; - foreach (OpenSim.Framework.Inventory.InventoryFolder InvFolder in userInventory.InventoryFolders.Values) - { - TempHash = new Hashtable(); - TempHash["name"] = InvFolder.FolderName; - TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); - TempHash["version"] = (Int32)InvFolder.Version; - TempHash["type_default"] = (Int32)InvFolder.DefaultType; - TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); - AgentInventoryArray.Add(TempHash); - } - - return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); - } - } - } -} +using System; +using System.Collections; +using System.Collections.Generic; +using libsecondlife; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Data; +using OpenSim.Framework.Types; +using OpenSim.Framework.UserManagement; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Inventory; + +namespace OpenSim.Region.Communications.Local +{ + public delegate void LoginToRegionEvent(ulong regionHandle, Login login); + + public class LocalLoginService : LoginService + { + private CommunicationsLocal m_Parent; + + private NetworkServersInfo serversInfo; + private uint defaultHomeX; + private uint defaultHomeY; + private bool authUsers = false; + + public event LoginToRegionEvent OnLoginToRegion; + + public LocalLoginService(UserManagerBase userManager, string welcomeMess, CommunicationsLocal parent, NetworkServersInfo serversInfo, bool authenticate) + : base(userManager, welcomeMess) + { + m_Parent = parent; + this.serversInfo = serversInfo; + defaultHomeX = this.serversInfo.DefaultHomeLocX; + defaultHomeY = this.serversInfo.DefaultHomeLocY; + this.authUsers = authenticate; + } + + + public override UserProfileData GetTheUser(string firstname, string lastname) + { + UserProfileData profile = this.m_userManager.GetUserProfile(firstname, lastname); + if (profile != null) + { + + return profile; + } + + if (!authUsers) + { + //no current user account so make one + Console.WriteLine("No User account found so creating a new one "); + this.m_userManager.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY); + + profile = this.m_userManager.GetUserProfile(firstname, lastname); + if (profile != null) + { + m_Parent.InventoryService.CreateNewUserInventory(profile.UUID); + } + + return profile; + } + return null; + } + + public override bool AuthenticateUser(UserProfileData profile, string password) + { + if (!authUsers) + { + //for now we will accept any password in sandbox mode + Console.WriteLine("authorising user"); + return true; + } + else + { + Console.WriteLine("Authenticating " + profile.username + " " + profile.surname); + + password = password.Remove(0, 3); //remove $1$ + + string s = Util.Md5Hash(password + ":" + profile.passwordSalt); + + return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); + } + } + + public override void CustomiseResponse(LoginResponse response, UserProfileData theUser) + { + ulong currentRegion = theUser.currentAgent.currentHandle; + RegionInfo reg = m_Parent.GridService.RequestNeighbourInfo(currentRegion); + + if (reg != null) + { + response.Home = "{'region_handle':[r" + (reg.RegionLocX * 256).ToString() + ",r" + (reg.RegionLocY * 256).ToString() + "], " + + "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + + "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}"; + string capsPath = Util.GetRandomCapsPath(); + response.SimAddress = reg.ExternalEndPoint.Address.ToString(); + response.SimPort = (Int32)reg.ExternalEndPoint.Port; + response.RegionX = reg.RegionLocX; + response.RegionY = reg.RegionLocY; + + response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CAPS/" + capsPath + "0000/"; + // response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CapsSeed/" + capsPath + "0000/"; + theUser.currentAgent.currentRegion = reg.SimUUID; + theUser.currentAgent.currentHandle = reg.RegionHandle; + + Login _login = new Login(); + //copy data to login object + _login.First = response.Firstname; + _login.Last = response.Lastname; + _login.Agent = response.AgentID; + _login.Session = response.SessionID; + _login.SecureSession = response.SecureSessionID; + _login.CircuitCode = (uint)response.CircuitCode; + _login.CapsPath = capsPath; + + if( OnLoginToRegion != null ) + { + OnLoginToRegion(currentRegion, _login); + } + } + else + { + Console.WriteLine("not found region " + currentRegion); + } + + } + + protected override InventoryData CreateInventoryData(LLUUID userID) + { + List folders = m_Parent.InventoryService.RequestFirstLevelFolders(userID); + if (folders.Count > 0) + { + LLUUID rootID = LLUUID.Zero; + ArrayList AgentInventoryArray = new ArrayList(); + Hashtable TempHash; + foreach (InventoryFolderBase InvFolder in folders) + { + if (InvFolder.parentID == LLUUID.Zero) + { + rootID = InvFolder.folderID; + } + TempHash = new Hashtable(); + TempHash["name"] = InvFolder.name; + TempHash["parent_id"] = InvFolder.parentID.ToStringHyphenated(); + TempHash["version"] = (Int32)InvFolder.version; + TempHash["type_default"] = (Int32)InvFolder.type; + TempHash["folder_id"] = InvFolder.folderID.ToStringHyphenated(); + AgentInventoryArray.Add(TempHash); + } + return new InventoryData(AgentInventoryArray, rootID); + } + else + { + AgentInventory userInventory = new AgentInventory(); + userInventory.CreateRootFolder(userID, false); + + ArrayList AgentInventoryArray = new ArrayList(); + Hashtable TempHash; + foreach (OpenSim.Framework.Inventory.InventoryFolder InvFolder in userInventory.InventoryFolders.Values) + { + TempHash = new Hashtable(); + TempHash["name"] = InvFolder.FolderName; + TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); + TempHash["version"] = (Int32)InvFolder.Version; + TempHash["type_default"] = (Int32)InvFolder.DefaultType; + TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); + AgentInventoryArray.Add(TempHash); + } + + return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); + } + } + } +} diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index dea4b9f..91694b5 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs @@ -70,7 +70,7 @@ namespace OpenSim.Region.Communications.OGS1 // Send Request XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams); - XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000); + XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 10000); Hashtable GridRespData = (Hashtable)GridResp.Value; Hashtable griddatahash = GridRespData; @@ -109,18 +109,20 @@ namespace OpenSim.Region.Communications.OGS1 List neighbours = new List(); - foreach (ArrayList a in respData.Values) + foreach (ArrayList neighboursList in respData.Values) { - foreach (Hashtable n in a) + foreach (Hashtable neighbourData in neighboursList) { - uint regX = Convert.ToUInt32(n["x"]); - uint regY = Convert.ToUInt32(n["y"]); + uint regX = Convert.ToUInt32(neighbourData["x"]); + uint regY = Convert.ToUInt32(neighbourData["y"]); if ((regionInfo.RegionLocX != regX) || (regionInfo.RegionLocY != regY)) { - string externalIpStr = OpenSim.Framework.Utilities.Util.GetHostFromDNS((string)n["sim_ip"]).ToString(); - uint port = Convert.ToUInt32(n["sim_port"]); - string externalUri = (string)n["sim_uri"]; + string simIp = (string)neighbourData["sim_ip"]; + + uint port = Convert.ToUInt32(neighbourData["sim_port"]); + string externalUri = (string)neighbourData["sim_uri"]; + string externalIpStr = OpenSim.Framework.Utilities.Util.GetHostFromDNS(simIp).ToString(); IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(externalIpStr), (int)port); string neighbourExternalUri = externalUri; RegionInfo neighbour = new RegionInfo(regX, regY, neighbourInternalEndPoint, externalIpStr); @@ -128,10 +130,10 @@ namespace OpenSim.Region.Communications.OGS1 //OGS1 //neighbour.RegionHandle = (ulong)n["regionhandle"]; is now calculated locally - neighbour.RegionName = (string)n["name"]; + neighbour.RegionName = (string)neighbourData["name"]; //OGS1+ - neighbour.SimUUID = (string)n["uuid"]; + neighbour.SimUUID = new LLUUID((string) neighbourData["uuid"]); neighbours.Add(neighbour); } diff --git a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs index 9a113ff..45188c1 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs @@ -1,10 +1,10 @@ -using System; using System.Collections.Generic; using libsecondlife; using OpenSim.Framework.Communications; using OpenSim.Framework.Data; using InventoryFolder = OpenSim.Framework.Communications.Caches.InventoryFolder; + namespace OpenSim.Region.Communications.OGS1 { public class OGS1InventoryService : IInventoryServices -- cgit v1.1