diff options
author | Diva Canto | 2010-01-28 19:19:42 -0800 |
---|---|---|
committer | Diva Canto | 2010-01-28 19:19:42 -0800 |
commit | 00f7d622cbc2c2e61d2efaacd8275da3f9821d8b (patch) | |
tree | 1bfc6dd3ac2a93443bc75baa03ceefba4cfacc1e /OpenSim/Services | |
parent | Added ExternalName config on Gatekeeper. (diff) | |
download | opensim-SC-00f7d622cbc2c2e61d2efaacd8275da3f9821d8b.zip opensim-SC-00f7d622cbc2c2e61d2efaacd8275da3f9821d8b.tar.gz opensim-SC-00f7d622cbc2c2e61d2efaacd8275da3f9821d8b.tar.bz2 opensim-SC-00f7d622cbc2c2e61d2efaacd8275da3f9821d8b.tar.xz |
HG 1.5 is in place. Tested in standalone only.
Diffstat (limited to '')
9 files changed, 816 insertions, 405 deletions
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 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using System.Net; | ||
5 | using System.Reflection; | ||
6 | |||
7 | using OpenSim.Services.Interfaces; | ||
8 | |||
9 | using OpenMetaverse; | ||
10 | using log4net; | ||
11 | using Nwc.XmlRpc; | ||
12 | using Nini.Config; | ||
13 | |||
14 | namespace 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 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using System.IO; | ||
5 | using System.Net; | ||
6 | using System.Reflection; | ||
7 | using System.Text; | ||
8 | |||
9 | using OpenSim.Framework; | ||
10 | using OpenSim.Services.Interfaces; | ||
11 | using OpenSim.Services.Connectors.Simulation; | ||
12 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
13 | |||
14 | using OpenMetaverse; | ||
15 | using OpenMetaverse.StructuredData; | ||
16 | using log4net; | ||
17 | using Nwc.XmlRpc; | ||
18 | using Nini.Config; | ||
19 | |||
20 | namespace 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; | |||
34 | using OpenSim.Services.Interfaces; | 34 | using OpenSim.Services.Interfaces; |
35 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 35 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
36 | using OpenSim.Server.Base; | 36 | using OpenSim.Server.Base; |
37 | using OpenSim.Services.Connectors.Hypergrid; | ||
37 | 38 | ||
38 | using OpenMetaverse; | 39 | using 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 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Net; | ||
4 | using System.Reflection; | ||
5 | |||
6 | using OpenSim.Services.Interfaces; | ||
7 | |||
8 | using OpenMetaverse; | ||
9 | using log4net; | ||
10 | using Nini.Config; | ||
11 | |||
12 | namespace 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 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Net; | ||
4 | using System.Reflection; | ||
5 | |||
6 | using OpenSim.Framework; | ||
7 | using OpenSim.Services.Connectors.Hypergrid; | ||
8 | using OpenSim.Services.Interfaces; | ||
9 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
10 | using OpenSim.Server.Base; | ||
11 | |||
12 | using OpenMetaverse; | ||
13 | using log4net; | ||
14 | using Nini.Config; | ||
15 | |||
16 | namespace 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; | |||
14 | using OpenSim.Server.Base; | 14 | using OpenSim.Server.Base; |
15 | using OpenSim.Services.Interfaces; | 15 | using OpenSim.Services.Interfaces; |
16 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 16 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
17 | using OpenSim.Services.Connectors.Hypergrid; | ||
17 | 18 | ||
18 | namespace OpenSim.Services.LLLoginService | 19 | namespace 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 | { |