aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml4
-rw-r--r--OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs484
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs129
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs303
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs560
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs84
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs183
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs131
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs65
9 files changed, 1661 insertions, 282 deletions
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
index f9e61aa..8f82718 100644
--- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
+++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
@@ -38,11 +38,15 @@
38 <RegionModule id="RemoteLandServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Land.RemoteLandServicesConnector" /> 38 <RegionModule id="RemoteLandServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Land.RemoteLandServicesConnector" />
39 <RegionModule id="LocalInterregionComms" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion.LocalInterregionComms" /> 39 <RegionModule id="LocalInterregionComms" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion.LocalInterregionComms" />
40 <RegionModule id="RESTInterregionComms" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion.RESTInterregionComms" /> 40 <RegionModule id="RESTInterregionComms" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion.RESTInterregionComms" />
41 <RegionModule id="LocalGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.LocalGridServicesConnector" />
42 <RegionModule id="RemoteGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.RemoteGridServicesConnector" />
43 <RegionModule id="HGGridConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.HGGridConnector" />
41 <!-- Service connectors IN modules --> 44 <!-- Service connectors IN modules -->
42 <RegionModule id="AssetServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset.AssetServiceInConnectorModule" /> 45 <RegionModule id="AssetServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset.AssetServiceInConnectorModule" />
43 <RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" /> 46 <RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" />
44 <RegionModule id="LandServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Land.LandServiceInConnectorModule" /> 47 <RegionModule id="LandServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Land.LandServiceInConnectorModule" />
45 <RegionModule id="NeighbourServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour.NeighbourServiceInConnectorModule" /> \ 48 <RegionModule id="NeighbourServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour.NeighbourServiceInConnectorModule" /> \
49 <RegionModule id="HypergridServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid.HypergridServiceInConnectorModule" /> \
46 50
47 </Extension> 51 </Extension>
48 52
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
index 2d81e4c..8b7a878 100644
--- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
@@ -54,12 +54,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
54 { 54 {
55 public UUID requestID; 55 public UUID requestID;
56 public Dictionary<string, string> headers; 56 public Dictionary<string, string> headers;
57 public string body; 57 public string body;
58 public int responseCode; 58 public int responseCode;
59 public string responseBody; 59 public string responseBody;
60 public ManualResetEvent ev; 60 public ManualResetEvent ev;
61 public bool requestDone; 61 public bool requestDone;
62 public int startTime; 62 public int startTime;
63 public string uri; 63 public string uri;
64 } 64 }
65 65
@@ -73,23 +73,23 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
73 new Dictionary<UUID, UrlData>(); 73 new Dictionary<UUID, UrlData>();
74 74
75 private Dictionary<string, UrlData> m_UrlMap = 75 private Dictionary<string, UrlData> m_UrlMap =
76 new Dictionary<string, UrlData>(); 76 new Dictionary<string, UrlData>();
77 77
78 78
79 private int m_TotalUrls = 100; 79 private int m_TotalUrls = 100;
80 80
81 private IHttpServer m_HttpServer = null; 81 private IHttpServer m_HttpServer = null;
82 82
83 private string m_ExternalHostNameForLSL = ""; 83 private string m_ExternalHostNameForLSL = "";
84 84
85 public Type ReplaceableInterface 85 public Type ReplaceableInterface
86 { 86 {
87 get { return null; } 87 get { return null; }
88 } 88 }
89 89
90 private Hashtable HandleHttpPoll(Hashtable request) 90 private Hashtable HandleHttpPoll(Hashtable request)
91 { 91 {
92 return new Hashtable(); 92 return new Hashtable();
93 } 93 }
94 94
95 public string Name 95 public string Name
@@ -98,7 +98,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
98 } 98 }
99 99
100 public void Initialise(IConfigSource config) 100 public void Initialise(IConfigSource config)
101 { 101 {
102 m_ExternalHostNameForLSL = config.Configs["Network"].GetString("ExternalHostNameForLSL", System.Environment.MachineName); 102 m_ExternalHostNameForLSL = config.Configs["Network"].GetString("ExternalHostNameForLSL", System.Environment.MachineName);
103 } 103 }
104 104
@@ -130,7 +130,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
130 130
131 public void Close() 131 public void Close()
132 { 132 {
133 } 133 }
134 public UUID RequestURL(IScriptModule engine, SceneObjectPart host, UUID itemID) 134 public UUID RequestURL(IScriptModule engine, SceneObjectPart host, UUID itemID)
135 { 135 {
136 UUID urlcode = UUID.Random(); 136 UUID urlcode = UUID.Random();
@@ -141,8 +141,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
141 { 141 {
142 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); 142 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" });
143 return urlcode; 143 return urlcode;
144 } 144 }
145 string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; 145 string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/";
146 146
147 UrlData urlData = new UrlData(); 147 UrlData urlData = new UrlData();
148 urlData.hostID = host.UUID; 148 urlData.hostID = host.UUID;
@@ -152,14 +152,14 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
152 urlData.urlcode = urlcode; 152 urlData.urlcode = urlcode;
153 urlData.requests = new Dictionary<UUID, RequestData>(); 153 urlData.requests = new Dictionary<UUID, RequestData>();
154 154
155 155
156 m_UrlMap[url] = urlData; 156 m_UrlMap[url] = urlData;
157 157
158 string uri = "/lslhttp/" + urlcode.ToString() + "/"; 158 string uri = "/lslhttp/" + urlcode.ToString() + "/";
159 159
160 m_HttpServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll, 160 m_HttpServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll,
161 new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents, 161 new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents,
162 urlcode)); 162 urlcode));
163 163
164 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); 164 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url });
165 } 165 }
@@ -180,11 +180,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
180 { 180 {
181 lock (m_UrlMap) 181 lock (m_UrlMap)
182 { 182 {
183 UrlData data; 183 UrlData data;
184 184
185 if (!m_UrlMap.TryGetValue(url, out data)) 185 if (!m_UrlMap.TryGetValue(url, out data))
186 { 186 {
187 return; 187 return;
188 } 188 }
189 189
190 foreach (UUID req in data.requests.Keys) 190 foreach (UUID req in data.requests.Keys)
@@ -196,36 +196,36 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
196 } 196 }
197 197
198 public void HttpResponse(UUID request, int status, string body) 198 public void HttpResponse(UUID request, int status, string body)
199 { 199 {
200 if (m_RequestMap.ContainsKey(request)) 200 if (m_RequestMap.ContainsKey(request))
201 { 201 {
202 UrlData urlData = m_RequestMap[request]; 202 UrlData urlData = m_RequestMap[request];
203 RequestData requestData=urlData.requests[request]; 203 RequestData requestData=urlData.requests[request];
204 urlData.requests[request].responseCode = status; 204 urlData.requests[request].responseCode = status;
205 urlData.requests[request].responseBody = body; 205 urlData.requests[request].responseBody = body;
206 //urlData.requests[request].ev.Set(); 206 //urlData.requests[request].ev.Set();
207 urlData.requests[request].requestDone=true; 207 urlData.requests[request].requestDone=true;
208 } 208 }
209 else 209 else
210 { 210 {
211 m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString()); 211 m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString());
212 } 212 }
213 } 213 }
214 214
215 public string GetHttpHeader(UUID requestId, string header) 215 public string GetHttpHeader(UUID requestId, string header)
216 { 216 {
217 if (m_RequestMap.ContainsKey(requestId)) 217 if (m_RequestMap.ContainsKey(requestId))
218 { 218 {
219 UrlData urlData=m_RequestMap[requestId]; 219 UrlData urlData=m_RequestMap[requestId];
220 string value; 220 string value;
221 if (urlData.requests[requestId].headers.TryGetValue(header,out value)) 221 if (urlData.requests[requestId].headers.TryGetValue(header,out value))
222 return value; 222 return value;
223 } 223 }
224 else 224 else
225 { 225 {
226 m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId); 226 m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId);
227 } 227 }
228 return String.Empty; 228 return String.Empty;
229 } 229 }
230 230
231 public int GetFreeUrls() 231 public int GetFreeUrls()
@@ -275,63 +275,63 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
275 foreach (string urlname in removeURLs) 275 foreach (string urlname in removeURLs)
276 m_UrlMap.Remove(urlname); 276 m_UrlMap.Remove(urlname);
277 } 277 }
278 } 278 }
279 279
280 280
281 private void RemoveUrl(UrlData data) 281 private void RemoveUrl(UrlData data)
282 { 282 {
283 m_HttpServer.RemoveHTTPHandler("", "/lslhttp/"+data.urlcode.ToString()+"/"); 283 m_HttpServer.RemoveHTTPHandler("", "/lslhttp/"+data.urlcode.ToString()+"/");
284 } 284 }
285 285
286 private Hashtable NoEvents(UUID requestID, UUID sessionID) 286 private Hashtable NoEvents(UUID requestID, UUID sessionID)
287 { 287 {
288 Hashtable response = new Hashtable(); 288 Hashtable response = new Hashtable();
289 UrlData url; 289 UrlData url;
290 lock (m_RequestMap) 290 lock (m_RequestMap)
291 { 291 {
292 if (!m_RequestMap.ContainsKey(requestID)) 292 if (!m_RequestMap.ContainsKey(requestID))
293 return response; 293 return response;
294 url = m_RequestMap[requestID]; 294 url = m_RequestMap[requestID];
295 } 295 }
296 296
297 if (System.Environment.TickCount - url.requests[requestID].startTime > 25000) 297 if (System.Environment.TickCount - url.requests[requestID].startTime > 25000)
298 { 298 {
299 response["int_response_code"] = 500; 299 response["int_response_code"] = 500;
300 response["str_response_string"] = "Script timeout"; 300 response["str_response_string"] = "Script timeout";
301 response["content_type"] = "text/plain"; 301 response["content_type"] = "text/plain";
302 response["keepalive"] = false; 302 response["keepalive"] = false;
303 response["reusecontext"] = false; 303 response["reusecontext"] = false;
304 304
305 //remove from map 305 //remove from map
306 lock (url) 306 lock (url)
307 { 307 {
308 url.requests.Remove(requestID); 308 url.requests.Remove(requestID);
309 m_RequestMap.Remove(requestID); 309 m_RequestMap.Remove(requestID);
310 } 310 }
311 311
312 return response; 312 return response;
313 } 313 }
314 314
315 315
316 return response; 316 return response;
317 } 317 }
318 318
319 private bool HasEvents(UUID requestID, UUID sessionID) 319 private bool HasEvents(UUID requestID, UUID sessionID)
320 { 320 {
321 UrlData url=null; 321 UrlData url=null;
322 322
323 lock (m_RequestMap) 323 lock (m_RequestMap)
324 { 324 {
325 if (!m_RequestMap.ContainsKey(requestID)) 325 if (!m_RequestMap.ContainsKey(requestID))
326 { 326 {
327 return false; 327 return false;
328 }
329 url = m_RequestMap[requestID];
330 if (!url.requests.ContainsKey(requestID))
331 {
332 return false;
333 } 328 }
334 } 329 url = m_RequestMap[requestID];
330 if (!url.requests.ContainsKey(requestID))
331 {
332 return false;
333 }
334 }
335 335
336 if (System.Environment.TickCount-url.requests[requestID].startTime>25000) 336 if (System.Environment.TickCount-url.requests[requestID].startTime>25000)
337 { 337 {
@@ -343,146 +343,146 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
343 else 343 else
344 return false; 344 return false;
345 345
346 } 346 }
347 private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) 347 private Hashtable GetEvents(UUID requestID, UUID sessionID, string request)
348 { 348 {
349 UrlData url = null; 349 UrlData url = null;
350 RequestData requestData = null; 350 RequestData requestData = null;
351 351
352 lock (m_RequestMap) 352 lock (m_RequestMap)
353 { 353 {
354 if (!m_RequestMap.ContainsKey(requestID)) 354 if (!m_RequestMap.ContainsKey(requestID))
355 return NoEvents(requestID,sessionID); 355 return NoEvents(requestID,sessionID);
356 url = m_RequestMap[requestID]; 356 url = m_RequestMap[requestID];
357 requestData = url.requests[requestID]; 357 requestData = url.requests[requestID];
358 } 358 }
359 359
360 if (!requestData.requestDone) 360 if (!requestData.requestDone)
361 return NoEvents(requestID,sessionID); 361 return NoEvents(requestID,sessionID);
362 362
363 Hashtable response = new Hashtable(); 363 Hashtable response = new Hashtable();
364 364
365 if (System.Environment.TickCount - requestData.startTime > 25000) 365 if (System.Environment.TickCount - requestData.startTime > 25000)
366 { 366 {
367 response["int_response_code"] = 500; 367 response["int_response_code"] = 500;
368 response["str_response_string"] = "Script timeout"; 368 response["str_response_string"] = "Script timeout";
369 response["content_type"] = "text/plain"; 369 response["content_type"] = "text/plain";
370 response["keepalive"] = false; 370 response["keepalive"] = false;
371 response["reusecontext"] = false; 371 response["reusecontext"] = false;
372 return response; 372 return response;
373 } 373 }
374 //put response 374 //put response
375 response["int_response_code"] = requestData.responseCode; 375 response["int_response_code"] = requestData.responseCode;
376 response["str_response_string"] = requestData.responseBody; 376 response["str_response_string"] = requestData.responseBody;
377 response["content_type"] = "text/plain"; 377 response["content_type"] = "text/plain";
378 response["keepalive"] = false; 378 response["keepalive"] = false;
379 response["reusecontext"] = false; 379 response["reusecontext"] = false;
380 380
381 //remove from map 381 //remove from map
382 lock (url) 382 lock (url)
383 { 383 {
384 url.requests.Remove(requestID); 384 url.requests.Remove(requestID);
385 m_RequestMap.Remove(requestID); 385 m_RequestMap.Remove(requestID);
386 } 386 }
387 387
388 return response; 388 return response;
389 } 389 }
390 public void HttpRequestHandler(UUID requestID, Hashtable request) 390 public void HttpRequestHandler(UUID requestID, Hashtable request)
391 { 391 {
392 lock (request) 392 lock (request)
393 { 393 {
394 string uri = request["uri"].ToString(); 394 string uri = request["uri"].ToString();
395 395
396 try 396 try
397 { 397 {
398 Hashtable headers = (Hashtable)request["headers"]; 398 Hashtable headers = (Hashtable)request["headers"];
399 399
400 string uri_full = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/"; 400 string uri_full = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/";
401 401
402 int pos1 = uri.IndexOf("/");// /lslhttp 402 int pos1 = uri.IndexOf("/");// /lslhttp
403 int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/ 403 int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/
404 int pos3 = uri.IndexOf("/", pos2 + 1);// /lslhttp/<UUID>/ 404 int pos3 = uri.IndexOf("/", pos2 + 1);// /lslhttp/<UUID>/
405 string uri_tmp = uri.Substring(0, pos3 + 1); 405 string uri_tmp = uri.Substring(0, pos3 + 1);
406 //HTTP server code doesn't provide us with QueryStrings 406 //HTTP server code doesn't provide us with QueryStrings
407 string pathInfo; 407 string pathInfo;
408 string queryString; 408 string queryString;
409 queryString = ""; 409 queryString = "";
410 410
411 pathInfo = uri.Substring(pos3); 411 pathInfo = uri.Substring(pos3);
412 412
413 UrlData url = m_UrlMap["http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp]; 413 UrlData url = m_UrlMap["http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp];
414 414
415 //for llGetHttpHeader support we need to store original URI here 415 //for llGetHttpHeader support we need to store original URI here
416 //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers 416 //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers
417 //as per http://wiki.secondlife.com/wiki/LlGetHTTPHeader 417 //as per http://wiki.secondlife.com/wiki/LlGetHTTPHeader
418 418
419 RequestData requestData = new RequestData(); 419 RequestData requestData = new RequestData();
420 requestData.requestID = requestID; 420 requestData.requestID = requestID;
421 requestData.requestDone = false; 421 requestData.requestDone = false;
422 requestData.startTime = System.Environment.TickCount; 422 requestData.startTime = System.Environment.TickCount;
423 requestData.uri = uri; 423 requestData.uri = uri;
424 if (requestData.headers == null) 424 if (requestData.headers == null)
425 requestData.headers = new Dictionary<string, string>(); 425 requestData.headers = new Dictionary<string, string>();
426 426
427 foreach (DictionaryEntry header in headers) 427 foreach (DictionaryEntry header in headers)
428 { 428 {
429 string key = (string)header.Key; 429 string key = (string)header.Key;
430 string value = (string)header.Value; 430 string value = (string)header.Value;
431 requestData.headers.Add(key, value); 431 requestData.headers.Add(key, value);
432 } 432 }
433 foreach (DictionaryEntry de in request) 433 foreach (DictionaryEntry de in request)
434 { 434 {
435 if (de.Key.ToString() == "querystringkeys") 435 if (de.Key.ToString() == "querystringkeys")
436 { 436 {
437 System.String[] keys = (System.String[])de.Value; 437 System.String[] keys = (System.String[])de.Value;
438 foreach (String key in keys) 438 foreach (String key in keys)
439 { 439 {
440 if (request.ContainsKey(key)) 440 if (request.ContainsKey(key))
441 { 441 {
442 string val = (String)request[key]; 442 string val = (String)request[key];
443 queryString = queryString + key + "=" + val + "&"; 443 queryString = queryString + key + "=" + val + "&";
444 } 444 }
445 } 445 }
446 if (queryString.Length > 1) 446 if (queryString.Length > 1)
447 queryString = queryString.Substring(0, queryString.Length - 1); 447 queryString = queryString.Substring(0, queryString.Length - 1);
448 448
449 } 449 }
450 450
451 } 451 }
452 452
453 //if this machine is behind DNAT/port forwarding, currently this is being 453 //if this machine is behind DNAT/port forwarding, currently this is being
454 //set to address of port forwarding router 454 //set to address of port forwarding router
455 requestData.headers["x-remote-ip"] = requestData.headers["remote_addr"]; 455 requestData.headers["x-remote-ip"] = requestData.headers["remote_addr"];
456 requestData.headers["x-path-info"] = pathInfo; 456 requestData.headers["x-path-info"] = pathInfo;
457 requestData.headers["x-query-string"] = queryString; 457 requestData.headers["x-query-string"] = queryString;
458 requestData.headers["x-script-url"] = url.url; 458 requestData.headers["x-script-url"] = url.url;
459 459
460 requestData.ev = new ManualResetEvent(false); 460 requestData.ev = new ManualResetEvent(false);
461 lock (url.requests) 461 lock (url.requests)
462 { 462 {
463 url.requests.Add(requestID, requestData); 463 url.requests.Add(requestID, requestData);
464 } 464 }
465 lock (m_RequestMap) 465 lock (m_RequestMap)
466 { 466 {
467 //add to request map 467 //add to request map
468 m_RequestMap.Add(requestID, url); 468 m_RequestMap.Add(requestID, url);
469 } 469 }
470 470
471 url.engine.PostScriptEvent(url.itemID, "http_request", new Object[] { requestID.ToString(), request["http-method"].ToString(), request["body"].ToString() }); 471 url.engine.PostScriptEvent(url.itemID, "http_request", new Object[] { requestID.ToString(), request["http-method"].ToString(), request["body"].ToString() });
472 472
473 //send initial response? 473 //send initial response?
474 Hashtable response = new Hashtable(); 474 Hashtable response = new Hashtable();
475 475
476 return; 476 return;
477 477
478 } 478 }
479 catch (Exception we) 479 catch (Exception we)
480 { 480 {
481 //Hashtable response = new Hashtable(); 481 //Hashtable response = new Hashtable();
482 m_log.Warn("[HttpRequestHandler]: http-in request failed"); 482 m_log.Warn("[HttpRequestHandler]: http-in request failed");
483 m_log.Warn(we.Message); 483 m_log.Warn(we.Message);
484 m_log.Warn(we.StackTrace); 484 m_log.Warn(we.StackTrace);
485 } 485 }
486 } 486 }
487 } 487 }
488 488
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs
new file mode 100644
index 0000000..4fbee7f
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs
@@ -0,0 +1,129 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using System.Collections.Generic;
31using log4net;
32using Nini.Config;
33using OpenSim.Framework;
34using OpenSim.Framework.Servers.HttpServer;
35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Server.Base;
38using OpenSim.Server.Handlers.Base;
39using OpenSim.Server.Handlers.Grid;
40
41namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
42{
43 public class HypergridServiceInConnectorModule : ISharedRegionModule
44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 private static bool m_Enabled = false;
47
48 private IConfigSource m_Config;
49 bool m_Registered = false;
50 HypergridServiceInConnector m_HypergridHandler;
51
52 #region IRegionModule interface
53
54 public void Initialise(IConfigSource config)
55 {
56 //// This module is only on for standalones in hypergrid mode
57 //enabled = (!config.Configs["Startup"].GetBoolean("gridmode", true)) &&
58 // config.Configs["Startup"].GetBoolean("hypergrid", true);
59 //m_log.DebugFormat("[RegionInventoryService]: enabled? {0}", enabled);
60 m_Config = config;
61 IConfig moduleConfig = config.Configs["Modules"];
62 if (moduleConfig != null)
63 {
64 m_Enabled = moduleConfig.GetBoolean("HypergridServiceInConnector", false);
65 if (m_Enabled)
66 {
67 m_log.Info("[HGGRID IN CONNECTOR]: Hypergrid Service In Connector enabled");
68 }
69
70 }
71
72 }
73
74 public void PostInitialise()
75 {
76 }
77
78 public void Close()
79 {
80 }
81
82 public Type ReplaceableInterface
83 {
84 get { return null; }
85 }
86
87 public string Name
88 {
89 get { return "HypergridService"; }
90 }
91
92 public void AddRegion(Scene scene)
93 {
94 if (!m_Enabled)
95 return;
96
97 if (!m_Registered)
98 {
99 m_Registered = true;
100
101 m_log.Info("[HypergridService]: Starting...");
102
103 Object[] args = new Object[] { m_Config, MainServer.Instance };
104
105 m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance);
106 //ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args);
107 }
108
109 SimpleRegionInfo rinfo = new SimpleRegionInfo(scene.RegionInfo);
110 m_HypergridHandler.AddRegion(rinfo);
111 }
112
113 public void RemoveRegion(Scene scene)
114 {
115 if (!m_Enabled)
116 return;
117
118 SimpleRegionInfo rinfo = new SimpleRegionInfo(scene.RegionInfo);
119 m_HypergridHandler.RemoveRegion(rinfo);
120 }
121
122 public void RegionLoaded(Scene scene)
123 {
124 }
125
126 #endregion
127
128 }
129}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs
new file mode 100644
index 0000000..36915ef
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs
@@ -0,0 +1,303 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Xml;
32using log4net;
33using Nini.Config;
34using OpenSim.Framework;
35//using OpenSim.Framework.Communications;
36using OpenSim.Framework.Console;
37using OpenSim.Region.Framework;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Region.Framework.Scenes.Hypergrid;
40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41
42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
43{
44 public class HGCommands
45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 private HGGridConnector m_HGGridConnector;
48 private Scene m_scene;
49
50 private static uint m_autoMappingX = 0;
51 private static uint m_autoMappingY = 0;
52 private static bool m_enableAutoMapping = false;
53
54 public HGCommands(HGGridConnector hgConnector, Scene scene)
55 {
56 m_HGGridConnector = hgConnector;
57 m_scene = scene;
58 }
59
60 //public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager,
61 // StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version)
62 //{
63 // HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager, HGServices);
64
65 // return
66 // new HGScene(
67 // regionInfo, circuitManager, m_commsManager, sceneGridService, storageManager,
68 // m_moduleLoader, false, m_configSettings.PhysicalPrim,
69 // m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version);
70 //}
71
72 public void RunCommand(string module, string[] cmdparams)
73 {
74 List<string> args = new List<string>(cmdparams);
75 if (args.Count < 1)
76 return;
77
78 string command = args[0];
79 args.RemoveAt(0);
80
81 cmdparams = args.ToArray();
82
83 RunHGCommand(command, cmdparams);
84
85 }
86
87 private void RunHGCommand(string command, string[] cmdparams)
88 {
89 if (command.Equals("linkk-mapping"))
90 {
91 if (cmdparams.Length == 2)
92 {
93 try
94 {
95 m_autoMappingX = Convert.ToUInt32(cmdparams[0]);
96 m_autoMappingY = Convert.ToUInt32(cmdparams[1]);
97 m_enableAutoMapping = true;
98 }
99 catch (Exception)
100 {
101 m_autoMappingX = 0;
102 m_autoMappingY = 0;
103 m_enableAutoMapping = false;
104 }
105 }
106 }
107 else if (command.Equals("linkk-region"))
108 {
109 if (cmdparams.Length < 3)
110 {
111 if ((cmdparams.Length == 1) || (cmdparams.Length == 2))
112 {
113 LoadXmlLinkFile(cmdparams);
114 }
115 else
116 {
117 LinkRegionCmdUsage();
118 }
119 return;
120 }
121
122 if (cmdparams[2].Contains(":"))
123 {
124 // New format
125 int xloc, yloc;
126 string mapName;
127 try
128 {
129 xloc = Convert.ToInt32(cmdparams[0]);
130 yloc = Convert.ToInt32(cmdparams[1]);
131 mapName = cmdparams[2];
132 if (cmdparams.Length > 3)
133 for (int i = 3; i < cmdparams.Length; i++)
134 mapName += " " + cmdparams[i];
135
136 m_log.Info(">> MapName: " + mapName);
137 //internalPort = Convert.ToUInt32(cmdparams[4]);
138 //remotingPort = Convert.ToUInt32(cmdparams[5]);
139 }
140 catch (Exception e)
141 {
142 m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
143 LinkRegionCmdUsage();
144 return;
145 }
146
147 // Convert cell coordinates given by the user to meters
148 xloc = xloc * (int)Constants.RegionSize;
149 yloc = yloc * (int)Constants.RegionSize;
150 m_HGGridConnector.TryLinkRegionToCoords(m_scene, null, mapName, xloc, yloc);
151 }
152 else
153 {
154 // old format
155 GridRegion regInfo;
156 int xloc, yloc;
157 uint externalPort;
158 string externalHostName;
159 try
160 {
161 xloc = Convert.ToInt32(cmdparams[0]);
162 yloc = Convert.ToInt32(cmdparams[1]);
163 externalPort = Convert.ToUInt32(cmdparams[3]);
164 externalHostName = cmdparams[2];
165 //internalPort = Convert.ToUInt32(cmdparams[4]);
166 //remotingPort = Convert.ToUInt32(cmdparams[5]);
167 }
168 catch (Exception e)
169 {
170 m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
171 LinkRegionCmdUsage();
172 return;
173 }
174
175 // Convert cell coordinates given by the user to meters
176 xloc = xloc * (int)Constants.RegionSize;
177 yloc = yloc * (int)Constants.RegionSize;
178 if (m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo))
179 {
180 if (cmdparams.Length >= 5)
181 {
182 regInfo.RegionName = "";
183 for (int i = 4; i < cmdparams.Length; i++)
184 regInfo.RegionName += cmdparams[i] + " ";
185 }
186 }
187 }
188 return;
189 }
190 else if (command.Equals("unlinkk-region"))
191 {
192 if (cmdparams.Length < 1)
193 {
194 UnlinkRegionCmdUsage();
195 return;
196 }
197 if (m_HGGridConnector.TryUnlinkRegion(m_scene, cmdparams[0]))
198 m_log.InfoFormat("[HGrid]: Successfully unlinked {0}", cmdparams[0]);
199 else
200 m_log.InfoFormat("[HGrid]: Unable to unlink {0}, region not found", cmdparams[0]);
201 }
202 }
203
204 private void LoadXmlLinkFile(string[] cmdparams)
205 {
206 //use http://www.hgurl.com/hypergrid.xml for test
207 try
208 {
209 XmlReader r = XmlReader.Create(cmdparams[0]);
210 XmlConfigSource cs = new XmlConfigSource(r);
211 string[] excludeSections = null;
212
213 if (cmdparams.Length == 2)
214 {
215 if (cmdparams[1].ToLower().StartsWith("excludelist:"))
216 {
217 string excludeString = cmdparams[1].ToLower();
218 excludeString = excludeString.Remove(0, 12);
219 char[] splitter = { ';' };
220
221 excludeSections = excludeString.Split(splitter);
222 }
223 }
224
225 for (int i = 0; i < cs.Configs.Count; i++)
226 {
227 bool skip = false;
228 if ((excludeSections != null) && (excludeSections.Length > 0))
229 {
230 for (int n = 0; n < excludeSections.Length; n++)
231 {
232 if (excludeSections[n] == cs.Configs[i].Name.ToLower())
233 {
234 skip = true;
235 break;
236 }
237 }
238 }
239 if (!skip)
240 {
241 ReadLinkFromConfig(cs.Configs[i]);
242 }
243 }
244 }
245 catch (Exception e)
246 {
247 m_log.Error(e.ToString());
248 }
249 }
250
251
252 private void ReadLinkFromConfig(IConfig config)
253 {
254 GridRegion regInfo;
255 int xloc, yloc;
256 uint externalPort;
257 string externalHostName;
258 uint realXLoc, realYLoc;
259
260 xloc = Convert.ToInt32(config.GetString("xloc", "0"));
261 yloc = Convert.ToInt32(config.GetString("yloc", "0"));
262 externalPort = Convert.ToUInt32(config.GetString("externalPort", "0"));
263 externalHostName = config.GetString("externalHostName", "");
264 realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0"));
265 realYLoc = Convert.ToUInt32(config.GetString("real-yloc", "0"));
266
267 if (m_enableAutoMapping)
268 {
269 xloc = (int)((xloc % 100) + m_autoMappingX);
270 yloc = (int)((yloc % 100) + m_autoMappingY);
271 }
272
273 if (((realXLoc == 0) && (realYLoc == 0)) ||
274 (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) &&
275 ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896))))
276 {
277 xloc = xloc * (int)Constants.RegionSize;
278 yloc = yloc * (int)Constants.RegionSize;
279 if (
280 m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort,
281 externalHostName, out regInfo))
282 {
283 regInfo.RegionName = config.GetString("localName", "");
284 }
285 }
286 }
287
288
289 private void LinkRegionCmdUsage()
290 {
291 m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>]");
292 m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]");
293 m_log.Info("Usage: link-region <URI_of_xml> [<exclude>]");
294 }
295
296 private void UnlinkRegionCmdUsage()
297 {
298 m_log.Info("Usage: unlink-region <HostName>:<HttpPort>");
299 m_log.Info("Usage: unlink-region <LocalName>");
300 }
301
302 }
303}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
new file mode 100644
index 0000000..0c2a835
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
@@ -0,0 +1,560 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Net;
31using System.Reflection;
32using System.Xml;
33
34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Region.Framework.Scenes.Hypergrid;
38using OpenSim.Services.Interfaces;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
40using OpenSim.Server.Base;
41using OpenSim.Services.Connectors.Grid;
42using OpenSim.Framework.Console;
43
44using OpenMetaverse;
45using log4net;
46using Nini.Config;
47
48namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
49{
50 public class HGGridConnector : ISharedRegionModule, IGridService
51 {
52 private static readonly ILog m_log =
53 LogManager.GetLogger(
54 MethodBase.GetCurrentMethod().DeclaringType);
55
56 private bool m_Enabled = false;
57 private bool m_Initialized = false;
58
59 private IGridService m_GridServiceConnector;
60 private HypergridServiceConnector m_HypergridServiceConnector;
61
62 // Hyperlink regions are hyperlinks on the map
63 protected Dictionary<UUID, GridRegion> m_HyperlinkRegions = new Dictionary<UUID, GridRegion>();
64
65 // Known regions are home regions of visiting foreign users.
66 // They are not on the map as static hyperlinks. They are dynamic hyperlinks, they go away when
67 // the visitor goes away. They are mapped to X=0 on the map.
68 // This is key-ed on agent ID
69 protected Dictionary<UUID, GridRegion> m_knownRegions = new Dictionary<UUID, GridRegion>();
70
71 protected Dictionary<UUID, ulong> m_HyperlinkHandles = new Dictionary<UUID, ulong>();
72
73 #region ISharedRegionModule
74
75 public Type ReplaceableInterface
76 {
77 get { return null; }
78 }
79
80 public string Name
81 {
82 get { return "HGGridServicesConnector"; }
83 }
84
85 public void Initialise(IConfigSource source)
86 {
87 IConfig moduleConfig = source.Configs["Modules"];
88 if (moduleConfig != null)
89 {
90 string name = moduleConfig.GetString("GridServices", "");
91 if (name == Name)
92 {
93 IConfig gridConfig = source.Configs["GridService"];
94 if (gridConfig == null)
95 {
96 m_log.Error("[HGGRID CONNECTOR]: GridService missing from OpenSim.ini");
97 return;
98 }
99
100
101 InitialiseConnectorModule(source);
102
103 m_Enabled = true;
104 m_log.Info("[HGGRID CONNECTOR]: HG grid enabled");
105 }
106 }
107 }
108
109 private void InitialiseConnectorModule(IConfigSource source)
110 {
111 IConfig gridConfig = source.Configs["GridService"];
112 if (gridConfig == null)
113 {
114 m_log.Error("[HGGRID CONNECTOR]: GridService missing from OpenSim.ini");
115 throw new Exception("Grid connector init error");
116 }
117
118 string module = gridConfig.GetString("GridServiceConnectorModule", String.Empty);
119 if (module == String.Empty)
120 {
121 m_log.Error("[HGGRID CONNECTOR]: No GridServiceConnectorModule named in section GridService");
122 //return;
123 throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's");
124 }
125
126 Object[] args = new Object[] { source };
127 m_GridServiceConnector = ServerUtils.LoadPlugin<IGridService>(module, args);
128
129 }
130
131 public void PostInitialise()
132 {
133 }
134
135 public void Close()
136 {
137 }
138
139 public void AddRegion(Scene scene)
140 {
141 if (!m_Enabled)
142 return;
143
144 scene.RegisterModuleInterface<IGridService>(this);
145
146 }
147
148 public void RemoveRegion(Scene scene)
149 {
150 }
151
152 public void RegionLoaded(Scene scene)
153 {
154 if (!m_Enabled)
155 return;
156
157 if (!m_Initialized)
158 {
159 m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService);
160 HGCommands hgCommands = new HGCommands(this, scene);
161 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "linkk-region",
162 "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
163 "Link a hypergrid region", hgCommands.RunCommand);
164 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "unlinkk-region",
165 "unlink-region <local name> or <HostName>:<HttpPort> <cr>",
166 "Unlink a hypergrid region", hgCommands.RunCommand);
167 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "linkk-mapping", "link-mapping [<x> <y>] <cr>",
168 "Set local coordinate to map HG regions to", hgCommands.RunCommand);
169 m_Initialized = true;
170 }
171
172
173 //scene.AddCommand("HGGridServicesConnector", "linkk-region",
174 // "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
175 // "Link a hypergrid region", hgCommands.RunCommand);
176 //scene.AddCommand("HGGridServicesConnector", "unlinkk-region",
177 // "unlink-region <local name> or <HostName>:<HttpPort> <cr>",
178 // "Unlink a hypergrid region", hgCommands.RunCommand);
179 //scene.AddCommand("HGGridServicesConnector", "linkk-mapping", "link-mapping [<x> <y>] <cr>",
180 // "Set local coordinate to map HG regions to", hgCommands.RunCommand);
181
182 }
183
184 #endregion
185
186 #region IGridService
187
188 public bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
189 {
190 // Region doesn't exist here. Trying to link remote region
191 if (regionInfo.RegionID.Equals(UUID.Zero))
192 {
193 m_log.Info("[HGrid]: Linking remote region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort);
194 ulong regionHandle = 0;
195 regionInfo.RegionID = m_HypergridServiceConnector.LinkRegion(regionInfo, out regionHandle);
196 if (!regionInfo.RegionID.Equals(UUID.Zero))
197 {
198 AddHyperlinkRegion(regionInfo, regionHandle);
199 m_log.Info("[HGrid]: Successfully linked to region_uuid " + regionInfo.RegionID);
200
201 // Try get the map image
202 m_HypergridServiceConnector.GetMapImage(regionInfo);
203 return true;
204 }
205 else
206 {
207 m_log.Info("[HGrid]: No such region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + "(" + regionInfo.InternalEndPoint.Port + ")");
208 return false;
209 }
210 // Note that these remote regions aren't registered in localBackend, so return null, no local listeners
211 }
212 else // normal grid
213 return m_GridServiceConnector.RegisterRegion(scopeID, regionInfo);
214 }
215
216 public bool DeregisterRegion(UUID regionID)
217 {
218 // Try the hyperlink collection
219 if (m_HyperlinkRegions.ContainsKey(regionID))
220 {
221 RemoveHyperlinkRegion(regionID);
222 return true;
223 }
224 // Try the foreign users home collection
225
226 foreach (GridRegion r in m_knownRegions.Values)
227 if (r.RegionID == regionID)
228 {
229 RemoveHyperlinkHomeRegion(regionID);
230 return true;
231 }
232
233 // Finally, try the normal route
234 return m_GridServiceConnector.DeregisterRegion(regionID);
235 }
236
237 public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
238 {
239 // No serving neighbours on hyperliked regions.
240 // Just the regular regions.
241 return m_GridServiceConnector.GetNeighbours(scopeID, regionID);
242 }
243
244 public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
245 {
246 // Try the hyperlink collection
247 if (m_HyperlinkRegions.ContainsKey(regionID))
248 return m_HyperlinkRegions[regionID];
249
250 // Try the foreign users home collection
251 foreach (GridRegion r in m_knownRegions.Values)
252 if (r.RegionID == regionID)
253 return m_knownRegions[regionID];
254
255 // Finally, try the normal route
256 return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID);
257 }
258
259 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
260 {
261 int snapX = (int) (x / Constants.RegionSize) * (int)Constants.RegionSize;
262 int snapY = (int) (y / Constants.RegionSize) * (int)Constants.RegionSize;
263 // Try the hyperlink collection
264 foreach (GridRegion r in m_HyperlinkRegions.Values)
265 {
266 if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY))
267 return r;
268 }
269
270 // Try the foreign users home collection
271 foreach (GridRegion r in m_knownRegions.Values)
272 {
273 if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY))
274 return r;
275 }
276
277 // Finally, try the normal route
278 return m_GridServiceConnector.GetRegionByPosition(scopeID, x, y);
279 }
280
281 public GridRegion GetRegionByName(UUID scopeID, string regionName)
282 {
283 // Try normal grid first
284 GridRegion region = m_GridServiceConnector.GetRegionByName(scopeID, regionName);
285 if (region != null)
286 return region;
287
288 // Try the hyperlink collection
289 foreach (GridRegion r in m_HyperlinkRegions.Values)
290 {
291 if (r.RegionName == regionName)
292 return r;
293 }
294
295 // Try the foreign users home collection
296 foreach (GridRegion r in m_knownRegions.Values)
297 {
298 if (r.RegionName == regionName)
299 return r;
300 }
301 return null;
302 }
303
304 public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
305 {
306 List<GridRegion> rinfos = new List<GridRegion>();
307
308 // Commenting until regionname exists
309 //foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values)
310 // if ((r.RegionName != null) && r.RegionName.StartsWith(name))
311 // rinfos.Add(r);
312
313 rinfos.AddRange(m_GridServiceConnector.GetRegionsByName(scopeID, name, maxNumber));
314 return rinfos;
315 }
316
317 public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
318 {
319 int snapXmin = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize;
320 int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize;
321 int snapYmin = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize;
322 int snapYmax = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize;
323
324 List<GridRegion> rinfos = new List<GridRegion>();
325 foreach (GridRegion r in m_HyperlinkRegions.Values)
326 if ((r.RegionLocX > snapXmin) && (r.RegionLocX < snapYmax) &&
327 (r.RegionLocY > snapYmin) && (r.RegionLocY < snapYmax))
328 rinfos.Add(r);
329
330 rinfos.AddRange(m_GridServiceConnector.GetRegionRange(scopeID, xmin, xmax, ymin, ymax));
331
332 return rinfos;
333 }
334
335 #endregion
336
337 #region Auxiliary
338
339 private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle)
340 {
341 m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo);
342 m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle);
343 }
344
345 private void RemoveHyperlinkRegion(UUID regionID)
346 {
347 m_HyperlinkRegions.Remove(regionID);
348 m_HyperlinkHandles.Remove(regionID);
349 }
350
351 private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle)
352 {
353 m_knownRegions.Add(userID, regionInfo);
354 m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle);
355 }
356
357 private void RemoveHyperlinkHomeRegion(UUID regionID)
358 {
359 foreach (KeyValuePair<UUID, GridRegion> kvp in m_knownRegions)
360 {
361 if (kvp.Value.RegionID == regionID)
362 {
363 m_knownRegions.Remove(kvp.Key);
364 }
365 }
366 m_HyperlinkHandles.Remove(regionID);
367 }
368 #endregion
369
370 #region Hyperlinks
371
372 private static Random random = new Random();
373
374 public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc)
375 {
376 string host = "127.0.0.1";
377 string portstr;
378 string regionName = "";
379 uint port = 9000;
380 string[] parts = mapName.Split(new char[] { ':' });
381 if (parts.Length >= 1)
382 {
383 host = parts[0];
384 }
385 if (parts.Length >= 2)
386 {
387 portstr = parts[1];
388 if (!UInt32.TryParse(portstr, out port))
389 regionName = parts[1];
390 }
391 // always take the last one
392 if (parts.Length >= 3)
393 {
394 regionName = parts[2];
395 }
396
397 // Sanity check. Don't ever link to this sim.
398 IPAddress ipaddr = null;
399 try
400 {
401 ipaddr = Util.GetHostFromDNS(host);
402 }
403 catch { }
404
405 if ((ipaddr != null) &&
406 !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port)))
407 {
408 GridRegion regInfo;
409 bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo);
410 if (success)
411 {
412 regInfo.RegionName = mapName;
413 return regInfo;
414 }
415 }
416
417 return null;
418 }
419
420 // From the map search and secondlife://blah
421 public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName)
422 {
423 int xloc = random.Next(0, Int16.MaxValue);
424 return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0);
425 }
426
427 public bool TryCreateLink(Scene m_scene, IClientAPI client, int xloc, int yloc,
428 string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo)
429 {
430 m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc);
431
432 regInfo = new GridRegion();
433 regInfo.RegionName = externalRegionName;
434 regInfo.HttpPort = externalPort;
435 regInfo.ExternalHostName = externalHostName;
436 regInfo.RegionLocX = xloc;
437 regInfo.RegionLocY = yloc;
438
439 try
440 {
441 regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
442 }
443 catch (Exception e)
444 {
445 m_log.Warn("[HGrid]: Wrong format for link-region: " + e.Message);
446 return false;
447 }
448
449 // Finally, link it
450 try
451 {
452 RegisterRegion(UUID.Zero, regInfo);
453 }
454 catch (Exception e)
455 {
456 m_log.Warn("[HGrid]: Unable to link region: " + e.Message);
457 return false;
458 }
459
460 int x, y;
461 if (!Check4096(m_scene, regInfo, out x, out y))
462 {
463 DeregisterRegion(regInfo.RegionID);
464 if (client != null)
465 client.SendAlertMessage("Region is too far (" + x + ", " + y + ")");
466 m_log.Info("[HGrid]: Unable to link, region is too far (" + x + ", " + y + ")");
467 return false;
468 }
469
470 if (!CheckCoords(m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, x, y))
471 {
472 DeregisterRegion(regInfo.RegionID);
473 if (client != null)
474 client.SendAlertMessage("Region has incompatible coordinates (" + x + ", " + y + ")");
475 m_log.Info("[HGrid]: Unable to link, region has incompatible coordinates (" + x + ", " + y + ")");
476 return false;
477 }
478
479 m_log.Debug("[HGrid]: link region succeeded");
480 return true;
481 }
482
483 public bool TryUnlinkRegion(Scene m_scene, string mapName)
484 {
485 GridRegion regInfo = null;
486 if (mapName.Contains(":"))
487 {
488 string host = "127.0.0.1";
489 //string portstr;
490 //string regionName = "";
491 uint port = 9000;
492 string[] parts = mapName.Split(new char[] { ':' });
493 if (parts.Length >= 1)
494 {
495 host = parts[0];
496 }
497 // if (parts.Length >= 2)
498 // {
499 // portstr = parts[1];
500 // if (!UInt32.TryParse(portstr, out port))
501 // regionName = parts[1];
502 // }
503 // always take the last one
504 // if (parts.Length >= 3)
505 // {
506 // regionName = parts[2];
507 // }
508 foreach (GridRegion r in m_HyperlinkRegions.Values)
509 if (host.Equals(r.ExternalHostName) && (port == r.HttpPort))
510 regInfo = r;
511 }
512 else
513 {
514 foreach (GridRegion r in m_HyperlinkRegions.Values)
515 if (r.RegionName.Equals(mapName))
516 regInfo = r;
517 }
518 if (regInfo != null)
519 {
520 return DeregisterRegion(regInfo.RegionID);
521 }
522 else
523 {
524 m_log.InfoFormat("[HGrid]: Region {0} not found", mapName);
525 return false;
526 }
527 }
528
529 /// <summary>
530 /// Cope with this viewer limitation.
531 /// </summary>
532 /// <param name="regInfo"></param>
533 /// <returns></returns>
534 public bool Check4096(Scene m_scene, GridRegion regInfo, out int x, out int y)
535 {
536 ulong realHandle = m_HyperlinkHandles[regInfo.RegionID];
537 uint ux = 0, uy = 0;
538 Utils.LongToUInts(realHandle, out ux, out uy);
539 x = (int)(ux / Constants.RegionSize);
540 y = (int)(uy / Constants.RegionSize);
541
542 if ((Math.Abs((int)(m_scene.RegionInfo.RegionLocX / Constants.RegionSize) - x) >= 4096) ||
543 (Math.Abs((int)(m_scene.RegionInfo.RegionLocY / Constants.RegionSize) - y) >= 4096))
544 {
545 return false;
546 }
547 return true;
548 }
549
550 public bool CheckCoords(uint thisx, uint thisy, int x, int y)
551 {
552 if ((thisx == x) && (thisy == y))
553 return false;
554 return true;
555 }
556
557 #endregion
558
559 }
560}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
index 74ece2e..743d3b9 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
@@ -35,6 +35,7 @@ using OpenSim.Server.Base;
35using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38using OpenMetaverse; 39using OpenMetaverse;
39 40
40namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid 41namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
@@ -50,6 +51,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
50 51
51 private bool m_Enabled = false; 52 private bool m_Enabled = false;
52 53
54 public LocalGridServicesConnector()
55 {
56 }
57
58 public LocalGridServicesConnector(IConfigSource source)
59 {
60 m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated");
61 InitialiseService(source);
62 }
63
53 #region ISharedRegionModule 64 #region ISharedRegionModule
54 65
55 public Type ReplaceableInterface 66 public Type ReplaceableInterface
@@ -70,38 +81,43 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
70 string name = moduleConfig.GetString("GridServices", ""); 81 string name = moduleConfig.GetString("GridServices", "");
71 if (name == Name) 82 if (name == Name)
72 { 83 {
73 IConfig assetConfig = source.Configs["GridService"]; 84 InitialiseService(source);
74 if (assetConfig == null)
75 {
76 m_log.Error("[GRID CONNECTOR]: GridService missing from OpenSim.ini");
77 return;
78 }
79
80 string serviceDll = assetConfig.GetString("LocalServiceModule",
81 String.Empty);
82
83 if (serviceDll == String.Empty)
84 {
85 m_log.Error("[GRID CONNECTOR]: No LocalServiceModule named in section GridService");
86 return;
87 }
88
89 Object[] args = new Object[] { source };
90 m_GridService =
91 ServerUtils.LoadPlugin<IGridService>(serviceDll,
92 args);
93
94 if (m_GridService == null)
95 {
96 m_log.Error("[GRID CONNECTOR]: Can't load asset service");
97 return;
98 }
99 m_Enabled = true; 85 m_Enabled = true;
100 m_log.Info("[GRID CONNECTOR]: Local grid connector enabled"); 86 m_log.Info("[LOCAL GRID CONNECTOR]: Local grid connector enabled");
101 } 87 }
102 } 88 }
103 } 89 }
104 90
91 private void InitialiseService(IConfigSource source)
92 {
93 IConfig assetConfig = source.Configs["GridService"];
94 if (assetConfig == null)
95 {
96 m_log.Error("[LOCAL GRID CONNECTOR]: GridService missing from OpenSim.ini");
97 return;
98 }
99
100 string serviceDll = assetConfig.GetString("LocalServiceModule",
101 String.Empty);
102
103 if (serviceDll == String.Empty)
104 {
105 m_log.Error("[LOCAL GRID CONNECTOR]: No LocalServiceModule named in section GridService");
106 return;
107 }
108
109 Object[] args = new Object[] { source };
110 m_GridService =
111 ServerUtils.LoadPlugin<IGridService>(serviceDll,
112 args);
113
114 if (m_GridService == null)
115 {
116 m_log.Error("[LOCAL GRID CONNECTOR]: Can't load grid service");
117 return;
118 }
119 }
120
105 public void PostInitialise() 121 public void PostInitialise()
106 { 122 {
107 } 123 }
@@ -130,7 +146,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
130 146
131 #region IGridService 147 #region IGridService
132 148
133 public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) 149 public bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
134 { 150 {
135 return m_GridService.RegisterRegion(scopeID, regionInfo); 151 return m_GridService.RegisterRegion(scopeID, regionInfo);
136 } 152 }
@@ -140,32 +156,32 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
140 return m_GridService.DeregisterRegion(regionID); 156 return m_GridService.DeregisterRegion(regionID);
141 } 157 }
142 158
143 public List<SimpleRegionInfo> GetNeighbours(UUID scopeID, UUID regionID) 159 public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
144 { 160 {
145 return m_GridService.GetNeighbours(scopeID, regionID); 161 return m_GridService.GetNeighbours(scopeID, regionID);
146 } 162 }
147 163
148 public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) 164 public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
149 { 165 {
150 return m_GridService.GetRegionByUUID(scopeID, regionID); 166 return m_GridService.GetRegionByUUID(scopeID, regionID);
151 } 167 }
152 168
153 public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) 169 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
154 { 170 {
155 return m_GridService.GetRegionByPosition(scopeID, x, y); 171 return m_GridService.GetRegionByPosition(scopeID, x, y);
156 } 172 }
157 173
158 public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) 174 public GridRegion GetRegionByName(UUID scopeID, string regionName)
159 { 175 {
160 return m_GridService.GetRegionByName(scopeID, regionName); 176 return m_GridService.GetRegionByName(scopeID, regionName);
161 } 177 }
162 178
163 public List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber) 179 public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
164 { 180 {
165 return m_GridService.GetRegionsByName(scopeID, name, maxNumber); 181 return m_GridService.GetRegionsByName(scopeID, name, maxNumber);
166 } 182 }
167 183
168 public List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) 184 public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
169 { 185 {
170 return m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax); 186 return m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax);
171 } 187 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
new file mode 100644
index 0000000..91a808b
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
@@ -0,0 +1,183 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using log4net;
29using System;
30using System.Collections.Generic;
31using System.Reflection;
32using Nini.Config;
33using OpenMetaverse;
34
35using OpenSim.Framework;
36using OpenSim.Services.Connectors;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Services.Interfaces;
40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41
42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
43{
44 public class RemoteGridServicesConnector :
45 GridServicesConnector, ISharedRegionModule, IGridService
46 {
47 private static readonly ILog m_log =
48 LogManager.GetLogger(
49 MethodBase.GetCurrentMethod().DeclaringType);
50
51 private bool m_Enabled = false;
52
53 private IGridService m_LocalGridService;
54
55 public RemoteGridServicesConnector()
56 {
57 }
58
59 public RemoteGridServicesConnector(IConfigSource source)
60 {
61 InitialiseServices(source);
62 }
63
64 #region ISharedRegionmodule
65
66 public Type ReplaceableInterface
67 {
68 get { return null; }
69 }
70
71 public string Name
72 {
73 get { return "RemoteGridServicesConnector"; }
74 }
75
76 public override void Initialise(IConfigSource source)
77 {
78 IConfig moduleConfig = source.Configs["Modules"];
79 if (moduleConfig != null)
80 {
81 string name = moduleConfig.GetString("GridServices", "");
82 if (name == Name)
83 {
84 InitialiseServices(source);
85 m_Enabled = true;
86 m_log.Info("[REMOTE GRID CONNECTOR]: Remote grid enabled");
87 }
88 }
89 }
90
91 private void InitialiseServices(IConfigSource source)
92 {
93 IConfig gridConfig = source.Configs["GridService"];
94 if (gridConfig == null)
95 {
96 m_log.Error("[REMOTE GRID CONNECTOR]: GridService missing from OpenSim.ini");
97 return;
98 }
99
100 base.Initialise(source);
101
102 m_LocalGridService = new LocalGridServicesConnector(source);
103 }
104
105 public void PostInitialise()
106 {
107 }
108
109 public void Close()
110 {
111 }
112
113 public void AddRegion(Scene scene)
114 {
115 if (!m_Enabled)
116 return;
117
118 scene.RegisterModuleInterface<IGridService>(this);
119 }
120
121 public void RemoveRegion(Scene scene)
122 {
123 }
124
125 public void RegionLoaded(Scene scene)
126 {
127 }
128
129 #endregion
130
131 #region IGridService
132
133 public override bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
134 {
135 if (m_LocalGridService.RegisterRegion(scopeID, regionInfo))
136 return base.RegisterRegion(scopeID, regionInfo);
137
138 return false;
139 }
140
141 public override bool DeregisterRegion(UUID regionID)
142 {
143 if (m_LocalGridService.DeregisterRegion(regionID))
144 return base.DeregisterRegion(regionID);
145
146 return false;
147 }
148
149 // Let's not override GetNeighbours -- let's get them all from the grid server
150
151 public override GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
152 {
153 GridRegion rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID);
154 if (rinfo == null)
155 rinfo = base.GetRegionByUUID(scopeID, regionID);
156
157 return rinfo;
158 }
159
160 public override GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
161 {
162 GridRegion rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y);
163 if (rinfo == null)
164 rinfo = base.GetRegionByPosition(scopeID, x, y);
165
166 return rinfo;
167 }
168
169 public override GridRegion GetRegionByName(UUID scopeID, string regionName)
170 {
171 GridRegion rinfo = m_LocalGridService.GetRegionByName(scopeID, regionName);
172 if (rinfo == null)
173 rinfo = base.GetRegionByName(scopeID, regionName);
174
175 return rinfo;
176 }
177
178 // Let's not override GetRegionsByName -- let's get them all from the grid server
179 // Let's not override GetRegionRange -- let's get them all from the grid server
180
181 #endregion
182 }
183}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
new file mode 100644
index 0000000..be32d6b
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
@@ -0,0 +1,131 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using System.Threading;
33using log4net.Config;
34using NUnit.Framework;
35using NUnit.Framework.SyntaxHelpers;
36using OpenMetaverse;
37using OpenSim.Framework;
38using Nini.Config;
39
40using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid;
41using OpenSim.Region.Framework.Scenes;
42using GridRegion = OpenSim.Services.Interfaces.GridRegion;
43using OpenSim.Tests.Common;
44using OpenSim.Tests.Common.Setup;
45
46namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
47{
48 [TestFixture]
49 public class GridConnectorsTests
50 {
51 LocalGridServicesConnector m_LocalConnector;
52 private void SetUp()
53 {
54 IConfigSource config = new IniConfigSource();
55 config.AddConfig("Modules");
56 config.AddConfig("GridService");
57 config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector");
58 config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService");
59 config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData");
60
61 m_LocalConnector = new LocalGridServicesConnector(config);
62 }
63
64 /// <summary>
65 /// Test saving a V0.2 OpenSim Region Archive.
66 /// </summary>
67 [Test]
68 public void TestRegisterRegionV0_2()
69 {
70 SetUp();
71
72 // Create 3 regions
73 GridRegion r1 = new GridRegion();
74 r1.RegionName = "Test Region 1";
75 r1.RegionID = new UUID(1);
76 r1.RegionLocX = 1000 * (int)Constants.RegionSize;
77 r1.RegionLocY = 1000 * (int)Constants.RegionSize;
78 r1.ExternalHostName = "127.0.0.1";
79 r1.HttpPort = 9001;
80 r1.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
81
82 GridRegion r2 = new GridRegion();
83 r2.RegionName = "Test Region 2";
84 r2.RegionID = new UUID(2);
85 r2.RegionLocX = 1001 * (int)Constants.RegionSize;
86 r2.RegionLocY = 1000 * (int)Constants.RegionSize;
87 r2.ExternalHostName = "127.0.0.1";
88 r2.HttpPort = 9002;
89 r2.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
90
91 GridRegion r3 = new GridRegion();
92 r3.RegionName = "Test Region 3";
93 r3.RegionID = new UUID(3);
94 r3.RegionLocX = 1005 * (int)Constants.RegionSize;
95 r3.RegionLocY = 1000 * (int)Constants.RegionSize;
96 r3.ExternalHostName = "127.0.0.1";
97 r3.HttpPort = 9003;
98 r3.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
99
100 m_LocalConnector.RegisterRegion(UUID.Zero, r1);
101 GridRegion result = m_LocalConnector.GetRegionByName(UUID.Zero, "Test");
102 Assert.IsNotNull(result, "Retrieved GetRegionByName is null");
103 Assert.That(result.RegionName, Is.EqualTo("Test Region 1"), "Retrieved region's name does not match");
104
105 result = m_LocalConnector.GetRegionByUUID(UUID.Zero, new UUID(1));
106 Assert.IsNotNull(result, "Retrieved GetRegionByUUID is null");
107 Assert.That(result.RegionID, Is.EqualTo(new UUID(1)), "Retrieved region's UUID does not match");
108
109 result = m_LocalConnector.GetRegionByPosition(UUID.Zero, 1000 * (int)Constants.RegionSize, 1000 * (int)Constants.RegionSize);
110 Assert.IsNotNull(result, "Retrieved GetRegionByPosition is null");
111 Assert.That(result.RegionLocX, Is.EqualTo(1000 * (int)Constants.RegionSize), "Retrieved region's position does not match");
112
113 m_LocalConnector.RegisterRegion(UUID.Zero, r2);
114 m_LocalConnector.RegisterRegion(UUID.Zero, r3);
115
116 List<GridRegion> results = m_LocalConnector.GetNeighbours(UUID.Zero, new UUID(1));
117 Assert.IsNotNull(results, "Retrieved neighbours list is null");
118 Assert.That(results.Count, Is.EqualTo(1), "Retrieved neighbour collection is greater than expected");
119 Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2)), "Retrieved region's UUID does not match");
120
121 results = m_LocalConnector.GetRegionsByName(UUID.Zero, "Test", 10);
122 Assert.IsNotNull(results, "Retrieved GetRegionsByName list is null");
123 Assert.That(results.Count, Is.EqualTo(3), "Retrieved neighbour collection is less than expected");
124
125 results = m_LocalConnector.GetRegionRange(UUID.Zero, 900 * (int)Constants.RegionSize, 1002 * (int)Constants.RegionSize,
126 900 * (int)Constants.RegionSize, 1100 * (int)Constants.RegionSize);
127 Assert.IsNotNull(results, "Retrieved GetRegionRange list is null");
128 Assert.That(results.Count, Is.EqualTo(2), "Retrieved neighbour collection is not the number expected");
129 }
130 }
131}
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index 75b3fe6..0d51cf4 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -33,7 +33,6 @@ using log4net;
33using Nini.Config; 33using Nini.Config;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Region.CoreModules.World.Terrain;
37using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
39 38
@@ -47,7 +46,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
47 46
48 private Scene m_scene; 47 private Scene m_scene;
49 48
50 private EstateTerrainXferHandler TerrainUploader = null; 49 private EstateTerrainXferHandler TerrainUploader;
51 50
52 #region Packet Data Responders 51 #region Packet Data Responders
53 52
@@ -155,6 +154,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
155 break; 154 break;
156 } 155 }
157 m_scene.RegionInfo.RegionSettings.Save(); 156 m_scene.RegionInfo.RegionSettings.Save();
157 sendRegionInfoPacketToAll();
158 } 158 }
159 159
160 public void setEstateTerrainTextureHeights(IClientAPI client, int corner, float lowValue, float highValue) 160 public void setEstateTerrainTextureHeights(IClientAPI client, int corner, float lowValue, float highValue)
@@ -179,6 +179,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
179 break; 179 break;
180 } 180 }
181 m_scene.RegionInfo.RegionSettings.Save(); 181 m_scene.RegionInfo.RegionSettings.Save();
182 sendRegionInfoPacketToAll();
182 } 183 }
183 184
184 private void handleCommitEstateTerrainTextureRequest(IClientAPI remoteClient) 185 private void handleCommitEstateTerrainTextureRequest(IClientAPI remoteClient)
@@ -668,7 +669,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
668 LookupUUID(uuidNameLookupList); 669 LookupUUID(uuidNameLookupList);
669 } 670 }
670 671
671 private void LookupUUIDSCompleted(IAsyncResult iar) 672 private static void LookupUUIDSCompleted(IAsyncResult iar)
672 { 673 {
673 LookupUUIDS icon = (LookupUUIDS)iar.AsyncState; 674 LookupUUIDS icon = (LookupUUIDS)iar.AsyncState;
674 icon.EndInvoke(iar); 675 icon.EndInvoke(iar);
@@ -683,7 +684,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
683 } 684 }
684 private void LookupUUIDsAsync(List<UUID> uuidLst) 685 private void LookupUUIDsAsync(List<UUID> uuidLst)
685 { 686 {
686 UUID[] uuidarr = new UUID[0]; 687 UUID[] uuidarr;
687 688
688 lock (uuidLst) 689 lock (uuidLst)
689 { 690 {
@@ -707,7 +708,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
707 708
708 for (int i = 0; i < avatars.Count; i++) 709 for (int i = 0; i < avatars.Count; i++)
709 { 710 {
710 HandleRegionInfoRequest(avatars[i].ControllingClient); ; 711 HandleRegionInfoRequest(avatars[i].ControllingClient);
711 } 712 }
712 } 713 }
713 714
@@ -768,7 +769,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
768 else 769 else
769 { 770 {
770 m_scene.RegionInfo.EstateSettings.UseGlobalTime = false; 771 m_scene.RegionInfo.EstateSettings.UseGlobalTime = false;
771 m_scene.RegionInfo.EstateSettings.SunPosition = (double)(parms2 - 0x1800)/1024.0; 772 m_scene.RegionInfo.EstateSettings.SunPosition = (parms2 - 0x1800)/1024.0;
772 } 773 }
773 774
774 if ((parms1 & 0x00000010) != 0) 775 if ((parms1 & 0x00000010) != 0)
@@ -828,8 +829,60 @@ namespace OpenSim.Region.CoreModules.World.Estate
828 m_scene.RegisterModuleInterface<IEstateModule>(this); 829 m_scene.RegisterModuleInterface<IEstateModule>(this);
829 m_scene.EventManager.OnNewClient += EventManager_OnNewClient; 830 m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
830 m_scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight; 831 m_scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight;
832
833 m_scene.AddCommand(this, "set terrain texture",
834 "set terrain texture <number> <uuid> [<x>] [<y>]",
835 "Sets the terrain <number> to <uuid>, if <x> or <y> are specified, it will only " +
836 "set it on regions with a matching coordinate. Specify -1 in <x> or <y> to wildcard" +
837 " that coordinate.",
838 consoleSetTerrainTexture);
839
840 m_scene.AddCommand(this, "set terrain heights",
841 "set terrain heights <corner> <min> <max> [<x>] [<y>]",
842 "Sets the terrain texture heights on corner #<corner> to <min>/<max>, if <x> or <y> are specified, it will only " +
843 "set it on regions with a matching coordinate. Specify -1 in <x> or <y> to wildcard" +
844 " that coordinate. Corner # SW = 0, NW = 1, SE = 2, NE = 3.",
845 consoleSetTerrainHeights);
831 } 846 }
832 847
848 #region Console Commands
849
850 public void consoleSetTerrainTexture(string module, string[] args)
851 {
852 string num = args[3];
853 string uuid = args[4];
854 int x = (args.Length > 5 ? int.Parse(args[5]) : -1);
855 int y = (args.Length > 6 ? int.Parse(args[6]) : -1);
856
857 if (x == -1 || m_scene.RegionInfo.RegionLocX == x)
858 {
859 if (y == -1 || m_scene.RegionInfo.RegionLocY == y)
860 {
861 m_log.Debug("[ESTATEMODULE] Setting terrain textures for " + m_scene.RegionInfo.RegionName);
862 setEstateTerrainBaseTexture(null, int.Parse(num), UUID.Parse(uuid));
863 }
864 }
865 }
866
867 public void consoleSetTerrainHeights(string module, string[] args)
868 {
869 string num = args[3];
870 string min = args[4];
871 string max = args[5];
872 int x = (args.Length > 6 ? int.Parse(args[6]) : -1);
873 int y = (args.Length > 7 ? int.Parse(args[7]) : -1);
874
875 if (x == -1 || m_scene.RegionInfo.RegionLocX == x)
876 {
877 if (y == -1 || m_scene.RegionInfo.RegionLocY == y)
878 {
879 m_log.Debug("[ESTATEMODULE] Setting terrain heights " + m_scene.RegionInfo.RegionName);
880 setEstateTerrainTextureHeights(null, int.Parse(num), float.Parse(min), float.Parse(max));
881 }
882 }
883 }
884
885 #endregion
833 886
834 public void PostInitialise() 887 public void PostInitialise()
835 { 888 {