From 0772e19af25b8524fa2527a4d5f3bac496d07811 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 3 Oct 2010 20:01:59 -0700 Subject: [PATCH] Added viewer's channel, mac, and id0 to agent circuit data. Also moved client ip address to agent circuit data, so that it's always there. --- OpenSim/Framework/AgentCircuitData.cs | 37 ++++++++++++++++++- .../EntityTransfer/EntityTransferModule.cs | 22 ++++++++--- .../Handlers/Hypergrid/HomeAgentHandlers.cs | 2 +- .../Server/Handlers/Login/LLLoginHandlers.cs | 19 ++++++++-- .../Hypergrid/UserAgentServiceConnector.cs | 8 +++- .../HypergridService/UserAgentService.cs | 6 ++- OpenSim/Services/Interfaces/ILoginService.cs | 3 +- .../Services/LLLoginService/LLLoginService.cs | 20 +++++++--- 8 files changed, 97 insertions(+), 20 deletions(-) diff --git a/OpenSim/Framework/AgentCircuitData.cs b/OpenSim/Framework/AgentCircuitData.cs index 783a8337a5..4f89d78c0e 100644 --- a/OpenSim/Framework/AgentCircuitData.cs +++ b/OpenSim/Framework/AgentCircuitData.cs @@ -108,10 +108,30 @@ namespace OpenSim.Framework public string ServiceSessionID = string.Empty; /// - /// Viewer's version string + /// The client's IP address, as captured by the login service + /// + public string IPAddress; + + /// + /// Viewer's version string as reported by the viewer at login /// public string Viewer; + /// + /// The channel strinf sent by the viewer at login + /// + public string Channel; + + /// + /// The Mac address as reported by the viewer at login + /// + public string Mac; + + /// + /// The id0 as reported by the viewer at login + /// + public string Id0; + /// /// Position the Agent's Avatar starts in the region /// @@ -179,7 +199,11 @@ namespace OpenSim.Framework args["service_session_id"] = OSD.FromString(ServiceSessionID); args["start_pos"] = OSD.FromString(startpos.ToString()); args["appearance_serial"] = OSD.FromInteger(Appearance.Serial); + args["client_ip"] = OSD.FromString(IPAddress); args["viewer"] = OSD.FromString(Viewer); + args["channel"] = OSD.FromString(Channel); + args["mac"] = OSD.FromString(Mac); + args["id0"] = OSD.FromString(Id0); if (Appearance != null) { @@ -279,8 +303,16 @@ namespace OpenSim.Framework SessionID = args["session_id"].AsUUID(); if (args["service_session_id"] != null) ServiceSessionID = args["service_session_id"].AsString(); + if (args["client_ip"] != null) + IPAddress = args["client_ip"].AsString(); if (args["viewer"] != null) Viewer = args["viewer"].AsString(); + if (args["channel"] != null) + Channel = args["channel"].AsString(); + if (args["mac"] != null) + Mac = args["mac"].AsString(); + if (args["id0"] != null) + Id0 = args["id0"].AsString(); if (args["start_pos"] != null) Vector3.TryParse(args["start_pos"].AsString(), out startpos); @@ -349,6 +381,9 @@ namespace OpenSim.Framework public float startposy; public float startposz; public string Viewer; + public string Channel; + public string Mac; + public string Id0; public sAgentCircuitData() { diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 81f49b6710..38fff1cab3 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -301,7 +301,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (currentAgentCircuit != null) { agentCircuit.ServiceURLs = currentAgentCircuit.ServiceURLs; + agentCircuit.IPAddress = currentAgentCircuit.IPAddress; agentCircuit.Viewer = currentAgentCircuit.Viewer; + agentCircuit.Channel = currentAgentCircuit.Channel; + agentCircuit.Mac = currentAgentCircuit.Mac; + agentCircuit.Id0 = currentAgentCircuit.Id0; } if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) @@ -955,16 +959,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer agent.CapsPath = CapsUtil.GetRandomCapsObjectPath(); agent.ChildrenCapSeeds = new Dictionary(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID)); - m_log.DebugFormat("[XXX] Seeds 1 {0}", agent.ChildrenCapSeeds.Count); + //m_log.DebugFormat("[XXX] Seeds 1 {0}", agent.ChildrenCapSeeds.Count); if (!agent.ChildrenCapSeeds.ContainsKey(sp.Scene.RegionInfo.RegionHandle)) agent.ChildrenCapSeeds.Add(sp.Scene.RegionInfo.RegionHandle, sp.ControllingClient.RequestClientInfo().CapsPath); - m_log.DebugFormat("[XXX] Seeds 2 {0}", agent.ChildrenCapSeeds.Count); + //m_log.DebugFormat("[XXX] Seeds 2 {0}", agent.ChildrenCapSeeds.Count); sp.AddNeighbourRegion(region.RegionHandle, agent.CapsPath); - foreach (ulong h in agent.ChildrenCapSeeds.Keys) - m_log.DebugFormat("[XXX] --> {0}", h); - m_log.DebugFormat("[XXX] Adding {0}", region.RegionHandle); + //foreach (ulong h in agent.ChildrenCapSeeds.Keys) + // m_log.DebugFormat("[XXX] --> {0}", h); + //m_log.DebugFormat("[XXX] Adding {0}", region.RegionHandle); agent.ChildrenCapSeeds.Add(region.RegionHandle, agent.CapsPath); if (sp.Scene.CapsModule != null) @@ -975,7 +979,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (currentAgentCircuit != null) { agent.ServiceURLs = currentAgentCircuit.ServiceURLs; + agent.IPAddress = currentAgentCircuit.IPAddress; agent.Viewer = currentAgentCircuit.Viewer; + agent.Channel = currentAgentCircuit.Channel; + agent.Mac = currentAgentCircuit.Mac; + agent.Id0 = currentAgentCircuit.Id0; } InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; @@ -1064,7 +1072,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (currentAgentCircuit != null) { agent.ServiceURLs = currentAgentCircuit.ServiceURLs; + agent.IPAddress = currentAgentCircuit.IPAddress; agent.Viewer = currentAgentCircuit.Viewer; + agent.Channel = currentAgentCircuit.Channel; + agent.Mac = currentAgentCircuit.Mac; + agent.Id0 = currentAgentCircuit.Id0; } if (newRegions.Contains(neighbour.RegionHandle)) diff --git a/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs index d10d6fc6fe..21f4f3d86a 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs @@ -157,7 +157,7 @@ namespace OpenSim.Server.Handlers.Hypergrid // Verify if this caller has authority to send the client IP if (callerIP == m_LoginServerIP) client_ipaddress = new IPEndPoint(IPAddress.Parse(ip_str), 0); - else + else // leaving this for now, but this warning should be removed m_log.WarnFormat("[HOME AGENT HANDLER]: Unauthorized machine {0} tried to set client ip to {1}", callerIP, ip_str); } catch diff --git a/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs index 30dc65e5e8..48f5f99ed3 100644 --- a/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs +++ b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs @@ -88,14 +88,26 @@ namespace OpenSim.Server.Handlers.Login startLocation = requestData["start"].ToString(); string clientVersion = "Unknown"; - if (requestData.Contains("version")) + if (requestData.Contains("version") && requestData["version"] != null) clientVersion = requestData["version"].ToString(); // We should do something interesting with the client version... + string channel = "Unknown"; + if (requestData.Contains("channel") && requestData["channel"] != null) + channel = requestData["channel"].ToString(); + + string mac = "Unknown"; + if (requestData.Contains("mac") && requestData["mac"] != null) + mac = requestData["mac"].ToString(); + + string id0 = "Unknown"; + if (requestData.Contains("id0") && requestData["id0"] != null) + id0 = requestData["id0"].ToString(); + //m_log.InfoFormat("[LOGIN]: XMLRPC Login Requested for {0} {1}, starting in {2}, using {3}", first, last, startLocation, clientVersion); LoginResponse reply = null; - reply = m_LocalService.Login(first, last, passwd, startLocation, scopeID, clientVersion, remoteClient); + reply = m_LocalService.Login(first, last, passwd, startLocation, scopeID, clientVersion, channel, mac, id0, remoteClient); XmlRpcResponse response = new XmlRpcResponse(); response.Value = reply.ToHashtable(); @@ -166,7 +178,8 @@ namespace OpenSim.Server.Handlers.Login m_log.Info("[LOGIN]: LLSD Login Requested for: '" + map["first"].AsString() + "' '" + map["last"].AsString() + "' / " + startLocation); LoginResponse reply = null; - reply = m_LocalService.Login(map["first"].AsString(), map["last"].AsString(), map["passwd"].AsString(), startLocation, scopeID, String.Empty, remoteClient); + reply = m_LocalService.Login(map["first"].AsString(), map["last"].AsString(), map["passwd"].AsString(), startLocation, scopeID, + map["version"].AsString(), map["channel"].AsString(), map["mac"].AsString(), map["id0"].AsString(), remoteClient); return reply.ToOSDMap(); } diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs index 6d3c64a875..247dd7ed10 100644 --- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs @@ -238,8 +238,12 @@ namespace OpenSim.Services.Connectors.Hypergrid args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); args["destination_name"] = OSD.FromString(destination.RegionName); args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); - if (ipaddress != null) - args["client_ip"] = OSD.FromString(ipaddress.Address.ToString()); + + // 10/3/2010 + // I added the client_ip up to the regular AgentCircuitData, so this doesn't need to be here. + // This need cleaning elsewhere... + //if (ipaddress != null) + // args["client_ip"] = OSD.FromString(ipaddress.Address.ToString()); return args; } diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs index 8acd618b92..eb6433cc6f 100644 --- a/OpenSim/Services/HypergridService/UserAgentService.cs +++ b/OpenSim/Services/HypergridService/UserAgentService.cs @@ -148,7 +148,6 @@ namespace OpenSim.Services.HypergridService agentCircuit.ServiceSessionID = "http://" + region.ExternalHostName + ":" + region.HttpPort + ";" + UUID.Random(); TravelingAgentInfo old = UpdateTravelInfo(agentCircuit, region); - //bool success = m_GatekeeperConnector.CreateAgent(region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, out reason); bool success = false; string myExternalIP = string.Empty; string gridName = "http://" + gatekeeper.ExternalHostName + ":" + gatekeeper.HttpPort; @@ -200,6 +199,11 @@ namespace OpenSim.Services.HypergridService { if (m_TravelingAgents.ContainsKey(agentCircuit.SessionID)) { + // Very important! Override whatever this agent comes with. + // UserAgentService always sets the IP for every new agent + // with the original IP address. + agentCircuit.IPAddress = m_TravelingAgents[agentCircuit.SessionID].ClientIPAddress; + old = m_TravelingAgents[agentCircuit.SessionID]; } diff --git a/OpenSim/Services/Interfaces/ILoginService.cs b/OpenSim/Services/Interfaces/ILoginService.cs index 9e573393d7..ee9b0b1720 100644 --- a/OpenSim/Services/Interfaces/ILoginService.cs +++ b/OpenSim/Services/Interfaces/ILoginService.cs @@ -47,7 +47,8 @@ namespace OpenSim.Services.Interfaces public interface ILoginService { - LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, UUID scopeID, string clientVersion, IPEndPoint clientIP); + LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, UUID scopeID, + string clientVersion, string channel, string mac, string id0, IPEndPoint clientIP); Hashtable SetLevel(string firstName, string lastName, string passwd, int level, IPEndPoint clientIP); } diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index d30c149cf0..127c4b2c5c 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs @@ -208,7 +208,8 @@ namespace OpenSim.Services.LLLoginService return response; } - public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, UUID scopeID, string clientVersion, IPEndPoint clientIP) + public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, UUID scopeID, + string clientVersion, string channel, string mac, string id0, IPEndPoint clientIP) { bool success = false; UUID session = UUID.Random(); @@ -340,7 +341,8 @@ namespace OpenSim.Services.LLLoginService // string reason = string.Empty; GridRegion dest; - AgentCircuitData aCircuit = LaunchAgentAtGrid(gatekeeper, destination, account, avatar, session, secureSession, position, where, clientVersion, clientIP, out where, out reason, out dest); + AgentCircuitData aCircuit = LaunchAgentAtGrid(gatekeeper, destination, account, avatar, session, secureSession, position, where, + clientVersion, channel, mac, id0, clientIP, out where, out reason, out dest); destination = dest; if (aCircuit == null) { @@ -600,7 +602,8 @@ namespace OpenSim.Services.LLLoginService } protected AgentCircuitData LaunchAgentAtGrid(GridRegion gatekeeper, GridRegion destination, UserAccount account, AvatarData avatar, - UUID session, UUID secureSession, Vector3 position, string currentWhere, string viewer, IPEndPoint clientIP, out string where, out string reason, out GridRegion dest) + UUID session, UUID secureSession, Vector3 position, string currentWhere, string viewer, string channel, string mac, string id0, + IPEndPoint clientIP, out string where, out string reason, out GridRegion dest) { where = currentWhere; ISimulationService simConnector = null; @@ -640,7 +643,7 @@ namespace OpenSim.Services.LLLoginService if (m_UserAgentService == null && simConnector != null) { circuitCode = (uint)Util.RandomClass.Next(); ; - aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position, viewer); + aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position, clientIP.Address.ToString(), viewer, channel, mac, id0); success = LaunchAgentDirectly(simConnector, destination, aCircuit, out reason); if (!success && m_GridService != null) { @@ -665,7 +668,7 @@ namespace OpenSim.Services.LLLoginService if (m_UserAgentService != null) { circuitCode = (uint)Util.RandomClass.Next(); ; - aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position, viewer); + aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position, clientIP.Address.ToString(), viewer, channel, mac, id0); success = LaunchAgentIndirectly(gatekeeper, destination, aCircuit, clientIP, out reason); if (!success && m_GridService != null) { @@ -694,7 +697,8 @@ namespace OpenSim.Services.LLLoginService } private AgentCircuitData MakeAgent(GridRegion region, UserAccount account, - AvatarData avatar, UUID session, UUID secureSession, uint circuit, Vector3 position, string viewer) + AvatarData avatar, UUID session, UUID secureSession, uint circuit, Vector3 position, + string ipaddress, string viewer, string channel, string mac, string id0) { AgentCircuitData aCircuit = new AgentCircuitData(); @@ -715,7 +719,11 @@ namespace OpenSim.Services.LLLoginService aCircuit.SecureSessionID = secureSession; aCircuit.SessionID = session; aCircuit.startpos = position; + aCircuit.IPAddress = ipaddress; aCircuit.Viewer = viewer; + aCircuit.Channel = channel; + aCircuit.Mac = mac; + aCircuit.Id0 = id0; SetServiceURLs(aCircuit, account); return aCircuit;