From da531fa9e124394228a7c7597bd50e548af81efb Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 23 Mar 2008 21:21:39 +0000 Subject: [PATCH] * Start passing around a region server's http port in RegionInfo. * This means that caps methods (editing scripts, poss map functions, etc) on non-home regions should now work with servers which are listening for http ports on a non default (9000) port. * If you are running a region server, this may only work properly once your grid server upgrades to this revision * PLEASE NOTE: This shouldn't cause inter-region problems if one end of the connection hasn't upgraded to this revision. However if it does, the instability will persist until the grid and region (and possibly all the region's neighbours) have upgraded to this revision. * This revision also adds extra login related messages, both for success and failure conditions --- .../Framework/Communications/LoginService.cs | 57 +++++++++++++------ OpenSim/Framework/NetworkServersInfo.cs | 2 +- OpenSim/Framework/RegionInfo.cs | 17 +++++- OpenSim/Framework/SerializableRegionInfo.cs | 17 +++++- OpenSim/Grid/UserServer/UserLoginService.cs | 6 +- OpenSim/Region/Application/OpenSimMain.cs | 2 +- .../Communications/Local/LocalLoginService.cs | 4 ++ .../Communications/OGS1/OGS1GridServices.cs | 28 ++++++++- .../Scenes/SceneCommunicationService.cs | 3 +- .../Environment/Scenes/ScenePresence.cs | 4 +- 10 files changed, 107 insertions(+), 33 deletions(-) diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index be47258d23..3e3216fdf9 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -73,7 +73,7 @@ namespace OpenSim.Framework.UserManagement } /// - /// Main user login function + /// Called when we receive the client's initial /// /// The XMLRPC request /// The response to send @@ -94,25 +94,32 @@ namespace OpenSim.Framework.UserManagement string startLocationRequest = "last"; - if (requestData.Contains("start")) - { - startLocationRequest = (string)requestData["start"]; - m_log.Info("[LOGIN]: Client Requested Start: " + (string)requestData["start"]); - } - UserProfileData userProfile; LoginResponse logResponse = new LoginResponse(); + + string firstname = String.Empty; + string lastname = String.Empty; if (GoodXML) { - string firstname = (string) requestData["first"]; - string lastname = (string) requestData["last"]; + firstname = (string) requestData["first"]; + lastname = (string) requestData["last"]; + + m_log.InfoFormat( + "[LOGIN]: Received login request message from user {0} {1}", + firstname, lastname); if( requestData.Contains("version")) { string clientversion = (string)requestData["version"]; - m_log.Info("[LOGIN]: Client Version " + clientversion + " for " + firstname + " " + lastname); + m_log.Info("[LOGIN]: Client version: " + clientversion); } + + if (requestData.Contains("start")) + { + startLocationRequest = (string)requestData["start"]; + m_log.Info("[LOGIN]: Client requested start location: " + (string)requestData["start"]); + } userProfile = GetTheUser(firstname, lastname); if (userProfile == null) @@ -134,31 +141,35 @@ namespace OpenSim.Framework.UserManagement { webloginkey = new LLUUID((string)requestData["web_login_key"]); } - catch (System.Exception) + catch (System.Exception e) { + m_log.InfoFormat( + "[LOGIN]: Bad web_login_key: {0} for user {1} {2}, exception {3}", + requestData["web_login_key"], firstname, lastname, e); + return logResponse.CreateFailedResponse(); } GoodLogin = AuthenticateUser(userProfile, webloginkey); } - else - { - return logResponse.CreateFailedResponse(); - } } else { + m_log.Info( + "[LOGIN]: login_to_simulator login message did not contain all the required data"); + return logResponse.CreateGridErrorResponse(); } if (!GoodLogin) { + m_log.InfoFormat("[LOGIN]: User {0} {1} failed authentication", firstname, lastname); + return logResponse.CreateLoginFailedResponse(); } else { // If we already have a session... - if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) { //TODO: The following statements can cause trouble: @@ -169,6 +180,11 @@ namespace OpenSim.Framework.UserManagement m_userManager.CommitAgent(ref userProfile); // Reject the login + + m_log.InfoFormat( + "[LOGIN]: Notifying user {0} {1} that they are already logged in", + firstname, lastname); + return logResponse.CreateAlreadyLoggedInResponse(); } // Otherwise... @@ -234,14 +250,19 @@ namespace OpenSim.Framework.UserManagement if (StatsManager.UserStats != null) StatsManager.UserStats.AddSuccessfulLogin(); + m_log.InfoFormat( + "[LOGIN]: Authentication of user {0} {1} successful. Sending response to client.", + firstname, lastname); + return logResponse.ToXmlRpcResponse(); } catch (Exception e) { - m_log.Info("[LOGIN]: " + e.ToString()); + m_log.Info("[LOGIN]: Login failed, exception" + e.ToString()); } - //} } + + m_log.Info("[LOGIN]: Login failed. Sending back blank XMLRPC response"); return response; } finally diff --git a/OpenSim/Framework/NetworkServersInfo.cs b/OpenSim/Framework/NetworkServersInfo.cs index 20cd768b27..df559fcafe 100644 --- a/OpenSim/Framework/NetworkServersInfo.cs +++ b/OpenSim/Framework/NetworkServersInfo.cs @@ -45,7 +45,7 @@ namespace OpenSim.Framework public string InventoryURL = String.Empty; - public static uint DefaultHttpListenerPort = 9000; + public static readonly uint DefaultHttpListenerPort = 9000; public uint HttpListenerPort = DefaultHttpListenerPort; public static uint RemotingListenerPort = 8895; diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index b5d6869894..fc6da5790c 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -71,6 +71,7 @@ namespace OpenSim.Framework m_internalEndPoint = ConvertFrom.InternalEndPoint; m_externalHostName = ConvertFrom.ExternalHostName; m_remotingPort = ConvertFrom.RemotingPort; + m_httpPort = ConvertFrom.HttpPort; m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports; RemotingAddress = ConvertFrom.RemotingAddress; RegionID = LLUUID.Zero; @@ -79,16 +80,27 @@ namespace OpenSim.Framework public LLUUID RegionID = LLUUID.Zero; - public uint m_remotingPort; + protected uint m_remotingPort; public uint RemotingPort { get { return m_remotingPort; } set { m_remotingPort = value; } } + + /// + /// The port by which http communication occurs with the region (most noticeably, CAPS communication) + /// + protected uint m_httpPort; + public uint HttpPort + { + get { return m_httpPort; } + set { m_httpPort = value; } + } + public bool m_allow_alternate_ports; - public string m_serverURI; + protected string m_serverURI; public string ServerURI { get @@ -142,7 +154,6 @@ namespace OpenSim.Framework } protected string m_externalHostName; - public string ExternalHostName { get { return m_externalHostName; } diff --git a/OpenSim/Framework/SerializableRegionInfo.cs b/OpenSim/Framework/SerializableRegionInfo.cs index 39a5993017..2c73da8749 100644 --- a/OpenSim/Framework/SerializableRegionInfo.cs +++ b/OpenSim/Framework/SerializableRegionInfo.cs @@ -49,6 +49,7 @@ namespace OpenSim.Framework m_internalEndPoint = ConvertFrom.InternalEndPoint; m_externalHostName = ConvertFrom.ExternalHostName; m_remotingPort = ConvertFrom.RemotingPort; + m_httpPort = ConvertFrom.HttpPort; m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports; RemotingAddress = ConvertFrom.RemotingAddress; m_proxyUrl = ConvertFrom.proxyUrl; @@ -79,17 +80,29 @@ namespace OpenSim.Framework public Guid RegionID = LLUUID.Zero.UUID; public uint m_remotingPort; - public uint RemotingPort { get { return m_remotingPort; } set { m_remotingPort = value; } } + + /// + /// The port by which http communication occurs with the region (most noticeably, CAPS communication) + /// + /// FIXME: Defaulting to 9000 temporarily (on the basis that this is the http port most region + /// servers are running) until the revision in which this change is made propogates around grids. + /// + protected uint m_httpPort = 9000; + public uint HttpPort + { + get { return m_httpPort; } + set { m_httpPort = value; } + } + public bool m_allow_alternate_ports; public string RemotingAddress; - public IPEndPoint ExternalEndPoint { get diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs index 823733f47c..20273ab8c1 100644 --- a/OpenSim/Grid/UserServer/UserLoginService.cs +++ b/OpenSim/Grid/UserServer/UserLoginService.cs @@ -174,9 +174,9 @@ namespace OpenSim.Grid.UserServer // Update agent with target sim - m_log.Info("[LOGIN]: Telling " - + SimInfo.regionName + " @ " + SimInfo.httpServerURI + " " + - SimInfo.regionLocX + "," + SimInfo.regionLocY + " to expect user connection"); + m_log.InfoFormat( + "[LOGIN]: Telling region {0} @ {1},{2} ({3}) to expect user connection", + SimInfo.regionName, response.RegionX, response.RegionY, SimInfo.httpServerURI); XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index f96d474e94..aa5a432a83 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -349,7 +349,7 @@ namespace OpenSim m_standaloneAuthenticate); m_loginService.OnLoginToRegion += backendService.AddNewSession; - // XMLRPC action + // set up XMLRPC handler for client's initial login request message m_httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); // provides the web form login diff --git a/OpenSim/Region/Communications/Local/LocalLoginService.cs b/OpenSim/Region/Communications/Local/LocalLoginService.cs index 9f4723990b..3eac7e99a0 100644 --- a/OpenSim/Region/Communications/Local/LocalLoginService.cs +++ b/OpenSim/Region/Communications/Local/LocalLoginService.cs @@ -178,6 +178,10 @@ namespace OpenSim.Region.Communications.Local _login.StartPos = new LLVector3(128, 128, 70); _login.CapsPath = capsPath; + m_log.InfoFormat( + "[LOGIN]: Telling region {0} @ {1},{2} ({3}:{4}) to expect user connection", + reg.RegionName, response.RegionX, response.RegionY, response.SimAddress, response.SimPort); + handlerLoginToRegion = OnLoginToRegion; if (handlerLoginToRegion != null) { diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index fa1db15735..23b8fb41b2 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs @@ -228,7 +228,14 @@ namespace OpenSim.Region.Communications.OGS1 string externalIpStr = Util.GetHostFromDNS(simIp).ToString(); SimpleRegionInfo sri = new SimpleRegionInfo(regX, regY, simIp, port); + sri.RemotingPort = Convert.ToUInt32(neighbourData["remoting_port"]); + + if (neighbourData.ContainsKey("http_port")) + { + sri.HttpPort = Convert.ToUInt32(neighbourData["http_port"]); + } + sri.RegionID = new LLUUID((string) neighbourData["uuid"]); neighbours.Add(sri); @@ -275,6 +282,11 @@ namespace OpenSim.Region.Communications.OGS1 regionInfo.RemotingPort = Convert.ToUInt32((string) responseData["remoting_port"]); regionInfo.RemotingAddress = internalIpStr; + + if (responseData.ContainsKey("http_port")) + { + regionInfo.HttpPort = Convert.ToUInt32((string) responseData["http_port"]); + } regionInfo.RegionID = new LLUUID((string) responseData["region_UUID"]); regionInfo.RegionName = (string) responseData["region_name"]; @@ -333,6 +345,11 @@ namespace OpenSim.Region.Communications.OGS1 regionInfo.RemotingPort = Convert.ToUInt32((string) responseData["remoting_port"]); regionInfo.RemotingAddress = internalIpStr; + + if (responseData.ContainsKey("http_port")) + { + regionInfo.HttpPort = Convert.ToUInt32((string) responseData["http_port"]); + } regionInfo.RegionID = new LLUUID((string) responseData["region_UUID"]); regionInfo.RegionName = (string) responseData["region_name"]; @@ -385,6 +402,11 @@ namespace OpenSim.Region.Communications.OGS1 regionInfo.RemotingPort = Convert.ToUInt32((string) responseData["remoting_port"]); regionInfo.RemotingAddress = internalIpStr; + + if (responseData.ContainsKey("http_port")) + { + regionInfo.HttpPort = Convert.ToUInt32((string) responseData["http_port"]); + } regionInfo.RegionID = new LLUUID((string) responseData["region_UUID"]); regionInfo.RegionName = (string) responseData["region_name"]; @@ -813,8 +835,10 @@ namespace OpenSim.Region.Communications.OGS1 // And, surprisingly, the reason is.. it doesn't know // it's own remoting port! How special. region = new SearializableRegionInfo(RequestNeighbourInfo(region.RegionHandle)); - region.RemotingAddress = region.ExternalHostName; - region.RemotingPort = NetworkServersInfo.RemotingListenerPort; + region.RemotingAddress = region.ExternalHostName; + region.RemotingPort = NetworkServersInfo.RemotingListenerPort; + region.HttpPort = serversInfo.HttpListenerPort; + if (m_localBackend.RegionUp(region, regionhandle)) { return true; diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index 5dccf135c1..f2b2f20e63 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs @@ -554,7 +554,8 @@ namespace OpenSim.Region.Environment.Scenes // TODO Should construct this behind a method string capsPath = - "http://" + reg.ExternalHostName + ":" + 9000 + "/CAPS/" + circuitdata.CapsPath + "0000/"; + "http://" + reg.ExternalHostName + ":" + reg.HttpPort + + "/CAPS/" + circuitdata.CapsPath + "0000/"; avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4), capsPath); diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index f58109d0f7..def7a77cdc 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -1618,9 +1618,9 @@ namespace OpenSim.Region.Environment.Scenes { AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo(); - // TODO Should construct this behind a method + // TODO Should construct this behind a method string capsPath = - "http://" + neighbourRegion.ExternalHostName + ":" + 9000 + "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort + "/CAPS/" + circuitdata.CapsPath + "0000/"; m_log.DebugFormat(