aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Framework/AgentCircuitData.cs5
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs20
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs10
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs112
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs4
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs33
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs4
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs3
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/HomeUsersSecurityServerConnector.cs122
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs33
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs168
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs90
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/HomeUsersSecurityServiceConnector.cs132
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs370
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs37
-rw-r--r--OpenSim/Services/HypergridService/GatekeeperService.cs77
-rw-r--r--OpenSim/Services/HypergridService/HomeUsersSecurityService.cs67
-rw-r--r--OpenSim/Services/HypergridService/UserAgentService.cs210
-rw-r--r--OpenSim/Services/Interfaces/IGatekeeperService.cs14
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs224
-rw-r--r--bin/config-include/StandaloneHypergrid.ini38
-rw-r--r--prebuild.xml1
23 files changed, 1121 insertions, 658 deletions
diff --git a/OpenSim/Framework/AgentCircuitData.cs b/OpenSim/Framework/AgentCircuitData.cs
index 142ca2c..9c9b4b0 100644
--- a/OpenSim/Framework/AgentCircuitData.cs
+++ b/OpenSim/Framework/AgentCircuitData.cs
@@ -75,6 +75,11 @@ namespace OpenSim.Framework
75 public uint circuitcode; 75 public uint circuitcode;
76 76
77 /// <summary> 77 /// <summary>
78 /// How this agent got here
79 /// </summary>
80 public uint teleportFlags;
81
82 /// <summary>
78 /// Agent's account first name 83 /// Agent's account first name
79 /// </summary> 84 /// </summary>
80 public string firstname; 85 public string firstname;
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index ffd2546..3c4fa72 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -38,7 +38,6 @@ using OpenMetaverse.Packets;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Framework.Statistics; 39using OpenSim.Framework.Statistics;
40using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
41using OpenSim.Services.Interfaces;
42using OpenMetaverse; 41using OpenMetaverse;
43 42
44using TokenBucket = OpenSim.Region.ClientStack.LindenUDP.TokenBucket; 43using TokenBucket = OpenSim.Region.ClientStack.LindenUDP.TokenBucket;
@@ -901,25 +900,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
901 900
902 if (!m_scene.TryGetClient(agentID, out existingClient)) 901 if (!m_scene.TryGetClient(agentID, out existingClient))
903 { 902 {
904 IHomeUsersSecurityService security = m_scene.RequestModuleInterface<IHomeUsersSecurityService>();
905 if (security != null)
906 {
907 IPEndPoint ep = security.GetEndPoint(sessionID);
908 if (ep != null && ep.ToString() != remoteEndPoint.ToString())
909 {
910 // uh-oh, this is fishy
911 m_log.WarnFormat("[LLUDPSERVER]: Agent {0} with session {1} connecting with unidentified end point. Refusing service.", agentID, sessionID);
912 m_log.WarnFormat("[LLUDPSERVER]: EP was {0}, now is {1}", ep.ToString(), remoteEndPoint.ToString());
913 return;
914 }
915 else if (ep != null)
916 {
917 // ok, you're home, welcome back
918 m_log.InfoFormat("LLUDPSERVER]: Agent {0} is coming back to this grid", agentID);
919 security.RemoveEndPoint(sessionID);
920 }
921 }
922
923 // Create the LLClientView 903 // Create the LLClientView
924 LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode); 904 LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
925 client.OnLogout += LogoutHandler; 905 client.OnLogout += LogoutHandler;
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index ed8c0fd..44f1191 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -237,9 +237,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
237 237
238 protected void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags, IEventQueue eq) 238 protected void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags, IEventQueue eq)
239 { 239 {
240 if (reg == null || finalDestination == null)
241 {
242 sp.ControllingClient.SendTeleportFailed("Unable to locate destination");
243 return;
244 }
245
240 m_log.DebugFormat( 246 m_log.DebugFormat(
241 "[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}:{2}/{3} final destination {4}", 247 "[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}:{2}/{3}",
242 reg.ExternalHostName, reg.HttpPort, reg.RegionName, position, finalDestination.RegionName); 248 reg.ExternalHostName, reg.HttpPort, finalDestination.RegionName, position);
243 249
244 uint newRegionX = (uint)(reg.RegionHandle >> 40); 250 uint newRegionX = (uint)(reg.RegionHandle >> 40);
245 uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); 251 uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index 4d5844c..85c2742 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -44,14 +44,13 @@ using Nini.Config;
44 44
45namespace OpenSim.Region.CoreModules.Framework.EntityTransfer 45namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
46{ 46{
47 public class HGEntityTransferModule : EntityTransferModule, ISharedRegionModule, IEntityTransferModule 47 public class HGEntityTransferModule : EntityTransferModule, ISharedRegionModule, IEntityTransferModule, IUserAgentVerificationModule
48 { 48 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 50
51 private bool m_Initialized = false; 51 private bool m_Initialized = false;
52 52
53 private GatekeeperServiceConnector m_GatekeeperConnector; 53 private GatekeeperServiceConnector m_GatekeeperConnector;
54 private IHomeUsersSecurityService m_Security;
55 54
56 #region ISharedRegionModule 55 #region ISharedRegionModule
57 56
@@ -69,21 +68,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
69 if (name == Name) 68 if (name == Name)
70 { 69 {
71 m_agentsInTransit = new List<UUID>(); 70 m_agentsInTransit = new List<UUID>();
72
73 IConfig config = source.Configs["HGEntityTransferModule"];
74 if (config != null)
75 {
76 string dll = config.GetString("HomeUsersSecurityService", string.Empty);
77 if (dll != string.Empty)
78 {
79 Object[] args = new Object[] { source };
80 m_Security = ServerUtils.LoadPlugin<IHomeUsersSecurityService>(dll, args);
81 if (m_Security == null)
82 m_log.Debug("[HG ENTITY TRANSFER MODULE]: Unable to load Home Users Security service");
83 else
84 m_log.Debug("[HG ENTITY TRANSFER MODULE]: Home Users Security service loaded");
85 }
86 }
87 71
88 m_Enabled = true; 72 m_Enabled = true;
89 m_log.InfoFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name); 73 m_log.InfoFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name);
@@ -95,7 +79,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
95 { 79 {
96 base.AddRegion(scene); 80 base.AddRegion(scene);
97 if (m_Enabled) 81 if (m_Enabled)
98 scene.RegisterModuleInterface<IHomeUsersSecurityService>(m_Security); 82 {
83 scene.RegisterModuleInterface<IUserAgentVerificationModule>(this);
84 scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(OnNewClient);
85 }
86 }
87
88 void OnNewClient(IClientAPI client)
89 {
90 client.OnLogout += new Action<IClientAPI>(OnLogout);
99 } 91 }
100 92
101 public override void RegionLoaded(Scene scene) 93 public override void RegionLoaded(Scene scene)
@@ -113,13 +105,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
113 { 105 {
114 base.AddRegion(scene); 106 base.AddRegion(scene);
115 if (m_Enabled) 107 if (m_Enabled)
116 scene.UnregisterModuleInterface<IHomeUsersSecurityService>(m_Security); 108 {
109 scene.UnregisterModuleInterface<IUserAgentVerificationModule>(this);
110 }
117 } 111 }
118 112
119 113
120 #endregion 114 #endregion
121 115
122 #region HG overrides 116 #region HG overrides of IEntiryTransferModule
123 117
124 protected override GridRegion GetFinalDestination(GridRegion region) 118 protected override GridRegion GetFinalDestination(GridRegion region)
125 { 119 {
@@ -142,26 +136,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
142 { 136 {
143 reason = string.Empty; 137 reason = string.Empty;
144 int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID); 138 int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID);
145 if ((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) 139 if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0)
146 { 140 {
147 // this user is going to another grid 141 // this user is going to another grid
148 // Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination 142 string userAgentDriver = agentCircuit.ServiceURLs["HomeURI"].ToString();
149 GridRegion region = new GridRegion(reg); 143 IUserAgentService connector = new UserAgentServiceConnector(userAgentDriver);
150 region.RegionName = finalDestination.RegionName; 144 bool success = connector.LoginAgentToGrid(agentCircuit, reg, finalDestination, out reason);
151 region.RegionID = finalDestination.RegionID; 145 if (success)
152 region.RegionLocX = finalDestination.RegionLocX; 146 // Log them out of this grid
153 region.RegionLocY = finalDestination.RegionLocY; 147 m_aScene.PresenceService.LogoutAgent(agentCircuit.SessionID, sp.AbsolutePosition, sp.Lookat);
154 148
155 // Log their session and remote endpoint in the home users security service 149 return success;
156 IHomeUsersSecurityService security = sp.Scene.RequestModuleInterface<IHomeUsersSecurityService>();
157 if (security != null)
158 security.SetEndPoint(sp.ControllingClient.SessionId, sp.ControllingClient.RemoteEndPoint);
159
160 //string token = sp.Scene.AuthenticationService.MakeToken(sp.UUID, reg.ExternalHostName + ":" + reg.HttpPort, 30);
161 // Log them out of this grid
162 sp.Scene.PresenceService.LogoutAgent(agentCircuit.SessionID, sp.AbsolutePosition, sp.Lookat);
163
164 return m_GatekeeperConnector.CreateAgent(region, agentCircuit, teleportFlags, out reason);
165 } 150 }
166 151
167 return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason); 152 return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason);
@@ -184,23 +169,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
184 // Foreign user wants to go home 169 // Foreign user wants to go home
185 // 170 //
186 AgentCircuitData aCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode); 171 AgentCircuitData aCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode);
187 if (aCircuit == null || (aCircuit != null && !aCircuit.ServiceURLs.ContainsKey("GatewayURI"))) 172 if (aCircuit == null || (aCircuit != null && !aCircuit.ServiceURLs.ContainsKey("HomeURI")))
188 { 173 {
189 client.SendTeleportFailed("Your information has been lost"); 174 client.SendTeleportFailed("Your information has been lost");
190 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information"); 175 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information");
191 return; 176 return;
192 } 177 }
193 178
194 GridRegion homeGatekeeper = MakeRegion(aCircuit); 179 IUserAgentService userAgentService = new UserAgentServiceConnector(aCircuit.ServiceURLs["HomeURI"].ToString());
195 if (homeGatekeeper == null)
196 {
197 client.SendTeleportFailed("Your information has been lost");
198 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's gateway information is malformed");
199 return;
200 }
201
202 Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY; 180 Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY;
203 GridRegion finalDestination = m_GatekeeperConnector.GetHomeRegion(homeGatekeeper, aCircuit.AgentID, out position, out lookAt); 181 GridRegion finalDestination = userAgentService.GetHomeRegion(aCircuit.AgentID, out position, out lookAt);
204 if (finalDestination == null) 182 if (finalDestination == null)
205 { 183 {
206 client.SendTeleportFailed("Your home region could not be found"); 184 client.SendTeleportFailed("Your home region could not be found");
@@ -216,20 +194,52 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
216 return; 194 return;
217 } 195 }
218 196
219 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}:{5}", 197 IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
198 GridRegion homeGatekeeper = MakeRegion(aCircuit);
199
200 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}:{5}",
220 aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ExternalHostName, homeGatekeeper.HttpPort, homeGatekeeper.RegionName); 201 aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ExternalHostName, homeGatekeeper.HttpPort, homeGatekeeper.RegionName);
221 202
222 IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
223 DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome), eq); 203 DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome), eq);
224 } 204 }
225 #endregion 205 #endregion
226 206
207 #region IUserAgentVerificationModule
208
209 public bool VerifyClient(AgentCircuitData aCircuit, string token)
210 {
211 if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
212 {
213 string url = aCircuit.ServiceURLs["HomeURI"].ToString();
214 IUserAgentService security = new UserAgentServiceConnector(url);
215 return security.VerifyClient(aCircuit.SessionID, token);
216 }
217
218 return false;
219 }
220
221 void OnLogout(IClientAPI obj)
222 {
223 AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode);
224
225 if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
226 {
227 string url = aCircuit.ServiceURLs["HomeURI"].ToString();
228 IUserAgentService security = new UserAgentServiceConnector(url);
229 security.LogoutAgent(obj.AgentId, obj.SessionId);
230 }
231
232 }
233
234 #endregion
235
227 private GridRegion MakeRegion(AgentCircuitData aCircuit) 236 private GridRegion MakeRegion(AgentCircuitData aCircuit)
228 { 237 {
229 GridRegion region = new GridRegion(); 238 GridRegion region = new GridRegion();
230 239
231 Uri uri = null; 240 Uri uri = null;
232 if (!Uri.TryCreate(aCircuit.ServiceURLs["GatewayURI"].ToString(), UriKind.Absolute, out uri)) 241 if (!aCircuit.ServiceURLs.ContainsKey("HomeURI") ||
242 (aCircuit.ServiceURLs.ContainsKey("HomeURI") && !Uri.TryCreate(aCircuit.ServiceURLs["HomeURI"].ToString(), UriKind.Absolute, out uri)))
233 return null; 243 return null;
234 244
235 region.ExternalHostName = uri.Host; 245 region.ExternalHostName = uri.Host;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs
index 6e6946c..c737f8b 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs
@@ -115,11 +115,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Hypergrid
115 115
116 m_log.Info("[HypergridService]: Starting..."); 116 m_log.Info("[HypergridService]: Starting...");
117 117
118// Object[] args = new Object[] { m_Config, MainServer.Instance };
119 ISimulationService simService = scene.RequestModuleInterface<ISimulationService>(); 118 ISimulationService simService = scene.RequestModuleInterface<ISimulationService>();
120 m_HypergridHandler = new GatekeeperServiceInConnector(m_Config, MainServer.Instance, simService); 119 m_HypergridHandler = new GatekeeperServiceInConnector(m_Config, MainServer.Instance, simService);
121 //ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args);
122 scene.RegisterModuleInterface<IGatekeeperService>(m_HypergridHandler.GateKeeper); 120 scene.RegisterModuleInterface<IGatekeeperService>(m_HypergridHandler.GateKeeper);
121
122 new UserAgentServerConnector(m_Config, MainServer.Instance);
123 } 123 }
124 } 124 }
125 125
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
index 73c68f1..e8738c4 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
@@ -52,4 +52,9 @@ namespace OpenSim.Region.Framework.Interfaces
52 52
53 void Cross(SceneObjectGroup sog, Vector3 position, bool silent); 53 void Cross(SceneObjectGroup sog, Vector3 position, bool silent);
54 } 54 }
55
56 public interface IUserAgentVerificationModule
57 {
58 bool VerifyClient(AgentCircuitData aCircuit, string token);
59 }
55} 60}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 3cfb236..f800d5f 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2416,6 +2416,37 @@ namespace OpenSim.Region.Framework.Scenes
2416 { 2416 {
2417 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); 2417 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
2418 2418
2419 // Do the verification here
2420 System.Net.EndPoint ep = client.GetClientEP();
2421 if (aCircuit != null)
2422 {
2423 if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0)
2424 {
2425 m_log.DebugFormat("[Scene]: Incoming client {0} {1} in region {2} via Login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
2426 IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>();
2427 if (userVerification != null)
2428 {
2429 if (!userVerification.VerifyClient(aCircuit, ep.ToString()))
2430 {
2431 // uh-oh, this is fishy
2432 m_log.WarnFormat("[Scene]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.",
2433 client.AgentId, client.SessionId, ep.ToString());
2434 try
2435 {
2436 client.Close();
2437 }
2438 catch (Exception e)
2439 {
2440 m_log.DebugFormat("[Scene]: Exception while closing aborted client: {0}", e.StackTrace);
2441 }
2442 return;
2443 }
2444 else
2445 m_log.DebugFormat("[Scene]: User Client Verification for {0} {1} returned true", aCircuit.firstname, aCircuit.lastname);
2446 }
2447 }
2448 }
2449
2419 m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); 2450 m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName);
2420 /* 2451 /*
2421 string logMsg = string.Format("[SCENE]: Adding new {0} agent for {1} in {2}", 2452 string logMsg = string.Format("[SCENE]: Adding new {0} agent for {1} in {2}",
@@ -2426,7 +2457,6 @@ namespace OpenSim.Region.Framework.Scenes
2426 */ 2457 */
2427 2458
2428 //CommsManager.UserProfileCacheService.AddNewUser(client.AgentId); 2459 //CommsManager.UserProfileCacheService.AddNewUser(client.AgentId);
2429
2430 ScenePresence sp = CreateAndAddScenePresence(client); 2460 ScenePresence sp = CreateAndAddScenePresence(client);
2431 sp.Appearance = aCircuit.Appearance; 2461 sp.Appearance = aCircuit.Appearance;
2432 2462
@@ -3243,6 +3273,7 @@ namespace OpenSim.Region.Framework.Scenes
3243 } 3273 }
3244 } 3274 }
3245 3275
3276 agent.teleportFlags = teleportFlags;
3246 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); 3277 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
3247 3278
3248 return true; 3279 return true;
diff --git a/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs
index 01e368c..c951653 100644
--- a/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs
+++ b/OpenSim/Server/Handlers/Hypergrid/AgentHandlers.cs
@@ -49,12 +49,12 @@ using log4net;
49 49
50namespace OpenSim.Server.Handlers.Hypergrid 50namespace OpenSim.Server.Handlers.Hypergrid
51{ 51{
52 public class AgentHandler : OpenSim.Server.Handlers.Simulation.AgentHandler 52 public class GatekeeperAgentHandler : OpenSim.Server.Handlers.Simulation.AgentHandler
53 { 53 {
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 private IGatekeeperService m_GatekeeperService; 55 private IGatekeeperService m_GatekeeperService;
56 56
57 public AgentHandler(IGatekeeperService gatekeeper) 57 public GatekeeperAgentHandler(IGatekeeperService gatekeeper)
58 { 58 {
59 m_GatekeeperService = gatekeeper; 59 m_GatekeeperService = gatekeeper;
60 } 60 }
diff --git a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs
index c73b110..f2d9321 100644
--- a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs
+++ b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs
@@ -68,9 +68,8 @@ namespace OpenSim.Server.Handlers.Hypergrid
68 HypergridHandlers hghandlers = new HypergridHandlers(m_GatekeeperService); 68 HypergridHandlers hghandlers = new HypergridHandlers(m_GatekeeperService);
69 server.AddXmlRPCHandler("link_region", hghandlers.LinkRegionRequest, false); 69 server.AddXmlRPCHandler("link_region", hghandlers.LinkRegionRequest, false);
70 server.AddXmlRPCHandler("get_region", hghandlers.GetRegion, false); 70 server.AddXmlRPCHandler("get_region", hghandlers.GetRegion, false);
71 server.AddXmlRPCHandler("get_home_region", hghandlers.GetHomeRegion, false);
72 71
73 server.AddHTTPHandler("/foreignagent/", new AgentHandler(m_GatekeeperService).Handler); 72 server.AddHTTPHandler("/foreignagent/", new GatekeeperAgentHandler(m_GatekeeperService).Handler);
74 73
75 } 74 }
76 75
diff --git a/OpenSim/Server/Handlers/Hypergrid/HomeUsersSecurityServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/HomeUsersSecurityServerConnector.cs
deleted file mode 100644
index 5379784..0000000
--- a/OpenSim/Server/Handlers/Hypergrid/HomeUsersSecurityServerConnector.cs
+++ /dev/null
@@ -1,122 +0,0 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Net;
5using System.Reflection;
6
7using Nini.Config;
8using OpenSim.Framework;
9using OpenSim.Server.Base;
10using OpenSim.Services.Interfaces;
11using OpenSim.Framework.Servers.HttpServer;
12using OpenSim.Server.Handlers.Base;
13
14using log4net;
15using Nwc.XmlRpc;
16using OpenMetaverse;
17
18namespace OpenSim.Server.Handlers.Hypergrid
19{
20 public class HomeUsersSecurityServerConnector : ServiceConnector
21 {
22 private static readonly ILog m_log =
23 LogManager.GetLogger(
24 MethodBase.GetCurrentMethod().DeclaringType);
25
26 private IHomeUsersSecurityService m_HomeUsersService;
27
28 public HomeUsersSecurityServerConnector(IConfigSource config, IHttpServer server) :
29 base(config, server, String.Empty)
30 {
31 IConfig gridConfig = config.Configs["HomeUsersSecurityService"];
32 if (gridConfig != null)
33 {
34 string serviceDll = gridConfig.GetString("LocalServiceModule", string.Empty);
35 Object[] args = new Object[] { config };
36 m_HomeUsersService = ServerUtils.LoadPlugin<IHomeUsersSecurityService>(serviceDll, args);
37 }
38 if (m_HomeUsersService == null)
39 throw new Exception("HomeUsersSecurity server connector cannot proceed because of missing service");
40
41 server.AddXmlRPCHandler("ep_get", GetEndPoint, false);
42 server.AddXmlRPCHandler("ep_set", SetEndPoint, false);
43 server.AddXmlRPCHandler("ep_remove", RemoveEndPoint, false);
44
45 }
46
47 public XmlRpcResponse GetEndPoint(XmlRpcRequest request, IPEndPoint remoteClient)
48 {
49 Hashtable requestData = (Hashtable)request.Params[0];
50 //string host = (string)requestData["host"];
51 //string portstr = (string)requestData["port"];
52 string sessionID_str = (string)requestData["sessionID"];
53 UUID sessionID = UUID.Zero;
54 UUID.TryParse(sessionID_str, out sessionID);
55
56 IPEndPoint ep = m_HomeUsersService.GetEndPoint(sessionID);
57
58 Hashtable hash = new Hashtable();
59 if (ep == null)
60 hash["result"] = "false";
61 else
62 {
63 hash["result"] = "true";
64 hash["ep_addr"] = ep.Address.ToString();
65 hash["ep_port"] = ep.Port.ToString();
66 }
67 XmlRpcResponse response = new XmlRpcResponse();
68 response.Value = hash;
69 return response;
70
71 }
72
73 public XmlRpcResponse SetEndPoint(XmlRpcRequest request, IPEndPoint remoteClient)
74 {
75 Hashtable requestData = (Hashtable)request.Params[0];
76 string host = (string)requestData["ep_addr"];
77 string portstr = (string)requestData["ep_port"];
78 string sessionID_str = (string)requestData["sessionID"];
79 UUID sessionID = UUID.Zero;
80 UUID.TryParse(sessionID_str, out sessionID);
81 int port = 0;
82 Int32.TryParse(portstr, out port);
83
84 IPEndPoint ep = null;
85 try
86 {
87 ep = new IPEndPoint(IPAddress.Parse(host), port);
88 }
89 catch
90 {
91 m_log.Debug("[HOME USERS SECURITY]: Exception in creating EndPoint");
92 }
93
94 m_HomeUsersService.SetEndPoint(sessionID, ep);
95
96 Hashtable hash = new Hashtable();
97 hash["result"] = "true";
98 XmlRpcResponse response = new XmlRpcResponse();
99 response.Value = hash;
100 return response;
101
102 }
103
104 public XmlRpcResponse RemoveEndPoint(XmlRpcRequest request, IPEndPoint remoteClient)
105 {
106 Hashtable requestData = (Hashtable)request.Params[0];
107 string sessionID_str = (string)requestData["sessionID"];
108 UUID sessionID = UUID.Zero;
109 UUID.TryParse(sessionID_str, out sessionID);
110
111 m_HomeUsersService.RemoveEndPoint(sessionID);
112
113 Hashtable hash = new Hashtable();
114 hash["result"] = "true";
115 XmlRpcResponse response = new XmlRpcResponse();
116 response.Value = hash;
117 return response;
118
119 }
120
121 }
122}
diff --git a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs
index 7d31730..0b65245 100644
--- a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs
+++ b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs
@@ -113,38 +113,5 @@ namespace OpenSim.Server.Handlers.Hypergrid
113 113
114 } 114 }
115 115
116 public XmlRpcResponse GetHomeRegion(XmlRpcRequest request, IPEndPoint remoteClient)
117 {
118 Hashtable requestData = (Hashtable)request.Params[0];
119 //string host = (string)requestData["host"];
120 //string portstr = (string)requestData["port"];
121 string userID_str = (string)requestData["userID"];
122 UUID userID = UUID.Zero;
123 UUID.TryParse(userID_str, out userID);
124
125 Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY;
126 GridRegion regInfo = m_GatekeeperService.GetHomeRegion(userID, out position, out lookAt);
127
128 Hashtable hash = new Hashtable();
129 if (regInfo == null)
130 hash["result"] = "false";
131 else
132 {
133 hash["result"] = "true";
134 hash["uuid"] = regInfo.RegionID.ToString();
135 hash["x"] = regInfo.RegionLocX.ToString();
136 hash["y"] = regInfo.RegionLocY.ToString();
137 hash["region_name"] = regInfo.RegionName;
138 hash["hostname"] = regInfo.ExternalHostName;
139 hash["http_port"] = regInfo.HttpPort.ToString();
140 hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString();
141 hash["position"] = position.ToString();
142 hash["lookAt"] = lookAt.ToString();
143 }
144 XmlRpcResponse response = new XmlRpcResponse();
145 response.Value = hash;
146 return response;
147
148 }
149 } 116 }
150} 117}
diff --git a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs
new file mode 100644
index 0000000..79c6b2a
--- /dev/null
+++ b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs
@@ -0,0 +1,168 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Net;
5using System.Reflection;
6
7using Nini.Config;
8using OpenSim.Framework;
9using OpenSim.Server.Base;
10using OpenSim.Services.Interfaces;
11using OpenSim.Framework.Servers.HttpServer;
12using OpenSim.Server.Handlers.Base;
13using GridRegion = OpenSim.Services.Interfaces.GridRegion;
14
15using log4net;
16using Nwc.XmlRpc;
17using OpenMetaverse;
18
19namespace OpenSim.Server.Handlers.Hypergrid
20{
21 public class UserAgentServerConnector : ServiceConnector
22 {
23 private static readonly ILog m_log =
24 LogManager.GetLogger(
25 MethodBase.GetCurrentMethod().DeclaringType);
26
27 private IUserAgentService m_HomeUsersService;
28
29 public UserAgentServerConnector(IConfigSource config, IHttpServer server) :
30 base(config, server, String.Empty)
31 {
32 IConfig gridConfig = config.Configs["UserAgentService"];
33 if (gridConfig != null)
34 {
35 string serviceDll = gridConfig.GetString("LocalServiceModule", string.Empty);
36 Object[] args = new Object[] { config };
37 m_HomeUsersService = ServerUtils.LoadPlugin<IUserAgentService>(serviceDll, args);
38 }
39 if (m_HomeUsersService == null)
40 throw new Exception("UserAgent server connector cannot proceed because of missing service");
41
42 server.AddXmlRPCHandler("agent_is_coming_home", AgentIsComingHome, false);
43 server.AddXmlRPCHandler("get_home_region", GetHomeRegion, false);
44 server.AddXmlRPCHandler("verify_agent", VerifyAgent, false);
45 server.AddXmlRPCHandler("verify_client", VerifyClient, false);
46 server.AddXmlRPCHandler("logout_agent", LogoutAgent, false);
47
48 server.AddHTTPHandler("/homeagent/", new HomeAgentHandler(m_HomeUsersService).Handler);
49 }
50
51 public XmlRpcResponse GetHomeRegion(XmlRpcRequest request, IPEndPoint remoteClient)
52 {
53 Hashtable requestData = (Hashtable)request.Params[0];
54 //string host = (string)requestData["host"];
55 //string portstr = (string)requestData["port"];
56 string userID_str = (string)requestData["userID"];
57 UUID userID = UUID.Zero;
58 UUID.TryParse(userID_str, out userID);
59
60 Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY;
61 GridRegion regInfo = m_HomeUsersService.GetHomeRegion(userID, out position, out lookAt);
62
63 Hashtable hash = new Hashtable();
64 if (regInfo == null)
65 hash["result"] = "false";
66 else
67 {
68 hash["result"] = "true";
69 hash["uuid"] = regInfo.RegionID.ToString();
70 hash["x"] = regInfo.RegionLocX.ToString();
71 hash["y"] = regInfo.RegionLocY.ToString();
72 hash["region_name"] = regInfo.RegionName;
73 hash["hostname"] = regInfo.ExternalHostName;
74 hash["http_port"] = regInfo.HttpPort.ToString();
75 hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString();
76 hash["position"] = position.ToString();
77 hash["lookAt"] = lookAt.ToString();
78 }
79 XmlRpcResponse response = new XmlRpcResponse();
80 response.Value = hash;
81 return response;
82
83 }
84
85 public XmlRpcResponse AgentIsComingHome(XmlRpcRequest request, IPEndPoint remoteClient)
86 {
87 Hashtable requestData = (Hashtable)request.Params[0];
88 //string host = (string)requestData["host"];
89 //string portstr = (string)requestData["port"];
90 string sessionID_str = (string)requestData["sessionID"];
91 UUID sessionID = UUID.Zero;
92 UUID.TryParse(sessionID_str, out sessionID);
93 string gridName = (string)requestData["externalName"];
94
95 bool success = m_HomeUsersService.AgentIsComingHome(sessionID, gridName);
96
97 Hashtable hash = new Hashtable();
98 hash["result"] = success.ToString();
99 XmlRpcResponse response = new XmlRpcResponse();
100 response.Value = hash;
101 return response;
102
103 }
104
105 public XmlRpcResponse VerifyAgent(XmlRpcRequest request, IPEndPoint remoteClient)
106 {
107 Hashtable requestData = (Hashtable)request.Params[0];
108 //string host = (string)requestData["host"];
109 //string portstr = (string)requestData["port"];
110 string sessionID_str = (string)requestData["sessionID"];
111 UUID sessionID = UUID.Zero;
112 UUID.TryParse(sessionID_str, out sessionID);
113 string token = (string)requestData["token"];
114
115 bool success = m_HomeUsersService.VerifyAgent(sessionID, token);
116
117 Hashtable hash = new Hashtable();
118 hash["result"] = success.ToString();
119 XmlRpcResponse response = new XmlRpcResponse();
120 response.Value = hash;
121 return response;
122
123 }
124
125 public XmlRpcResponse VerifyClient(XmlRpcRequest request, IPEndPoint remoteClient)
126 {
127 Hashtable requestData = (Hashtable)request.Params[0];
128 //string host = (string)requestData["host"];
129 //string portstr = (string)requestData["port"];
130 string sessionID_str = (string)requestData["sessionID"];
131 UUID sessionID = UUID.Zero;
132 UUID.TryParse(sessionID_str, out sessionID);
133 string token = (string)requestData["token"];
134
135 bool success = m_HomeUsersService.VerifyClient(sessionID, token);
136
137 Hashtable hash = new Hashtable();
138 hash["result"] = success.ToString();
139 XmlRpcResponse response = new XmlRpcResponse();
140 response.Value = hash;
141 return response;
142
143 }
144
145 public XmlRpcResponse LogoutAgent(XmlRpcRequest request, IPEndPoint remoteClient)
146 {
147 Hashtable requestData = (Hashtable)request.Params[0];
148 //string host = (string)requestData["host"];
149 //string portstr = (string)requestData["port"];
150 string sessionID_str = (string)requestData["sessionID"];
151 UUID sessionID = UUID.Zero;
152 UUID.TryParse(sessionID_str, out sessionID);
153 string userID_str = (string)requestData["userID"];
154 UUID userID = UUID.Zero;
155 UUID.TryParse(userID_str, out userID);
156
157 m_HomeUsersService.LogoutAgent(userID, sessionID);
158
159 Hashtable hash = new Hashtable();
160 hash["result"] = "true";
161 XmlRpcResponse response = new XmlRpcResponse();
162 response.Value = hash;
163 return response;
164
165 }
166
167 }
168}
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
index 5ad1af2..608228d 100644
--- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
@@ -241,95 +241,5 @@ namespace OpenSim.Services.Connectors.Hypergrid
241 return null; 241 return null;
242 } 242 }
243 243
244 public GridRegion GetHomeRegion(GridRegion gatekeeper, UUID userID, out Vector3 position, out Vector3 lookAt)
245 {
246 position = Vector3.UnitY; lookAt = Vector3.UnitY;
247
248 Hashtable hash = new Hashtable();
249 hash["userID"] = userID.ToString();
250
251 IList paramList = new ArrayList();
252 paramList.Add(hash);
253
254 XmlRpcRequest request = new XmlRpcRequest("get_home_region", paramList);
255 string uri = "http://" + gatekeeper.ExternalHostName + ":" + gatekeeper.HttpPort + "/";
256 XmlRpcResponse response = null;
257 try
258 {
259 response = request.Send(uri, 10000);
260 }
261 catch (Exception e)
262 {
263 return null;
264 }
265
266 if (response.IsFault)
267 {
268 return null;
269 }
270
271 hash = (Hashtable)response.Value;
272 //foreach (Object o in hash)
273 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
274 try
275 {
276 bool success = false;
277 Boolean.TryParse((string)hash["result"], out success);
278 if (success)
279 {
280 GridRegion region = new GridRegion();
281
282 UUID.TryParse((string)hash["uuid"], out region.RegionID);
283 //m_log.Debug(">> HERE, uuid: " + region.RegionID);
284 int n = 0;
285 if (hash["x"] != null)
286 {
287 Int32.TryParse((string)hash["x"], out n);
288 region.RegionLocX = n;
289 //m_log.Debug(">> HERE, x: " + region.RegionLocX);
290 }
291 if (hash["y"] != null)
292 {
293 Int32.TryParse((string)hash["y"], out n);
294 region.RegionLocY = n;
295 //m_log.Debug(">> HERE, y: " + region.RegionLocY);
296 }
297 if (hash["region_name"] != null)
298 {
299 region.RegionName = (string)hash["region_name"];
300 //m_log.Debug(">> HERE, name: " + region.RegionName);
301 }
302 if (hash["hostname"] != null)
303 region.ExternalHostName = (string)hash["hostname"];
304 if (hash["http_port"] != null)
305 {
306 uint p = 0;
307 UInt32.TryParse((string)hash["http_port"], out p);
308 region.HttpPort = p;
309 }
310 if (hash["internal_port"] != null)
311 {
312 int p = 0;
313 Int32.TryParse((string)hash["internal_port"], out p);
314 region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p);
315 }
316 if (hash["position"] != null)
317 Vector3.TryParse((string)hash["position"], out position);
318 if (hash["lookAt"] != null)
319 Vector3.TryParse((string)hash["lookAt"], out lookAt);
320
321 // Successful return
322 return region;
323 }
324
325 }
326 catch (Exception e)
327 {
328 return null;
329 }
330
331 return null;
332
333 }
334 } 244 }
335} 245}
diff --git a/OpenSim/Services/Connectors/Hypergrid/HomeUsersSecurityServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HomeUsersSecurityServiceConnector.cs
deleted file mode 100644
index 150690b..0000000
--- a/OpenSim/Services/Connectors/Hypergrid/HomeUsersSecurityServiceConnector.cs
+++ /dev/null
@@ -1,132 +0,0 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Net;
5using System.Reflection;
6
7using OpenSim.Services.Interfaces;
8
9using OpenMetaverse;
10using log4net;
11using Nwc.XmlRpc;
12using Nini.Config;
13
14namespace OpenSim.Services.Connectors.Hypergrid
15{
16 public class HomeUsersSecurityServiceConnector : IHomeUsersSecurityService
17 {
18 private static readonly ILog m_log =
19 LogManager.GetLogger(
20 MethodBase.GetCurrentMethod().DeclaringType);
21
22 string m_ServerURL;
23 public HomeUsersSecurityServiceConnector(string url)
24 {
25 m_ServerURL = url;
26 }
27
28 public HomeUsersSecurityServiceConnector(IConfigSource config)
29 {
30 }
31
32 public void SetEndPoint(UUID sessionID, IPEndPoint ep)
33 {
34 Hashtable hash = new Hashtable();
35 hash["sessionID"] = sessionID.ToString();
36 hash["ep_addr"] = ep.Address.ToString();
37 hash["ep_port"] = ep.Port.ToString();
38
39 Call("ep_set", hash);
40 }
41
42 public void RemoveEndPoint(UUID sessionID)
43 {
44 Hashtable hash = new Hashtable();
45 hash["sessionID"] = sessionID.ToString();
46
47 Call("ep_remove", hash);
48 }
49
50 public IPEndPoint GetEndPoint(UUID sessionID)
51 {
52 Hashtable hash = new Hashtable();
53 hash["sessionID"] = sessionID.ToString();
54
55 IList paramList = new ArrayList();
56 paramList.Add(hash);
57
58 XmlRpcRequest request = new XmlRpcRequest("ep_get", paramList);
59 //m_log.Debug("[HGrid]: Linking to " + uri);
60 XmlRpcResponse response = null;
61 try
62 {
63 response = request.Send(m_ServerURL, 10000);
64 }
65 catch (Exception e)
66 {
67 m_log.Debug("[HGrid]: Exception " + e.Message);
68 return null;
69 }
70
71 if (response.IsFault)
72 {
73 m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
74 return null;
75 }
76
77 hash = (Hashtable)response.Value;
78 //foreach (Object o in hash)
79 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
80 try
81 {
82 bool success = false;
83 Boolean.TryParse((string)hash["result"], out success);
84 if (success)
85 {
86 IPEndPoint ep = null;
87 int port = 0;
88 if (hash["ep_port"] != null)
89 Int32.TryParse((string)hash["ep_port"], out port);
90 if (hash["ep_addr"] != null)
91 ep = new IPEndPoint(IPAddress.Parse((string)hash["ep_addr"]), port);
92
93 return ep;
94 }
95
96 }
97 catch (Exception e)
98 {
99 m_log.Error("[HGrid]: Got exception while parsing GetEndPoint response " + e.StackTrace);
100 return null;
101 }
102
103 return null;
104 }
105
106 private void Call(string method, Hashtable hash)
107 {
108 IList paramList = new ArrayList();
109 paramList.Add(hash);
110
111 XmlRpcRequest request = new XmlRpcRequest(method, paramList);
112 XmlRpcResponse response = null;
113 try
114 {
115 response = request.Send(m_ServerURL, 10000);
116 }
117 catch (Exception e)
118 {
119 m_log.Debug("[HGrid]: Exception " + e.Message);
120 return ;
121 }
122
123 if (response.IsFault)
124 {
125 m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
126 return ;
127 }
128
129 }
130
131 }
132}
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
new file mode 100644
index 0000000..83d3449
--- /dev/null
+++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
@@ -0,0 +1,370 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.IO;
5using System.Net;
6using System.Reflection;
7using System.Text;
8
9using OpenSim.Framework;
10using OpenSim.Services.Interfaces;
11using OpenSim.Services.Connectors.Simulation;
12using GridRegion = OpenSim.Services.Interfaces.GridRegion;
13
14using OpenMetaverse;
15using OpenMetaverse.StructuredData;
16using log4net;
17using Nwc.XmlRpc;
18using Nini.Config;
19
20namespace OpenSim.Services.Connectors.Hypergrid
21{
22 public class UserAgentServiceConnector : IUserAgentService
23 {
24 private static readonly ILog m_log =
25 LogManager.GetLogger(
26 MethodBase.GetCurrentMethod().DeclaringType);
27
28 string m_ServerURL;
29 public UserAgentServiceConnector(string url)
30 {
31 m_ServerURL = url;
32 }
33
34 public UserAgentServiceConnector(IConfigSource config)
35 {
36 }
37
38 public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason)
39 {
40 reason = String.Empty;
41
42 if (destination == null)
43 {
44 reason = "Destination is null";
45 m_log.Debug("[USER AGENT CONNECTOR]: Given destination is null");
46 return false;
47 }
48
49 string uri = m_ServerURL + "/homeagent/" + aCircuit.AgentID + "/";
50
51 Console.WriteLine(" >>> LoginAgentToGrid <<< " + uri);
52
53 HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri);
54 AgentCreateRequest.Method = "POST";
55 AgentCreateRequest.ContentType = "application/json";
56 AgentCreateRequest.Timeout = 10000;
57 //AgentCreateRequest.KeepAlive = false;
58 //AgentCreateRequest.Headers.Add("Authorization", authKey);
59
60 // Fill it in
61 OSDMap args = PackCreateAgentArguments(aCircuit, gatekeeper, destination);
62
63 string strBuffer = "";
64 byte[] buffer = new byte[1];
65 try
66 {
67 strBuffer = OSDParser.SerializeJsonString(args);
68 Encoding str = Util.UTF8;
69 buffer = str.GetBytes(strBuffer);
70
71 }
72 catch (Exception e)
73 {
74 m_log.WarnFormat("[USER AGENT CONNECTOR]: Exception thrown on serialization of ChildCreate: {0}", e.Message);
75 // ignore. buffer will be empty, caller should check.
76 }
77
78 Stream os = null;
79 try
80 { // send the Post
81 AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send
82 os = AgentCreateRequest.GetRequestStream();
83 os.Write(buffer, 0, strBuffer.Length); //Send it
84 m_log.InfoFormat("[USER AGENT CONNECTOR]: Posted CreateAgent request to remote sim {0}, region {1}, x={2} y={3}",
85 uri, destination.RegionName, destination.RegionLocX, destination.RegionLocY);
86 }
87 //catch (WebException ex)
88 catch
89 {
90 //m_log.InfoFormat("[USER AGENT CONNECTOR]: Bad send on ChildAgentUpdate {0}", ex.Message);
91 reason = "cannot contact remote region";
92 return false;
93 }
94 finally
95 {
96 if (os != null)
97 os.Close();
98 }
99
100 // Let's wait for the response
101 //m_log.Info("[USER AGENT CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall");
102
103 WebResponse webResponse = null;
104 StreamReader sr = null;
105 try
106 {
107 webResponse = AgentCreateRequest.GetResponse();
108 if (webResponse == null)
109 {
110 m_log.Info("[USER AGENT CONNECTOR]: Null reply on DoCreateChildAgentCall post");
111 }
112 else
113 {
114
115 sr = new StreamReader(webResponse.GetResponseStream());
116 string response = sr.ReadToEnd().Trim();
117 m_log.InfoFormat("[USER AGENT CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response);
118
119 if (!String.IsNullOrEmpty(response))
120 {
121 try
122 {
123 // we assume we got an OSDMap back
124 OSDMap r = Util.GetOSDMap(response);
125 bool success = r["success"].AsBoolean();
126 reason = r["reason"].AsString();
127 return success;
128 }
129 catch (NullReferenceException e)
130 {
131 m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message);
132
133 // check for old style response
134 if (response.ToLower().StartsWith("true"))
135 return true;
136
137 return false;
138 }
139 }
140 }
141 }
142 catch (WebException ex)
143 {
144 m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", ex.Message);
145 reason = "Destination did not reply";
146 return false;
147 }
148 finally
149 {
150 if (sr != null)
151 sr.Close();
152 }
153
154 return true;
155
156 }
157
158 protected OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination)
159 {
160 OSDMap args = null;
161 try
162 {
163 args = aCircuit.PackAgentCircuitData();
164 }
165 catch (Exception e)
166 {
167 m_log.Debug("[USER AGENT CONNECTOR]: PackAgentCircuitData failed with exception: " + e.Message);
168 }
169 // Add the input arguments
170 args["gatekeeper_host"] = OSD.FromString(gatekeeper.ExternalHostName);
171 args["gatekeeper_port"] = OSD.FromString(gatekeeper.HttpPort.ToString());
172 args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
173 args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
174 args["destination_name"] = OSD.FromString(destination.RegionName);
175 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
176
177 return args;
178 }
179
180 public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt)
181 {
182 position = Vector3.UnitY; lookAt = Vector3.UnitY;
183
184 Hashtable hash = new Hashtable();
185 hash["userID"] = userID.ToString();
186
187 IList paramList = new ArrayList();
188 paramList.Add(hash);
189
190 XmlRpcRequest request = new XmlRpcRequest("get_home_region", paramList);
191 XmlRpcResponse response = null;
192 try
193 {
194 response = request.Send(m_ServerURL, 10000);
195 }
196 catch (Exception e)
197 {
198 return null;
199 }
200
201 if (response.IsFault)
202 {
203 return null;
204 }
205
206 hash = (Hashtable)response.Value;
207 //foreach (Object o in hash)
208 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
209 try
210 {
211 bool success = false;
212 Boolean.TryParse((string)hash["result"], out success);
213 if (success)
214 {
215 GridRegion region = new GridRegion();
216
217 UUID.TryParse((string)hash["uuid"], out region.RegionID);
218 //m_log.Debug(">> HERE, uuid: " + region.RegionID);
219 int n = 0;
220 if (hash["x"] != null)
221 {
222 Int32.TryParse((string)hash["x"], out n);
223 region.RegionLocX = n;
224 //m_log.Debug(">> HERE, x: " + region.RegionLocX);
225 }
226 if (hash["y"] != null)
227 {
228 Int32.TryParse((string)hash["y"], out n);
229 region.RegionLocY = n;
230 //m_log.Debug(">> HERE, y: " + region.RegionLocY);
231 }
232 if (hash["region_name"] != null)
233 {
234 region.RegionName = (string)hash["region_name"];
235 //m_log.Debug(">> HERE, name: " + region.RegionName);
236 }
237 if (hash["hostname"] != null)
238 region.ExternalHostName = (string)hash["hostname"];
239 if (hash["http_port"] != null)
240 {
241 uint p = 0;
242 UInt32.TryParse((string)hash["http_port"], out p);
243 region.HttpPort = p;
244 }
245 if (hash["internal_port"] != null)
246 {
247 int p = 0;
248 Int32.TryParse((string)hash["internal_port"], out p);
249 region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p);
250 }
251 if (hash["position"] != null)
252 Vector3.TryParse((string)hash["position"], out position);
253 if (hash["lookAt"] != null)
254 Vector3.TryParse((string)hash["lookAt"], out lookAt);
255
256 // Successful return
257 return region;
258 }
259
260 }
261 catch (Exception e)
262 {
263 return null;
264 }
265
266 return null;
267
268 }
269
270 public bool AgentIsComingHome(UUID sessionID, string thisGridExternalName)
271 {
272 Hashtable hash = new Hashtable();
273 hash["sessionID"] = sessionID.ToString();
274 hash["externalName"] = thisGridExternalName;
275
276 IList paramList = new ArrayList();
277 paramList.Add(hash);
278
279 XmlRpcRequest request = new XmlRpcRequest("agent_is_coming_home", paramList);
280 string reason = string.Empty;
281 return GetBoolResponse(request, out reason);
282 }
283
284 public bool VerifyAgent(UUID sessionID, string token)
285 {
286 Hashtable hash = new Hashtable();
287 hash["sessionID"] = sessionID.ToString();
288 hash["token"] = token;
289
290 IList paramList = new ArrayList();
291 paramList.Add(hash);
292
293 XmlRpcRequest request = new XmlRpcRequest("verify_agent", paramList);
294 string reason = string.Empty;
295 return GetBoolResponse(request, out reason);
296 }
297
298 public bool VerifyClient(UUID sessionID, string token)
299 {
300 Hashtable hash = new Hashtable();
301 hash["sessionID"] = sessionID.ToString();
302 hash["token"] = token;
303
304 IList paramList = new ArrayList();
305 paramList.Add(hash);
306
307 XmlRpcRequest request = new XmlRpcRequest("verify_client", paramList);
308 string reason = string.Empty;
309 return GetBoolResponse(request, out reason);
310 }
311
312 public void LogoutAgent(UUID userID, UUID sessionID)
313 {
314 Hashtable hash = new Hashtable();
315 hash["sessionID"] = sessionID.ToString();
316 hash["userID"] = userID.ToString();
317
318 IList paramList = new ArrayList();
319 paramList.Add(hash);
320
321 XmlRpcRequest request = new XmlRpcRequest("logout_agent", paramList);
322 string reason = string.Empty;
323 GetBoolResponse(request, out reason);
324 }
325
326
327 private bool GetBoolResponse(XmlRpcRequest request, out string reason)
328 {
329 //m_log.Debug("[HGrid]: Linking to " + uri);
330 XmlRpcResponse response = null;
331 try
332 {
333 response = request.Send(m_ServerURL, 10000);
334 }
335 catch (Exception e)
336 {
337 m_log.Debug("[HGrid]: Exception " + e.Message);
338 reason = "Exception: " + e.Message;
339 return false;
340 }
341
342 if (response.IsFault)
343 {
344 m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
345 reason = "XMLRPC Fault";
346 return false;
347 }
348
349 Hashtable hash = (Hashtable)response.Value;
350 //foreach (Object o in hash)
351 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
352 try
353 {
354 bool success = false;
355 reason = string.Empty;
356 Boolean.TryParse((string)hash["result"], out success);
357
358 return success;
359 }
360 catch (Exception e)
361 {
362 m_log.Error("[HGrid]: Got exception while parsing GetEndPoint response " + e.StackTrace);
363 reason = "Exception: " + e.Message;
364 return false;
365 }
366
367 }
368
369 }
370}
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
index 683fe79..e2ab179 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -104,21 +104,7 @@ namespace OpenSim.Services.Connectors.Simulation
104 //AgentCreateRequest.Headers.Add("Authorization", authKey); 104 //AgentCreateRequest.Headers.Add("Authorization", authKey);
105 105
106 // Fill it in 106 // Fill it in
107 OSDMap args = null; 107 OSDMap args = PackCreateAgentArguments(aCircuit, destination, flags);
108 try
109 {
110 args = aCircuit.PackAgentCircuitData();
111 }
112 catch (Exception e)
113 {
114 m_log.Debug("[REMOTE SIMULATION CONNECTOR]: PackAgentCircuitData failed with exception: " + e.Message);
115 }
116 // Add the input arguments
117 args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
118 args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
119 args["destination_name"] = OSD.FromString(destination.RegionName);
120 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
121 args["teleport_flags"] = OSD.FromString(flags.ToString());
122 108
123 string strBuffer = ""; 109 string strBuffer = "";
124 byte[] buffer = new byte[1]; 110 byte[] buffer = new byte[1];
@@ -214,6 +200,27 @@ namespace OpenSim.Services.Connectors.Simulation
214 return true; 200 return true;
215 } 201 }
216 202
203 protected virtual OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion destination, uint flags)
204 {
205 OSDMap args = null;
206 try
207 {
208 args = aCircuit.PackAgentCircuitData();
209 }
210 catch (Exception e)
211 {
212 m_log.Debug("[REMOTE SIMULATION CONNECTOR]: PackAgentCircuitData failed with exception: " + e.Message);
213 }
214 // Add the input arguments
215 args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
216 args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
217 args["destination_name"] = OSD.FromString(destination.RegionName);
218 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
219 args["teleport_flags"] = OSD.FromString(flags.ToString());
220
221 return args;
222 }
223
217 public bool UpdateAgent(GridRegion destination, AgentData data) 224 public bool UpdateAgent(GridRegion destination, AgentData data)
218 { 225 {
219 return UpdateAgent(destination, (IAgentData)data); 226 return UpdateAgent(destination, (IAgentData)data);
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs
index 3cb5d50..3bf0836 100644
--- a/OpenSim/Services/HypergridService/GatekeeperService.cs
+++ b/OpenSim/Services/HypergridService/GatekeeperService.cs
@@ -34,6 +34,7 @@ using OpenSim.Framework;
34using OpenSim.Services.Interfaces; 34using OpenSim.Services.Interfaces;
35using GridRegion = OpenSim.Services.Interfaces.GridRegion; 35using GridRegion = OpenSim.Services.Interfaces.GridRegion;
36using OpenSim.Server.Base; 36using OpenSim.Server.Base;
37using OpenSim.Services.Connectors.Hypergrid;
37 38
38using OpenMetaverse; 39using OpenMetaverse;
39 40
@@ -50,9 +51,8 @@ namespace OpenSim.Services.HypergridService
50 51
51 IGridService m_GridService; 52 IGridService m_GridService;
52 IPresenceService m_PresenceService; 53 IPresenceService m_PresenceService;
53 IAuthenticationService m_AuthenticationService;
54 IUserAccountService m_UserAccountService; 54 IUserAccountService m_UserAccountService;
55 IHomeUsersSecurityService m_HomeUsersSecurityService; 55 IUserAgentService m_UserAgentService;
56 ISimulationService m_SimulationService; 56 ISimulationService m_SimulationService;
57 57
58 string m_AuthDll; 58 string m_AuthDll;
@@ -69,12 +69,12 @@ namespace OpenSim.Services.HypergridService
69 throw new Exception(String.Format("No section GatekeeperService in config file")); 69 throw new Exception(String.Format("No section GatekeeperService in config file"));
70 70
71 string accountService = serverConfig.GetString("UserAccountService", String.Empty); 71 string accountService = serverConfig.GetString("UserAccountService", String.Empty);
72 string homeUsersSecurityService = serverConfig.GetString("HomeUsersSecurityService", string.Empty); 72 string homeUsersService = serverConfig.GetString("HomeUsersSecurityService", string.Empty);
73 string gridService = serverConfig.GetString("GridService", String.Empty); 73 string gridService = serverConfig.GetString("GridService", String.Empty);
74 string presenceService = serverConfig.GetString("PresenceService", String.Empty); 74 string presenceService = serverConfig.GetString("PresenceService", String.Empty);
75 string simulationService = serverConfig.GetString("SimulationService", String.Empty); 75 string simulationService = serverConfig.GetString("SimulationService", String.Empty);
76 76
77 m_AuthDll = serverConfig.GetString("AuthenticationService", String.Empty); 77 //m_AuthDll = serverConfig.GetString("AuthenticationService", String.Empty);
78 78
79 // These 3 are mandatory, the others aren't 79 // These 3 are mandatory, the others aren't
80 if (gridService == string.Empty || presenceService == string.Empty || m_AuthDll == string.Empty) 80 if (gridService == string.Empty || presenceService == string.Empty || m_AuthDll == string.Empty)
@@ -92,8 +92,8 @@ namespace OpenSim.Services.HypergridService
92 92
93 if (accountService != string.Empty) 93 if (accountService != string.Empty)
94 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args); 94 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
95 if (homeUsersSecurityService != string.Empty) 95 if (homeUsersService != string.Empty)
96 m_HomeUsersSecurityService = ServerUtils.LoadPlugin<IHomeUsersSecurityService>(homeUsersSecurityService, args); 96 m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(homeUsersService, args);
97 97
98 if (simService != null) 98 if (simService != null)
99 m_SimulationService = simService; 99 m_SimulationService = simService;
@@ -206,13 +206,12 @@ namespace OpenSim.Services.HypergridService
206 account = m_UserAccountService.GetUserAccount(m_ScopeID, aCircuit.AgentID); 206 account = m_UserAccountService.GetUserAccount(m_ScopeID, aCircuit.AgentID);
207 if (account != null) 207 if (account != null)
208 { 208 {
209 // Make sure this is the user coming home, and not a fake 209 // Make sure this is the user coming home, and not a foreign user with same UUID as a local user
210 if (m_HomeUsersSecurityService != null) 210 if (m_UserAgentService != null)
211 { 211 {
212 Object ep = m_HomeUsersSecurityService.GetEndPoint(aCircuit.SessionID); 212 if (!m_UserAgentService.AgentIsComingHome(aCircuit.SessionID, m_ExternalName))
213 if (ep == null)
214 { 213 {
215 // This is a fake, this session never left this grid 214 // Can't do, sorry
216 reason = "Unauthorized"; 215 reason = "Unauthorized";
217 m_log.InfoFormat("[GATEKEEPER SERVICE]: Foreign agent {0} {1} has same ID as local user. Refusing service.", 216 m_log.InfoFormat("[GATEKEEPER SERVICE]: Foreign agent {0} {1} has same ID as local user. Refusing service.",
218 aCircuit.firstname, aCircuit.lastname); 217 aCircuit.firstname, aCircuit.lastname);
@@ -266,32 +265,35 @@ namespace OpenSim.Services.HypergridService
266 // 265 //
267 // Finally launch the agent at the destination 266 // Finally launch the agent at the destination
268 // 267 //
269 return m_SimulationService.CreateAgent(destination, aCircuit, 0, out reason); 268 return m_SimulationService.CreateAgent(destination, aCircuit, (uint)Constants.TeleportFlags.ViaLogin, out reason);
270 } 269 }
271 270
272 protected bool Authenticate(AgentCircuitData aCircuit) 271 protected bool Authenticate(AgentCircuitData aCircuit)
273 { 272 {
274 string authURL = string.Empty; 273 if (!CheckAddress(aCircuit.ServiceSessionID))
274 return false;
275
276 string userURL = string.Empty;
275 if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) 277 if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
276 authURL = aCircuit.ServiceURLs["HomeURI"].ToString(); 278 userURL = aCircuit.ServiceURLs["HomeURI"].ToString();
277 279
278 if (authURL == string.Empty) 280 if (userURL == string.Empty)
279 { 281 {
280 m_log.DebugFormat("[GATEKEEPER SERVICE]: Agent did not provide an authentication server URL"); 282 m_log.DebugFormat("[GATEKEEPER SERVICE]: Agent did not provide an authentication server URL");
281 return false; 283 return false;
282 } 284 }
283 285
284 Object[] args = new Object[] { authURL }; 286 Object[] args = new Object[] { userURL };
285 IAuthenticationService authService = ServerUtils.LoadPlugin<IAuthenticationService>(m_AuthDll, args); 287 IUserAgentService userAgentService = new UserAgentServiceConnector(userURL); //ServerUtils.LoadPlugin<IUserAgentService>(m_AuthDll, args);
286 if (authService != null) 288 if (userAgentService != null)
287 { 289 {
288 try 290 try
289 { 291 {
290 return authService.Verify(aCircuit.AgentID, aCircuit.SecureSessionID.ToString(), 30); 292 return userAgentService.VerifyAgent(aCircuit.SessionID, aCircuit.ServiceSessionID);
291 } 293 }
292 catch 294 catch
293 { 295 {
294 m_log.DebugFormat("[GATEKEEPER SERVICE]: Unable to contact authentication service at {0}", authURL); 296 m_log.DebugFormat("[GATEKEEPER SERVICE]: Unable to contact authentication service at {0}", userURL);
295 return false; 297 return false;
296 } 298 }
297 } 299 }
@@ -299,35 +301,20 @@ namespace OpenSim.Services.HypergridService
299 return false; 301 return false;
300 } 302 }
301 303
302 #endregion 304 // Check that the service token was generated for *this* grid.
303 305 // If it wasn't then that's a fake agent.
304 public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt) 306 protected bool CheckAddress(string serviceToken)
305 { 307 {
306 position = new Vector3(128, 128, 0); lookAt = Vector3.UnitY; 308 string[] parts = serviceToken.Split(new char[] { ';' });
309 if (parts.Length < 2)
310 return false;
307 311
308 m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to get home region of user {0}", userID); 312 string addressee = parts[0];
313 return (addressee == m_ExternalName);
314 }
309 315
310 GridRegion home = null; 316 #endregion
311 PresenceInfo[] presences = m_PresenceService.GetAgents(new string[] { userID.ToString() });
312 if (presences != null && presences.Length > 0)
313 {
314 UUID homeID = presences[0].HomeRegionID;
315 if (homeID != UUID.Zero)
316 {
317 home = m_GridService.GetRegionByUUID(m_ScopeID, homeID);
318 position = presences[0].HomePosition;
319 lookAt = presences[0].HomeLookAt;
320 }
321 if (home == null)
322 {
323 List<GridRegion> defs = m_GridService.GetDefaultRegions(m_ScopeID);
324 if (defs != null && defs.Count > 0)
325 home = defs[0];
326 }
327 }
328 317
329 return home;
330 }
331 318
332 #region Misc 319 #region Misc
333 320
diff --git a/OpenSim/Services/HypergridService/HomeUsersSecurityService.cs b/OpenSim/Services/HypergridService/HomeUsersSecurityService.cs
deleted file mode 100644
index a7adfc1..0000000
--- a/OpenSim/Services/HypergridService/HomeUsersSecurityService.cs
+++ /dev/null
@@ -1,67 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Net;
4using System.Reflection;
5
6using OpenSim.Services.Interfaces;
7
8using OpenMetaverse;
9using log4net;
10using Nini.Config;
11
12namespace OpenSim.Services.HypergridService
13{
14 /// <summary>
15 /// This service is for HG1.5 only, to make up for the fact that clients don't
16 /// keep any private information in themselves, and that their 'home service'
17 /// needs to do it for them.
18 /// Once we have better clients, this shouldn't be needed.
19 /// </summary>
20 public class HomeUsersSecurityService : IHomeUsersSecurityService
21 {
22 private static readonly ILog m_log =
23 LogManager.GetLogger(
24 MethodBase.GetCurrentMethod().DeclaringType);
25
26 //
27 // This is a persistent storage wannabe for dealing with the
28 // quirks of HG1.5. We don't really want to store this in a table.
29 // But this is the necessary information for securing clients
30 // coming home.
31 //
32 protected static Dictionary<UUID, IPEndPoint> m_ClientEndPoints = new Dictionary<UUID, IPEndPoint>();
33
34 public HomeUsersSecurityService(IConfigSource config)
35 {
36 m_log.DebugFormat("[HOME USERS SECURITY]: Starting...");
37 }
38
39 public void SetEndPoint(UUID sessionID, IPEndPoint ep)
40 {
41 m_log.DebugFormat("[HOME USERS SECURITY]: Set EndPoint {0} for session {1}", ep.ToString(), sessionID);
42
43 lock (m_ClientEndPoints)
44 m_ClientEndPoints[sessionID] = ep;
45 }
46
47 public IPEndPoint GetEndPoint(UUID sessionID)
48 {
49 lock (m_ClientEndPoints)
50 if (m_ClientEndPoints.ContainsKey(sessionID))
51 {
52 m_log.DebugFormat("[HOME USERS SECURITY]: Get EndPoint {0} for session {1}", m_ClientEndPoints[sessionID].ToString(), sessionID);
53 return m_ClientEndPoints[sessionID];
54 }
55
56 return null;
57 }
58
59 public void RemoveEndPoint(UUID sessionID)
60 {
61 m_log.DebugFormat("[HOME USERS SECURITY]: Remove EndPoint for session {0}", sessionID);
62 lock (m_ClientEndPoints)
63 if (m_ClientEndPoints.ContainsKey(sessionID))
64 m_ClientEndPoints.Remove(sessionID);
65 }
66 }
67}
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
new file mode 100644
index 0000000..0873a2b
--- /dev/null
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -0,0 +1,210 @@
1using System;
2using System.Collections.Generic;
3using System.Net;
4using System.Reflection;
5
6using OpenSim.Framework;
7using OpenSim.Services.Connectors.Hypergrid;
8using OpenSim.Services.Interfaces;
9using GridRegion = OpenSim.Services.Interfaces.GridRegion;
10using OpenSim.Server.Base;
11
12using OpenMetaverse;
13using log4net;
14using Nini.Config;
15
16namespace OpenSim.Services.HypergridService
17{
18 /// <summary>
19 /// This service is for HG1.5 only, to make up for the fact that clients don't
20 /// keep any private information in themselves, and that their 'home service'
21 /// needs to do it for them.
22 /// Once we have better clients, this shouldn't be needed.
23 /// </summary>
24 public class UserAgentService : IUserAgentService
25 {
26 private static readonly ILog m_log =
27 LogManager.GetLogger(
28 MethodBase.GetCurrentMethod().DeclaringType);
29
30 // This will need to go into a DB table
31 static Dictionary<UUID, TravelingAgentInfo> m_TravelingAgents = new Dictionary<UUID, TravelingAgentInfo>();
32
33 static bool m_Initialized = false;
34
35 protected static IPresenceService m_PresenceService;
36 protected static IGridService m_GridService;
37 protected static GatekeeperServiceConnector m_GatekeeperConnector;
38
39 public UserAgentService(IConfigSource config)
40 {
41 if (!m_Initialized)
42 {
43 m_log.DebugFormat("[HOME USERS SECURITY]: Starting...");
44
45 IConfig serverConfig = config.Configs["UserAgentService"];
46 if (serverConfig == null)
47 throw new Exception(String.Format("No section UserAgentService in config file"));
48
49 string gridService = serverConfig.GetString("GridService", String.Empty);
50 string presenceService = serverConfig.GetString("PresenceService", String.Empty);
51
52 if (gridService == string.Empty || presenceService == string.Empty)
53 throw new Exception(String.Format("Incomplete specifications, UserAgent Service cannot function."));
54
55 Object[] args = new Object[] { config };
56 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
57 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
58 m_GatekeeperConnector = new GatekeeperServiceConnector();
59
60 m_Initialized = true;
61 }
62 }
63
64 public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt)
65 {
66 position = new Vector3(128, 128, 0); lookAt = Vector3.UnitY;
67
68 m_log.DebugFormat("[USER AGENT SERVICE]: Request to get home region of user {0}", userID);
69
70 GridRegion home = null;
71 PresenceInfo[] presences = m_PresenceService.GetAgents(new string[] { userID.ToString() });
72 if (presences != null && presences.Length > 0)
73 {
74 UUID homeID = presences[0].HomeRegionID;
75 if (homeID != UUID.Zero)
76 {
77 home = m_GridService.GetRegionByUUID(UUID.Zero, homeID);
78 position = presences[0].HomePosition;
79 lookAt = presences[0].HomeLookAt;
80 }
81 if (home == null)
82 {
83 List<GridRegion> defs = m_GridService.GetDefaultRegions(UUID.Zero);
84 if (defs != null && defs.Count > 0)
85 home = defs[0];
86 }
87 }
88
89 return home;
90 }
91
92 public bool LoginAgentToGrid(AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, out string reason)
93 {
94 m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} to grid {2}",
95 agentCircuit.firstname, agentCircuit.lastname, gatekeeper.ExternalHostName +":"+ gatekeeper.HttpPort);
96
97 // Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination
98 GridRegion region = new GridRegion(gatekeeper);
99 region.RegionName = finalDestination.RegionName;
100 region.RegionID = finalDestination.RegionID;
101 region.RegionLocX = finalDestination.RegionLocX;
102 region.RegionLocY = finalDestination.RegionLocY;
103
104 // Generate a new service session
105 agentCircuit.ServiceSessionID = "http://" + region.ExternalHostName + ":" + region.HttpPort + ";" + UUID.Random();
106 TravelingAgentInfo old = UpdateTravelInfo(agentCircuit, region);
107
108 bool success = m_GatekeeperConnector.CreateAgent(region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, out reason);
109
110 if (!success)
111 {
112 m_log.DebugFormat("[USER AGENT SERVICE]: Unable to login user {0} {1} to grid {2}, reason: {3}",
113 agentCircuit.firstname, agentCircuit.lastname, region.ExternalHostName + ":" + region.HttpPort, reason);
114
115 // restore the old travel info
116 lock (m_TravelingAgents)
117 m_TravelingAgents[agentCircuit.SessionID] = old;
118
119 return false;
120 }
121
122 return true;
123 }
124
125 TravelingAgentInfo UpdateTravelInfo(AgentCircuitData agentCircuit, GridRegion region)
126 {
127 TravelingAgentInfo travel = new TravelingAgentInfo();
128 TravelingAgentInfo old = null;
129 lock (m_TravelingAgents)
130 {
131 if (m_TravelingAgents.ContainsKey(agentCircuit.SessionID))
132 {
133 old = m_TravelingAgents[agentCircuit.SessionID];
134 }
135
136 m_TravelingAgents[agentCircuit.SessionID] = travel;
137 }
138 travel.UserID = agentCircuit.AgentID;
139 travel.GridExternalName = region.ExternalHostName + ":" + region.HttpPort;
140 travel.ServiceToken = agentCircuit.ServiceSessionID;
141 if (old != null)
142 travel.ClientToken = old.ClientToken;
143
144 return old;
145 }
146
147 public void LogoutAgent(UUID userID, UUID sessionID)
148 {
149 m_log.DebugFormat("[USER AGENT SERVICE]: User {0} logged out", userID);
150
151 lock (m_TravelingAgents)
152 {
153 List<UUID> travels = new List<UUID>();
154 foreach (KeyValuePair<UUID, TravelingAgentInfo> kvp in m_TravelingAgents)
155 if (kvp.Value.UserID == userID)
156 travels.Add(kvp.Key);
157 foreach (UUID session in travels)
158 m_TravelingAgents.Remove(session);
159 }
160 }
161
162 // We need to prevent foreign users with the same UUID as a local user
163 public bool AgentIsComingHome(UUID sessionID, string thisGridExternalName)
164 {
165 if (!m_TravelingAgents.ContainsKey(sessionID))
166 return false;
167
168 TravelingAgentInfo travel = m_TravelingAgents[sessionID];
169 return travel.GridExternalName == thisGridExternalName;
170 }
171
172 public bool VerifyClient(UUID sessionID, string token)
173 {
174 if (m_TravelingAgents.ContainsKey(sessionID))
175 {
176 // Aquiles heel. Must trust the first grid upon login
177 if (m_TravelingAgents[sessionID].ClientToken == string.Empty)
178 {
179 m_TravelingAgents[sessionID].ClientToken = token;
180 return true;
181 }
182 return m_TravelingAgents[sessionID].ClientToken == token;
183 }
184 return false;
185 }
186
187 public bool VerifyAgent(UUID sessionID, string token)
188 {
189 if (m_TravelingAgents.ContainsKey(sessionID))
190 {
191 m_log.DebugFormat("[USER AGENT SERVICE]: Verifying agent token {0} against {1}", token, m_TravelingAgents[sessionID].ServiceToken);
192 return m_TravelingAgents[sessionID].ServiceToken == token;
193 }
194
195 m_log.DebugFormat("[USER AGENT SERVICE]: Token verification for session {0}: no such session", sessionID);
196
197 return false;
198 }
199
200 }
201
202 class TravelingAgentInfo
203 {
204 public UUID UserID;
205 public string GridExternalName = string.Empty;
206 public string ServiceToken = string.Empty;
207 public string ClientToken = string.Empty;
208 }
209
210}
diff --git a/OpenSim/Services/Interfaces/IGatekeeperService.cs b/OpenSim/Services/Interfaces/IGatekeeperService.cs
index f8eb817..ca7b9b3 100644
--- a/OpenSim/Services/Interfaces/IGatekeeperService.cs
+++ b/OpenSim/Services/Interfaces/IGatekeeperService.cs
@@ -41,17 +41,19 @@ namespace OpenSim.Services.Interfaces
41 41
42 bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason); 42 bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason);
43 43
44 GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt);
45
46 } 44 }
47 45
48 /// <summary> 46 /// <summary>
49 /// HG1.5 only 47 /// HG1.5 only
50 /// </summary> 48 /// </summary>
51 public interface IHomeUsersSecurityService 49 public interface IUserAgentService
52 { 50 {
53 void SetEndPoint(UUID sessionID, IPEndPoint ep); 51 bool LoginAgentToGrid(AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, out string reason);
54 IPEndPoint GetEndPoint(UUID sessionID); 52 void LogoutAgent(UUID userID, UUID sessionID);
55 void RemoveEndPoint(UUID sessionID); 53 GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt);
54
55 bool AgentIsComingHome(UUID sessionID, string thisGridExternalName);
56 bool VerifyAgent(UUID sessionID, string token);
57 bool VerifyClient(UUID sessionID, string token);
56 } 58 }
57} 59}
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index d4f89d9..cacedf8 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -14,6 +14,7 @@ using OpenSim.Framework.Console;
14using OpenSim.Server.Base; 14using OpenSim.Server.Base;
15using OpenSim.Services.Interfaces; 15using OpenSim.Services.Interfaces;
16using GridRegion = OpenSim.Services.Interfaces.GridRegion; 16using GridRegion = OpenSim.Services.Interfaces.GridRegion;
17using OpenSim.Services.Connectors.Hypergrid;
17 18
18namespace OpenSim.Services.LLLoginService 19namespace OpenSim.Services.LLLoginService
19{ 20{
@@ -31,11 +32,15 @@ namespace OpenSim.Services.LLLoginService
31 private ISimulationService m_RemoteSimulationService; 32 private ISimulationService m_RemoteSimulationService;
32 private ILibraryService m_LibraryService; 33 private ILibraryService m_LibraryService;
33 private IAvatarService m_AvatarService; 34 private IAvatarService m_AvatarService;
35 private IUserAgentService m_UserAgentService;
36
37 private GatekeeperServiceConnector m_GatekeeperConnector;
34 38
35 private string m_DefaultRegionName; 39 private string m_DefaultRegionName;
36 private string m_WelcomeMessage; 40 private string m_WelcomeMessage;
37 private bool m_RequireInventory; 41 private bool m_RequireInventory;
38 private int m_MinLoginLevel; 42 private int m_MinLoginLevel;
43 private string m_GatekeeperURL;
39 44
40 IConfig m_LoginServerConfig; 45 IConfig m_LoginServerConfig;
41 46
@@ -46,6 +51,7 @@ namespace OpenSim.Services.LLLoginService
46 throw new Exception(String.Format("No section LoginService in config file")); 51 throw new Exception(String.Format("No section LoginService in config file"));
47 52
48 string accountService = m_LoginServerConfig.GetString("UserAccountService", String.Empty); 53 string accountService = m_LoginServerConfig.GetString("UserAccountService", String.Empty);
54 string agentService = m_LoginServerConfig.GetString("UserAgentService", String.Empty);
49 string authService = m_LoginServerConfig.GetString("AuthenticationService", String.Empty); 55 string authService = m_LoginServerConfig.GetString("AuthenticationService", String.Empty);
50 string invService = m_LoginServerConfig.GetString("InventoryService", String.Empty); 56 string invService = m_LoginServerConfig.GetString("InventoryService", String.Empty);
51 string gridService = m_LoginServerConfig.GetString("GridService", String.Empty); 57 string gridService = m_LoginServerConfig.GetString("GridService", String.Empty);
@@ -57,6 +63,7 @@ namespace OpenSim.Services.LLLoginService
57 m_DefaultRegionName = m_LoginServerConfig.GetString("DefaultRegion", String.Empty); 63 m_DefaultRegionName = m_LoginServerConfig.GetString("DefaultRegion", String.Empty);
58 m_WelcomeMessage = m_LoginServerConfig.GetString("WelcomeMessage", "Welcome to OpenSim!"); 64 m_WelcomeMessage = m_LoginServerConfig.GetString("WelcomeMessage", "Welcome to OpenSim!");
59 m_RequireInventory = m_LoginServerConfig.GetBoolean("RequireInventory", true); 65 m_RequireInventory = m_LoginServerConfig.GetBoolean("RequireInventory", true);
66 m_GatekeeperURL = m_LoginServerConfig.GetString("GatekeeperURI", string.Empty);
60 67
61 // These are required; the others aren't 68 // These are required; the others aren't
62 if (accountService == string.Empty || authService == string.Empty) 69 if (accountService == string.Empty || authService == string.Empty)
@@ -74,6 +81,9 @@ namespace OpenSim.Services.LLLoginService
74 m_AvatarService = ServerUtils.LoadPlugin<IAvatarService>(avatarService, args); 81 m_AvatarService = ServerUtils.LoadPlugin<IAvatarService>(avatarService, args);
75 if (simulationService != string.Empty) 82 if (simulationService != string.Empty)
76 m_RemoteSimulationService = ServerUtils.LoadPlugin<ISimulationService>(simulationService, args); 83 m_RemoteSimulationService = ServerUtils.LoadPlugin<ISimulationService>(simulationService, args);
84 if (agentService != string.Empty)
85 m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(agentService, args);
86
77 // 87 //
78 // deal with the services given as argument 88 // deal with the services given as argument
79 // 89 //
@@ -89,6 +99,8 @@ namespace OpenSim.Services.LLLoginService
89 m_LibraryService = ServerUtils.LoadPlugin<ILibraryService>(libService, args); 99 m_LibraryService = ServerUtils.LoadPlugin<ILibraryService>(libService, args);
90 } 100 }
91 101
102 m_GatekeeperConnector = new GatekeeperServiceConnector();
103
92 if (!Initialized) 104 if (!Initialized)
93 { 105 {
94 Initialized = true; 106 Initialized = true;
@@ -185,7 +197,8 @@ namespace OpenSim.Services.LLLoginService
185 string where = string.Empty; 197 string where = string.Empty;
186 Vector3 position = Vector3.Zero; 198 Vector3 position = Vector3.Zero;
187 Vector3 lookAt = Vector3.Zero; 199 Vector3 lookAt = Vector3.Zero;
188 GridRegion destination = FindDestination(account, presence, session, startLocation, out where, out position, out lookAt); 200 GridRegion gatekeeper = null;
201 GridRegion destination = FindDestination(account, presence, session, startLocation, out gatekeeper, out where, out position, out lookAt);
189 if (destination == null) 202 if (destination == null)
190 { 203 {
191 m_PresenceService.LogoutAgent(session, presence.Position, presence.LookAt); 204 m_PresenceService.LogoutAgent(session, presence.Position, presence.LookAt);
@@ -205,50 +218,16 @@ namespace OpenSim.Services.LLLoginService
205 // 218 //
206 // Instantiate/get the simulation interface and launch an agent at the destination 219 // Instantiate/get the simulation interface and launch an agent at the destination
207 // 220 //
208 ISimulationService simConnector = null;
209 string reason = string.Empty; 221 string reason = string.Empty;
210 uint circuitCode = 0; 222 AgentCircuitData aCircuit = LaunchAgentAtGrid(gatekeeper, destination, account, avatar, session, secureSession, position, where, out where, out reason);
211 AgentCircuitData aCircuit = null; 223
212 Object[] args = new Object[] { destination };
213 // HG standalones have both a localSimulatonDll and a remoteSimulationDll
214 // non-HG standalones have just a localSimulationDll
215 // independent login servers have just a remoteSimulationDll
216 if (!startLocation.Contains("@") && (m_LocalSimulationService != null))
217 simConnector = m_LocalSimulationService;
218 else if (m_RemoteSimulationService != null)
219 simConnector = m_RemoteSimulationService;
220 if (simConnector != null)
221 {
222 circuitCode = (uint)Util.RandomClass.Next(); ;
223 aCircuit = LaunchAgent(simConnector, destination, account, avatar, session, secureSession, circuitCode, position, out reason);
224 }
225 if (aCircuit == null) 224 if (aCircuit == null)
226 { 225 {
227 // Try the fallback regions 226 m_PresenceService.LogoutAgent(session, presence.Position, presence.LookAt);
228 List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.ScopeID, destination.RegionLocX, destination.RegionLocY); 227 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: {0}", reason);
229 if (fallbacks != null) 228 return LLFailedLoginResponse.AuthorizationProblem;
230 {
231 foreach (GridRegion r in fallbacks)
232 {
233 aCircuit = LaunchAgent(simConnector, r, account, avatar, session, secureSession, circuitCode, position, out reason);
234 if (aCircuit != null)
235 {
236 where = "safe";
237 destination = r;
238 break;
239 }
240 }
241 }
242 229
243 if (aCircuit == null)
244 {
245 // we tried...
246 m_PresenceService.LogoutAgent(session, presence.Position, presence.LookAt);
247 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: {0}", reason);
248 return LLFailedLoginResponse.AuthorizationProblem;
249 }
250 } 230 }
251
252 // TODO: Get Friends list... 231 // TODO: Get Friends list...
253 232
254 // 233 //
@@ -268,10 +247,11 @@ namespace OpenSim.Services.LLLoginService
268 } 247 }
269 } 248 }
270 249
271 private GridRegion FindDestination(UserAccount account, PresenceInfo pinfo, UUID sessionID, string startLocation, out string where, out Vector3 position, out Vector3 lookAt) 250 private GridRegion FindDestination(UserAccount account, PresenceInfo pinfo, UUID sessionID, string startLocation, out GridRegion gatekeeper, out string where, out Vector3 position, out Vector3 lookAt)
272 { 251 {
273 m_log.DebugFormat("[LLOGIN SERVICE]: FindDestination for start location {0}", startLocation); 252 m_log.DebugFormat("[LLOGIN SERVICE]: FindDestination for start location {0}", startLocation);
274 253
254 gatekeeper = null;
275 where = "home"; 255 where = "home";
276 position = new Vector3(128, 128, 0); 256 position = new Vector3(128, 128, 0);
277 lookAt = new Vector3(0, 1, 0); 257 lookAt = new Vector3(0, 1, 0);
@@ -376,6 +356,11 @@ namespace OpenSim.Services.LLLoginService
376 } 356 }
377 else 357 else
378 { 358 {
359 if (m_UserAgentService == null)
360 {
361 m_log.WarnFormat("[LLLOGIN SERVICE]: This llogin service is not running a user agent service, as such it can't lauch agents at foreign grids");
362 return null;
363 }
379 string[] parts = regionName.Split(new char[] { '@' }); 364 string[] parts = regionName.Split(new char[] { '@' });
380 if (parts.Length < 2) 365 if (parts.Length < 2)
381 { 366 {
@@ -390,10 +375,7 @@ namespace OpenSim.Services.LLLoginService
390 uint port = 0; 375 uint port = 0;
391 if (parts.Length > 1) 376 if (parts.Length > 1)
392 UInt32.TryParse(parts[1], out port); 377 UInt32.TryParse(parts[1], out port);
393 GridRegion region = new GridRegion(); 378 GridRegion region = FindForeignRegion(domainName, port, regionName, out gatekeeper);
394 region.ExternalHostName = domainName;
395 region.HttpPort = port;
396 region.RegionName = regionName;
397 return region; 379 return region;
398 } 380 }
399 } 381 }
@@ -417,10 +399,139 @@ namespace OpenSim.Services.LLLoginService
417 399
418 } 400 }
419 401
420 private AgentCircuitData LaunchAgent(ISimulationService simConnector, GridRegion region, UserAccount account, 402 private GridRegion FindForeignRegion(string domainName, uint port, string regionName, out GridRegion gatekeeper)
421 AvatarData avatar, UUID session, UUID secureSession, uint circuit, Vector3 position, out string reason) 403 {
404 gatekeeper = new GridRegion();
405 gatekeeper.ExternalHostName = domainName;
406 gatekeeper.HttpPort = port;
407 gatekeeper.RegionName = regionName;
408
409 UUID regionID;
410 ulong handle;
411 string imageURL = string.Empty, reason = string.Empty;
412 if (m_GatekeeperConnector.LinkRegion(gatekeeper, out regionID, out handle, out domainName, out imageURL, out reason))
413 {
414 GridRegion destination = m_GatekeeperConnector.GetHyperlinkRegion(gatekeeper, regionID);
415 return destination;
416 }
417
418 return null;
419 }
420
421 private string hostName = string.Empty;
422 private int port = 0;
423
424 private void SetHostAndPort(string url)
425 {
426 try
427 {
428 Uri uri = new Uri(url);
429 hostName = uri.Host;
430 port = uri.Port;
431 }
432 catch
433 {
434 m_log.WarnFormat("[LLLogin SERVICE]: Unable to parse GatekeeperURL {0}", url);
435 }
436 }
437
438 private AgentCircuitData LaunchAgentAtGrid(GridRegion gatekeeper, GridRegion destination, UserAccount account, AvatarData avatar,
439 UUID session, UUID secureSession, Vector3 position, string currentWhere, out string where, out string reason)
422 { 440 {
441 where = currentWhere;
442 ISimulationService simConnector = null;
423 reason = string.Empty; 443 reason = string.Empty;
444 uint circuitCode = 0;
445 AgentCircuitData aCircuit = null;
446
447 if (m_UserAgentService == null)
448 {
449 // HG standalones have both a localSimulatonDll and a remoteSimulationDll
450 // non-HG standalones have just a localSimulationDll
451 // independent login servers have just a remoteSimulationDll
452 if (m_LocalSimulationService != null)
453 simConnector = m_LocalSimulationService;
454 else if (m_RemoteSimulationService != null)
455 simConnector = m_RemoteSimulationService;
456 }
457 else // User Agent Service is on
458 {
459 if (gatekeeper == null) // login to local grid
460 {
461 if (hostName == string.Empty)
462 SetHostAndPort(m_GatekeeperURL);
463
464 gatekeeper = new GridRegion(destination);
465 gatekeeper.ExternalHostName = hostName;
466 gatekeeper.HttpPort = (uint)port;
467
468 }
469 else // login to foreign grid
470 {
471 }
472 }
473
474 bool success = false;
475
476 if (m_UserAgentService == null && simConnector != null)
477 {
478 circuitCode = (uint)Util.RandomClass.Next(); ;
479 aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position);
480 success = LaunchAgentDirectly(simConnector, destination, aCircuit, out reason);
481 if (!success && m_GridService != null)
482 {
483 // Try the fallback regions
484 List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.ScopeID, destination.RegionLocX, destination.RegionLocY);
485 if (fallbacks != null)
486 {
487 foreach (GridRegion r in fallbacks)
488 {
489 success = LaunchAgentDirectly(simConnector, r, aCircuit, out reason);
490 if (success)
491 {
492 where = "safe";
493 destination = r;
494 break;
495 }
496 }
497 }
498 }
499 }
500
501 if (m_UserAgentService != null)
502 {
503 circuitCode = (uint)Util.RandomClass.Next(); ;
504 aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position);
505 success = LaunchAgentIndirectly(gatekeeper, destination, aCircuit, out reason);
506 if (!success && m_GridService != null)
507 {
508 // Try the fallback regions
509 List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.ScopeID, destination.RegionLocX, destination.RegionLocY);
510 if (fallbacks != null)
511 {
512 foreach (GridRegion r in fallbacks)
513 {
514 success = LaunchAgentIndirectly(gatekeeper, r, aCircuit, out reason);
515 if (success)
516 {
517 where = "safe";
518 destination = r;
519 break;
520 }
521 }
522 }
523 }
524 }
525
526 if (success)
527 return aCircuit;
528 else
529 return null;
530 }
531
532 private AgentCircuitData MakeAgent(GridRegion region, UserAccount account,
533 AvatarData avatar, UUID session, UUID secureSession, uint circuit, Vector3 position)
534 {
424 AgentCircuitData aCircuit = new AgentCircuitData(); 535 AgentCircuitData aCircuit = new AgentCircuitData();
425 536
426 aCircuit.AgentID = account.PrincipalID; 537 aCircuit.AgentID = account.PrincipalID;
@@ -442,10 +553,13 @@ namespace OpenSim.Services.LLLoginService
442 aCircuit.startpos = position; 553 aCircuit.startpos = position;
443 SetServiceURLs(aCircuit, account); 554 SetServiceURLs(aCircuit, account);
444 555
445 if (simConnector.CreateAgent(region, aCircuit, 0, out reason)) 556 return aCircuit;
446 return aCircuit;
447 557
448 return null; 558 //m_UserAgentService.LoginAgentToGrid(aCircuit, GatekeeperServiceConnector, region, out reason);
559 //if (simConnector.CreateAgent(region, aCircuit, 0, out reason))
560 // return aCircuit;
561
562 //return null;
449 563
450 } 564 }
451 565
@@ -468,6 +582,16 @@ namespace OpenSim.Services.LLLoginService
468 } 582 }
469 } 583 }
470 584
585 private bool LaunchAgentDirectly(ISimulationService simConnector, GridRegion region, AgentCircuitData aCircuit, out string reason)
586 {
587 return simConnector.CreateAgent(region, aCircuit, (int)Constants.TeleportFlags.ViaLogin, out reason);
588 }
589
590 private bool LaunchAgentIndirectly(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, out string reason)
591 {
592 return m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, out reason);
593 }
594
471 #region Console Commands 595 #region Console Commands
472 private void RegisterCommands() 596 private void RegisterCommands()
473 { 597 {
diff --git a/bin/config-include/StandaloneHypergrid.ini b/bin/config-include/StandaloneHypergrid.ini
index 98e37e3..9897149 100644
--- a/bin/config-include/StandaloneHypergrid.ini
+++ b/bin/config-include/StandaloneHypergrid.ini
@@ -72,23 +72,6 @@
72 72
73 AllowHypergridMapSearch = true 73 AllowHypergridMapSearch = true
74 74
75[HypergridService]
76 GridService = "OpenSim.Services.GridService.dll:GridService"
77 AssetService = "OpenSim.Services.AssetService.dll:AssetService"
78
79[GatekeeperService]
80 LocalServiceModule = "OpenSim.Services.HypergridService.dll:GatekeeperService"
81 ;; for the service
82 UserAccountService = "OpenSim.Services.UserAccountService.dll:UserAccountService"
83 PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService"
84 GridService = "OpenSim.Services.GridService.dll:GridService"
85 AuthenticationService = "OpenSim.Services.Connectors.dll:AuthenticationServicesConnector"
86 ; how does the outside world reach me? This acts as public key too.
87 ExternalName = "http://127.0.0.1:9000"
88
89[HGEntityTransferModule]
90 HomeUsersSecurityService = "OpenSim.Services.HypergridService.dll:HomeUsersSecurityService"
91
92[PresenceService] 75[PresenceService]
93 LocalServiceModule = "OpenSim.Services.PresenceService.dll:PresenceService" 76 LocalServiceModule = "OpenSim.Services.PresenceService.dll:PresenceService"
94 77
@@ -100,9 +83,11 @@
100 GridService = "OpenSim.Services.GridService.dll:GridService" 83 GridService = "OpenSim.Services.GridService.dll:GridService"
101 InventoryService = "OpenSim.Services.InventoryService.dll:InventoryService" 84 InventoryService = "OpenSim.Services.InventoryService.dll:InventoryService"
102 85
86
103[LoginService] 87[LoginService]
104 LocalServiceModule = "OpenSim.Services.LLLoginService.dll:LLLoginService" 88 LocalServiceModule = "OpenSim.Services.LLLoginService.dll:LLLoginService"
105 UserAccountService = "OpenSim.Services.UserAccountService.dll:UserAccountService" 89 UserAccountService = "OpenSim.Services.UserAccountService.dll:UserAccountService"
90 UserAgentService = "OpenSim.Services.HypergridService.dll:UserAgentService"
106 AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" 91 AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"
107 InventoryService = "OpenSim.Services.InventoryService.dll:InventoryService" 92 InventoryService = "OpenSim.Services.InventoryService.dll:InventoryService"
108 PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService" 93 PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService"
@@ -113,7 +98,24 @@
113 WelcomeMessage = "Welcome, Avatar!" 98 WelcomeMessage = "Welcome, Avatar!"
114 99
115 HomeURI = "http://127.0.0.1:9000" 100 HomeURI = "http://127.0.0.1:9000"
116 GatewayURI = "http://127.0.0.1:9000" 101 GatekeeperURI = "http://127.0.0.1:9000"
117 InventoryServerURI = "http://127.0.0.1:9000" 102 InventoryServerURI = "http://127.0.0.1:9000"
118 AssetServerURI = "http://127.0.0.1:9000" 103 AssetServerURI = "http://127.0.0.1:9000"
119 104
105[GatekeeperService]
106 LocalServiceModule = "OpenSim.Services.HypergridService.dll:GatekeeperService"
107 ;; for the service
108 UserAccountService = "OpenSim.Services.UserAccountService.dll:UserAccountService"
109 UserAgentService = "OpenSim.Services.Hypergrid.dll:UserAgentService"
110 PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService"
111 GridService = "OpenSim.Services.GridService.dll:GridService"
112 AuthenticationService = "OpenSim.Services.Connectors.dll:AuthenticationServicesConnector"
113 ; how does the outside world reach me? This acts as public key too.
114 ExternalName = "http://127.0.0.1:9000"
115
116[UserAgentService]
117 LocalServiceModule = "OpenSim.Services.HypergridService.dll:UserAgentService"
118 ;; for the service
119 PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService"
120 GridService = "OpenSim.Services.GridService.dll:GridService"
121
diff --git a/prebuild.xml b/prebuild.xml
index 3ad1a2f..ca2871f 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -1181,6 +1181,7 @@
1181 <Reference name="OpenSim.Framework.Console"/> 1181 <Reference name="OpenSim.Framework.Console"/>
1182 <Reference name="OpenSim.Framework.Servers.HttpServer"/> 1182 <Reference name="OpenSim.Framework.Servers.HttpServer"/>
1183 <Reference name="OpenSim.Services.Interfaces"/> 1183 <Reference name="OpenSim.Services.Interfaces"/>
1184 <Reference name="OpenSim.Services.Connectors"/>
1184 <Reference name="OpenSim.Services.Base"/> 1185 <Reference name="OpenSim.Services.Base"/>
1185 <Reference name="OpenSim.Server.Base"/> 1186 <Reference name="OpenSim.Server.Base"/>
1186 <Reference name="OpenMetaverseTypes.dll"/> 1187 <Reference name="OpenMetaverseTypes.dll"/>