diff options
Diffstat (limited to 'OpenSim/Server/Handlers/Grid')
-rw-r--r-- | OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs | 154 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs | 55 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs | 106 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs | 208 |
4 files changed, 315 insertions, 208 deletions
diff --git a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs new file mode 100644 index 0000000..d1233dc --- /dev/null +++ b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs | |||
@@ -0,0 +1,154 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.IO; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Text; | ||
34 | using log4net; | ||
35 | using Nini.Config; | ||
36 | using Nwc.XmlRpc; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Framework.Servers.HttpServer; | ||
39 | |||
40 | namespace OpenSim.Server.Handlers.Grid | ||
41 | { | ||
42 | public class GridInfoHandlers | ||
43 | { | ||
44 | private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | |||
46 | private Hashtable _info = new Hashtable(); | ||
47 | |||
48 | /// <summary> | ||
49 | /// Instantiate a GridInfoService object. | ||
50 | /// </summary> | ||
51 | /// <param name="configPath">path to config path containing | ||
52 | /// grid information</param> | ||
53 | /// <remarks> | ||
54 | /// GridInfoService uses the [GridInfo] section of the | ||
55 | /// standard OpenSim.ini file --- which is not optimal, but | ||
56 | /// anything else requires a general redesign of the config | ||
57 | /// system. | ||
58 | /// </remarks> | ||
59 | public GridInfoHandlers(IConfigSource configSource) | ||
60 | { | ||
61 | loadGridInfo(configSource); | ||
62 | } | ||
63 | |||
64 | private void loadGridInfo(IConfigSource configSource) | ||
65 | { | ||
66 | _info["platform"] = "OpenSim"; | ||
67 | try | ||
68 | { | ||
69 | IConfig startupCfg = configSource.Configs["Startup"]; | ||
70 | IConfig gridCfg = configSource.Configs["GridInfoService"]; | ||
71 | IConfig netCfg = configSource.Configs["Network"]; | ||
72 | |||
73 | bool grid = startupCfg.GetBoolean("gridmode", false); | ||
74 | |||
75 | if (null != gridCfg) | ||
76 | { | ||
77 | foreach (string k in gridCfg.GetKeys()) | ||
78 | { | ||
79 | _info[k] = gridCfg.GetString(k); | ||
80 | } | ||
81 | } | ||
82 | else if (null != netCfg) | ||
83 | { | ||
84 | if (grid) | ||
85 | _info["login"] | ||
86 | = netCfg.GetString( | ||
87 | "user_server_url", "http://127.0.0.1:" + ConfigSettings.DefaultUserServerHttpPort.ToString()); | ||
88 | else | ||
89 | _info["login"] | ||
90 | = String.Format( | ||
91 | "http://127.0.0.1:{0}/", | ||
92 | netCfg.GetString( | ||
93 | "http_listener_port", ConfigSettings.DefaultRegionHttpPort.ToString())); | ||
94 | |||
95 | IssueWarning(); | ||
96 | } | ||
97 | else | ||
98 | { | ||
99 | _info["login"] = "http://127.0.0.1:9000/"; | ||
100 | IssueWarning(); | ||
101 | } | ||
102 | } | ||
103 | catch (Exception) | ||
104 | { | ||
105 | _log.Debug("[GRID INFO SERVICE]: Cannot get grid info from config source, using minimal defaults"); | ||
106 | } | ||
107 | |||
108 | _log.DebugFormat("[GRID INFO SERVICE]: Grid info service initialized with {0} keys", _info.Count); | ||
109 | |||
110 | } | ||
111 | |||
112 | private void IssueWarning() | ||
113 | { | ||
114 | _log.Warn("[GRID INFO SERVICE]: found no [GridInfo] section in your OpenSim.ini"); | ||
115 | _log.Warn("[GRID INFO SERVICE]: trying to guess sensible defaults, you might want to provide better ones:"); | ||
116 | |||
117 | foreach (string k in _info.Keys) | ||
118 | { | ||
119 | _log.WarnFormat("[GRID INFO SERVICE]: {0}: {1}", k, _info[k]); | ||
120 | } | ||
121 | } | ||
122 | |||
123 | public XmlRpcResponse XmlRpcGridInfoMethod(XmlRpcRequest request, IPEndPoint remoteClient) | ||
124 | { | ||
125 | XmlRpcResponse response = new XmlRpcResponse(); | ||
126 | Hashtable responseData = new Hashtable(); | ||
127 | |||
128 | _log.Info("[GRID INFO SERVICE]: Request for grid info"); | ||
129 | |||
130 | foreach (string k in _info.Keys) | ||
131 | { | ||
132 | responseData[k] = _info[k]; | ||
133 | } | ||
134 | response.Value = responseData; | ||
135 | |||
136 | return response; | ||
137 | } | ||
138 | |||
139 | public string RestGetGridInfoMethod(string request, string path, string param, | ||
140 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
141 | { | ||
142 | StringBuilder sb = new StringBuilder(); | ||
143 | |||
144 | sb.Append("<gridinfo>\n"); | ||
145 | foreach (string k in _info.Keys) | ||
146 | { | ||
147 | sb.AppendFormat("<{0}>{1}</{0}>\n", k, _info[k]); | ||
148 | } | ||
149 | sb.Append("</gridinfo>\n"); | ||
150 | |||
151 | return sb.ToString(); | ||
152 | } | ||
153 | } | ||
154 | } | ||
diff --git a/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs b/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs new file mode 100644 index 0000000..c9e80d9 --- /dev/null +++ b/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs | |||
@@ -0,0 +1,55 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using OpenMetaverse; | ||
33 | using Nini.Config; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Servers.HttpServer; | ||
36 | using OpenSim.Server.Handlers.Base; | ||
37 | |||
38 | namespace OpenSim.Server.Handlers.Grid | ||
39 | { | ||
40 | public class GridInfoServerInConnector : ServiceConnector | ||
41 | { | ||
42 | private string m_ConfigName = "GridInfoService"; | ||
43 | |||
44 | public GridInfoServerInConnector(IConfigSource config, IHttpServer server, string configName) : | ||
45 | base(config, server, configName) | ||
46 | { | ||
47 | GridInfoHandlers handlers = new GridInfoHandlers(config); | ||
48 | |||
49 | server.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info", | ||
50 | handlers.RestGetGridInfoMethod)); | ||
51 | server.AddXmlRPCHandler("get_grid_info", handlers.XmlRpcGridInfoMethod); | ||
52 | } | ||
53 | |||
54 | } | ||
55 | } | ||
diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index 85a8738..c90dd6f 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs | |||
@@ -103,6 +103,14 @@ namespace OpenSim.Server.Handlers.Grid | |||
103 | case "get_region_range": | 103 | case "get_region_range": |
104 | return GetRegionRange(request); | 104 | return GetRegionRange(request); |
105 | 105 | ||
106 | case "get_default_regions": | ||
107 | return GetDefaultRegions(request); | ||
108 | |||
109 | case "get_fallback_regions": | ||
110 | return GetFallbackRegions(request); | ||
111 | |||
112 | case "get_region_flags": | ||
113 | return GetRegionFlags(request); | ||
106 | } | 114 | } |
107 | m_log.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method); | 115 | m_log.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method); |
108 | } | 116 | } |
@@ -404,6 +412,104 @@ namespace OpenSim.Server.Handlers.Grid | |||
404 | return encoding.GetBytes(xmlString); | 412 | return encoding.GetBytes(xmlString); |
405 | } | 413 | } |
406 | 414 | ||
415 | byte[] GetDefaultRegions(Dictionary<string, object> request) | ||
416 | { | ||
417 | //m_log.DebugFormat("[GRID HANDLER]: GetDefaultRegions"); | ||
418 | UUID scopeID = UUID.Zero; | ||
419 | if (request.ContainsKey("SCOPEID")) | ||
420 | UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); | ||
421 | else | ||
422 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range"); | ||
423 | |||
424 | List<GridRegion> rinfos = m_GridService.GetDefaultRegions(scopeID); | ||
425 | |||
426 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
427 | if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) | ||
428 | result["result"] = "null"; | ||
429 | else | ||
430 | { | ||
431 | int i = 0; | ||
432 | foreach (GridRegion rinfo in rinfos) | ||
433 | { | ||
434 | Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs(); | ||
435 | result["region" + i] = rinfoDict; | ||
436 | i++; | ||
437 | } | ||
438 | } | ||
439 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
440 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
441 | UTF8Encoding encoding = new UTF8Encoding(); | ||
442 | return encoding.GetBytes(xmlString); | ||
443 | } | ||
444 | |||
445 | byte[] GetFallbackRegions(Dictionary<string, object> request) | ||
446 | { | ||
447 | //m_log.DebugFormat("[GRID HANDLER]: GetRegionRange"); | ||
448 | UUID scopeID = UUID.Zero; | ||
449 | if (request.ContainsKey("SCOPEID")) | ||
450 | UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); | ||
451 | else | ||
452 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get fallback regions"); | ||
453 | |||
454 | int x = 0, y = 0; | ||
455 | if (request.ContainsKey("X")) | ||
456 | Int32.TryParse(request["X"].ToString(), out x); | ||
457 | else | ||
458 | m_log.WarnFormat("[GRID HANDLER]: no X in request to get fallback regions"); | ||
459 | if (request.ContainsKey("Y")) | ||
460 | Int32.TryParse(request["Y"].ToString(), out y); | ||
461 | else | ||
462 | m_log.WarnFormat("[GRID HANDLER]: no Y in request to get fallback regions"); | ||
463 | |||
464 | |||
465 | List<GridRegion> rinfos = m_GridService.GetFallbackRegions(scopeID, x, y); | ||
466 | |||
467 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
468 | if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0))) | ||
469 | result["result"] = "null"; | ||
470 | else | ||
471 | { | ||
472 | int i = 0; | ||
473 | foreach (GridRegion rinfo in rinfos) | ||
474 | { | ||
475 | Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs(); | ||
476 | result["region" + i] = rinfoDict; | ||
477 | i++; | ||
478 | } | ||
479 | } | ||
480 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
481 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
482 | UTF8Encoding encoding = new UTF8Encoding(); | ||
483 | return encoding.GetBytes(xmlString); | ||
484 | } | ||
485 | |||
486 | byte[] GetRegionFlags(Dictionary<string, object> request) | ||
487 | { | ||
488 | UUID scopeID = UUID.Zero; | ||
489 | if (request.ContainsKey("SCOPEID")) | ||
490 | UUID.TryParse(request["SCOPEID"].ToString(), out scopeID); | ||
491 | else | ||
492 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours"); | ||
493 | |||
494 | UUID regionID = UUID.Zero; | ||
495 | if (request.ContainsKey("REGIONID")) | ||
496 | UUID.TryParse(request["REGIONID"].ToString(), out regionID); | ||
497 | else | ||
498 | m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); | ||
499 | |||
500 | int flags = m_GridService.GetRegionFlags(scopeID, regionID); | ||
501 | // m_log.DebugFormat("[GRID HANDLER]: flags for region {0}: {1}", regionID, flags); | ||
502 | |||
503 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
504 | result["result"] = flags.ToString(); | ||
505 | |||
506 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
507 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
508 | UTF8Encoding encoding = new UTF8Encoding(); | ||
509 | return encoding.GetBytes(xmlString); | ||
510 | } | ||
511 | |||
512 | |||
407 | #endregion | 513 | #endregion |
408 | 514 | ||
409 | #region Misc | 515 | #region Misc |
diff --git a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs deleted file mode 100644 index 7cc0dfa..0000000 --- a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs +++ /dev/null | |||
@@ -1,208 +0,0 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using System.Net; | ||
33 | using Nini.Config; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Server.Base; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | using OpenSim.Framework.Servers.HttpServer; | ||
38 | using OpenSim.Server.Handlers.Base; | ||
39 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
40 | |||
41 | using OpenMetaverse; | ||
42 | using log4net; | ||
43 | using Nwc.XmlRpc; | ||
44 | |||
45 | namespace OpenSim.Server.Handlers.Grid | ||
46 | { | ||
47 | public class HypergridServiceInConnector : ServiceConnector | ||
48 | { | ||
49 | private static readonly ILog m_log = | ||
50 | LogManager.GetLogger( | ||
51 | MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | |||
53 | private List<GridRegion> m_RegionsOnSim = new List<GridRegion>(); | ||
54 | private IHyperlinkService m_HyperlinkService; | ||
55 | |||
56 | public HypergridServiceInConnector(IConfigSource config, IHttpServer server, IHyperlinkService hyperService) : | ||
57 | base(config, server, String.Empty) | ||
58 | { | ||
59 | m_HyperlinkService = hyperService; | ||
60 | server.AddXmlRPCHandler("link_region", LinkRegionRequest, false); | ||
61 | server.AddXmlRPCHandler("expect_hg_user", ExpectHGUser, false); | ||
62 | } | ||
63 | |||
64 | public void AddRegion(GridRegion rinfo) | ||
65 | { | ||
66 | m_RegionsOnSim.Add(rinfo); | ||
67 | } | ||
68 | |||
69 | public void RemoveRegion(GridRegion rinfo) | ||
70 | { | ||
71 | if (m_RegionsOnSim.Contains(rinfo)) | ||
72 | m_RegionsOnSim.Remove(rinfo); | ||
73 | } | ||
74 | |||
75 | /// <summary> | ||
76 | /// Someone wants to link to us | ||
77 | /// </summary> | ||
78 | /// <param name="request"></param> | ||
79 | /// <returns></returns> | ||
80 | public XmlRpcResponse LinkRegionRequest(XmlRpcRequest request, IPEndPoint remoteClient) | ||
81 | { | ||
82 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
83 | //string host = (string)requestData["host"]; | ||
84 | //string portstr = (string)requestData["port"]; | ||
85 | string name = (string)requestData["region_name"]; | ||
86 | |||
87 | m_log.DebugFormat("[HGrid]: Hyperlink request"); | ||
88 | |||
89 | GridRegion regInfo = null; | ||
90 | foreach (GridRegion r in m_RegionsOnSim) | ||
91 | { | ||
92 | if ((r.RegionName != null) && (name != null) && (r.RegionName.ToLower() == name.ToLower())) | ||
93 | { | ||
94 | regInfo = r; | ||
95 | break; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | if (regInfo == null) | ||
100 | regInfo = m_RegionsOnSim[0]; // Send out the first region | ||
101 | |||
102 | Hashtable hash = new Hashtable(); | ||
103 | hash["uuid"] = regInfo.RegionID.ToString(); | ||
104 | m_log.Debug(">> Here " + regInfo.RegionID); | ||
105 | hash["handle"] = regInfo.RegionHandle.ToString(); | ||
106 | hash["region_image"] = regInfo.TerrainImage.ToString(); | ||
107 | hash["region_name"] = regInfo.RegionName; | ||
108 | hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString(); | ||
109 | //m_log.Debug(">> Here: " + regInfo.InternalEndPoint.Port); | ||
110 | |||
111 | |||
112 | XmlRpcResponse response = new XmlRpcResponse(); | ||
113 | response.Value = hash; | ||
114 | return response; | ||
115 | } | ||
116 | |||
117 | /// <summary> | ||
118 | /// Received from other HGrid nodes when a user wants to teleport here. This call allows | ||
119 | /// the region to prepare for direct communication from the client. Sends back an empty | ||
120 | /// xmlrpc response on completion. | ||
121 | /// This is somewhat similar to OGS1's ExpectUser, but with the additional task of | ||
122 | /// registering the user in the local user cache. | ||
123 | /// </summary> | ||
124 | /// <param name="request"></param> | ||
125 | /// <returns></returns> | ||
126 | public XmlRpcResponse ExpectHGUser(XmlRpcRequest request, IPEndPoint remoteClient) | ||
127 | { | ||
128 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
129 | ForeignUserProfileData userData = new ForeignUserProfileData(); | ||
130 | |||
131 | userData.FirstName = (string)requestData["firstname"]; | ||
132 | userData.SurName = (string)requestData["lastname"]; | ||
133 | userData.ID = new UUID((string)requestData["agent_id"]); | ||
134 | UUID sessionID = new UUID((string)requestData["session_id"]); | ||
135 | userData.HomeLocation = new Vector3((float)Convert.ToDecimal((string)requestData["startpos_x"], Culture.NumberFormatInfo), | ||
136 | (float)Convert.ToDecimal((string)requestData["startpos_y"], Culture.NumberFormatInfo), | ||
137 | (float)Convert.ToDecimal((string)requestData["startpos_z"], Culture.NumberFormatInfo)); | ||
138 | |||
139 | userData.UserServerURI = (string)requestData["userserver_id"]; | ||
140 | userData.UserAssetURI = (string)requestData["assetserver_id"]; | ||
141 | userData.UserInventoryURI = (string)requestData["inventoryserver_id"]; | ||
142 | |||
143 | m_log.DebugFormat("[HGrid]: Prepare for connection from {0} {1} (@{2}) UUID={3}", | ||
144 | userData.FirstName, userData.SurName, userData.UserServerURI, userData.ID); | ||
145 | |||
146 | ulong userRegionHandle = 0; | ||
147 | int userhomeinternalport = 0; | ||
148 | if (requestData.ContainsKey("region_uuid")) | ||
149 | { | ||
150 | UUID uuid = UUID.Zero; | ||
151 | UUID.TryParse((string)requestData["region_uuid"], out uuid); | ||
152 | userData.HomeRegionID = uuid; | ||
153 | userRegionHandle = Convert.ToUInt64((string)requestData["regionhandle"]); | ||
154 | userData.UserHomeAddress = (string)requestData["home_address"]; | ||
155 | userData.UserHomePort = (string)requestData["home_port"]; | ||
156 | userhomeinternalport = Convert.ToInt32((string)requestData["internal_port"]); | ||
157 | |||
158 | m_log.Debug("[HGrid]: home_address: " + userData.UserHomeAddress + | ||
159 | "; home_port: " + userData.UserHomePort); | ||
160 | } | ||
161 | else | ||
162 | m_log.WarnFormat("[HGrid]: User has no home region information"); | ||
163 | |||
164 | XmlRpcResponse resp = new XmlRpcResponse(); | ||
165 | |||
166 | // Let's check if someone is trying to get in with a stolen local identity. | ||
167 | // The need for this test is a consequence of not having truly global names :-/ | ||
168 | bool comingHome = false; | ||
169 | if (m_HyperlinkService.CheckUserAtEntry(userData.ID, sessionID, out comingHome) == false) | ||
170 | { | ||
171 | m_log.WarnFormat("[HGrid]: Access denied to foreign user."); | ||
172 | Hashtable respdata = new Hashtable(); | ||
173 | respdata["success"] = "FALSE"; | ||
174 | respdata["reason"] = "Foreign user has the same ID as a local user, or logins disabled."; | ||
175 | resp.Value = respdata; | ||
176 | return resp; | ||
177 | } | ||
178 | |||
179 | // Finally, everything looks ok | ||
180 | //m_log.Debug("XXX---- EVERYTHING OK ---XXX"); | ||
181 | |||
182 | if (!comingHome) | ||
183 | { | ||
184 | // We don't do this if the user is coming to the home grid | ||
185 | GridRegion home = new GridRegion(); | ||
186 | home.RegionID = userData.HomeRegionID; | ||
187 | home.ExternalHostName = userData.UserHomeAddress; | ||
188 | home.HttpPort = Convert.ToUInt32(userData.UserHomePort); | ||
189 | uint x = 0, y = 0; | ||
190 | Utils.LongToUInts(userRegionHandle, out x, out y); | ||
191 | home.RegionLocX = (int)x; | ||
192 | home.RegionLocY = (int)y; | ||
193 | home.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)userhomeinternalport); | ||
194 | |||
195 | m_HyperlinkService.AcceptUser(userData, home); | ||
196 | } | ||
197 | // else the user is coming to a non-home region of the home grid | ||
198 | // We simply drop this user information altogether | ||
199 | |||
200 | Hashtable respdata2 = new Hashtable(); | ||
201 | respdata2["success"] = "TRUE"; | ||
202 | resp.Value = respdata2; | ||
203 | |||
204 | return resp; | ||
205 | } | ||
206 | |||
207 | } | ||
208 | } | ||