diff options
author | Homer Horwitz | 2008-10-03 23:00:42 +0000 |
---|---|---|
committer | Homer Horwitz | 2008-10-03 23:00:42 +0000 |
commit | 16d68749a457acf079a6737f4ca9a9adb9e53e2f (patch) | |
tree | 901b2c31e53eeb97f30ac46f2b7f406a01e1755a /OpenSim | |
parent | Fix: Mantis#2326: Fix: privilege escalation through attach from ground (diff) | |
download | opensim-SC_OLD-16d68749a457acf079a6737f4ca9a9adb9e53e2f.zip opensim-SC_OLD-16d68749a457acf079a6737f4ca9a9adb9e53e2f.tar.gz opensim-SC_OLD-16d68749a457acf079a6737f4ca9a9adb9e53e2f.tar.bz2 opensim-SC_OLD-16d68749a457acf079a6737f4ca9a9adb9e53e2f.tar.xz |
Add the missing bits for the new region-search:
- Added lookup in the data-layer
- MySQL works
- SQLite doesn't have a grid-db, so it won't work there
- I added MSSQL-code to the best of my knowledge; but I don't know MSSQL :-)
- Added the plumbing up to OGS1GridServices. This speaks with the grid-server
via XMLRPC.
- Modified MapSearchModule to use the new data. It's backward compatible; if
used with an old grid-server, it just returns one found region instead of a
list.
- Refactored a bit.
Note: This updates data, grid-server and region code. No new files.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/GridDataBase.cs | 3 | ||||
-rw-r--r-- | OpenSim/Data/IGridData.cs | 9 | ||||
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLGridData.cs | 27 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLGridData.cs | 46 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteGridData.cs | 12 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/IGridServices.cs | 15 | ||||
-rw-r--r-- | OpenSim/Grid/GridServer/GridManager.cs | 70 | ||||
-rw-r--r-- | OpenSim/Grid/GridServer/GridServerBase.cs | 1 | ||||
-rw-r--r-- | OpenSim/Region/Communications/Local/LocalBackEndServices.cs | 15 | ||||
-rw-r--r-- | OpenSim/Region/Communications/OGS1/OGS1GridServices.cs | 119 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs | 57 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs | 6 |
12 files changed, 312 insertions, 68 deletions
diff --git a/OpenSim/Data/GridDataBase.cs b/OpenSim/Data/GridDataBase.cs index e8dbc11..1e2b6fa 100644 --- a/OpenSim/Data/GridDataBase.cs +++ b/OpenSim/Data/GridDataBase.cs | |||
@@ -25,6 +25,7 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Collections.Generic; | ||
28 | using OpenMetaverse; | 29 | using OpenMetaverse; |
29 | 30 | ||
30 | namespace OpenSim.Data | 31 | namespace OpenSim.Data |
@@ -35,6 +36,7 @@ namespace OpenSim.Data | |||
35 | public abstract RegionProfileData GetProfileByUUID(UUID UUID); | 36 | public abstract RegionProfileData GetProfileByUUID(UUID UUID); |
36 | public abstract RegionProfileData GetProfileByString(string regionName); | 37 | public abstract RegionProfileData GetProfileByString(string regionName); |
37 | public abstract RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax); | 38 | public abstract RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax); |
39 | public abstract List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum); | ||
38 | public abstract bool AuthenticateSim(UUID UUID, ulong regionHandle, string simrecvkey); | 40 | public abstract bool AuthenticateSim(UUID UUID, ulong regionHandle, string simrecvkey); |
39 | public abstract DataResponse AddProfile(RegionProfileData profile); | 41 | public abstract DataResponse AddProfile(RegionProfileData profile); |
40 | public abstract ReservationData GetReservationAtPoint(uint x, uint y); | 42 | public abstract ReservationData GetReservationAtPoint(uint x, uint y); |
@@ -44,6 +46,7 @@ namespace OpenSim.Data | |||
44 | public abstract void Initialise(); | 46 | public abstract void Initialise(); |
45 | public abstract void Initialise(string connect); | 47 | public abstract void Initialise(string connect); |
46 | public abstract void Dispose(); | 48 | public abstract void Dispose(); |
49 | |||
47 | public abstract string Name { get; } | 50 | public abstract string Name { get; } |
48 | public abstract string Version { get; } | 51 | public abstract string Version { get; } |
49 | } | 52 | } |
diff --git a/OpenSim/Data/IGridData.cs b/OpenSim/Data/IGridData.cs index 132361f..a42a7d8 100644 --- a/OpenSim/Data/IGridData.cs +++ b/OpenSim/Data/IGridData.cs | |||
@@ -25,6 +25,7 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Collections.Generic; | ||
28 | using OpenMetaverse; | 29 | using OpenMetaverse; |
29 | using OpenSim.Framework; | 30 | using OpenSim.Framework; |
30 | 31 | ||
@@ -80,6 +81,14 @@ namespace OpenSim.Data | |||
80 | RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax); | 81 | RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax); |
81 | 82 | ||
82 | /// <summary> | 83 | /// <summary> |
84 | /// Returns up to maxNum profiles of regions that have a name starting with namePrefix | ||
85 | /// </summary> | ||
86 | /// <param name="name">The name to match against</param> | ||
87 | /// <param name="maxNum">Maximum number of profiles to return</param> | ||
88 | /// <returns>A list of sim profiles</returns> | ||
89 | List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum); | ||
90 | |||
91 | /// <summary> | ||
83 | /// Authenticates a sim by use of its recv key. | 92 | /// Authenticates a sim by use of its recv key. |
84 | /// WARNING: Insecure | 93 | /// WARNING: Insecure |
85 | /// </summary> | 94 | /// </summary> |
diff --git a/OpenSim/Data/MSSQL/MSSQLGridData.cs b/OpenSim/Data/MSSQL/MSSQLGridData.cs index 443116a..6f94980 100644 --- a/OpenSim/Data/MSSQL/MSSQLGridData.cs +++ b/OpenSim/Data/MSSQL/MSSQLGridData.cs | |||
@@ -216,6 +216,33 @@ namespace OpenSim.Data.MSSQL | |||
216 | return null; | 216 | return null; |
217 | } | 217 | } |
218 | 218 | ||
219 | |||
220 | /// <summary> | ||
221 | /// Returns up to maxNum profiles of regions that have a name starting with namePrefix | ||
222 | /// </summary> | ||
223 | /// <param name="name">The name to match against</param> | ||
224 | /// <param name="maxNum">Maximum number of profiles to return</param> | ||
225 | /// <returns>A list of sim profiles</returns> | ||
226 | override public List<RegionProfileData> GetRegionsByName (string namePrefix, uint maxNum) | ||
227 | { | ||
228 | using (AutoClosingSqlCommand command = database.Query("SELECT * FROM regions WHERE regionName LIKE @name")) | ||
229 | { | ||
230 | command.Parameters.Add(database.CreateParameter("name", namePrefix + "%")); | ||
231 | |||
232 | List<RegionProfileData> rows = new List<RegionProfileData>(); | ||
233 | |||
234 | using (SqlDataReader reader = command.ExecuteReader()) | ||
235 | { | ||
236 | while (rows.Count < maxNum && reader.Read()) | ||
237 | { | ||
238 | rows.Add(ReadSimRow(reader)); | ||
239 | } | ||
240 | } | ||
241 | |||
242 | return rows; | ||
243 | } | ||
244 | } | ||
245 | |||
219 | /// <summary> | 246 | /// <summary> |
220 | /// Returns a sim profile from its location | 247 | /// Returns a sim profile from its location |
221 | /// </summary> | 248 | /// </summary> |
diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 1155ae3..26a8591 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs | |||
@@ -283,6 +283,52 @@ namespace OpenSim.Data.MySQL | |||
283 | } | 283 | } |
284 | 284 | ||
285 | /// <summary> | 285 | /// <summary> |
286 | /// Returns up to maxNum profiles of regions that have a name starting with namePrefix | ||
287 | /// </summary> | ||
288 | /// <param name="name">The name to match against</param> | ||
289 | /// <param name="maxNum">Maximum number of profiles to return</param> | ||
290 | /// <returns>A list of sim profiles</returns> | ||
291 | override public List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum) | ||
292 | { | ||
293 | MySQLSuperManager dbm = GetLockedConnection(); | ||
294 | |||
295 | try | ||
296 | { | ||
297 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
298 | param["?name"] = namePrefix + "%"; | ||
299 | |||
300 | IDbCommand result = | ||
301 | dbm.Manager.Query( | ||
302 | "SELECT * FROM regions WHERE regionName LIKE ?name", | ||
303 | param); | ||
304 | IDataReader reader = result.ExecuteReader(); | ||
305 | |||
306 | RegionProfileData row; | ||
307 | |||
308 | List<RegionProfileData> rows = new List<RegionProfileData>(); | ||
309 | |||
310 | while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null) | ||
311 | { | ||
312 | rows.Add(row); | ||
313 | } | ||
314 | reader.Close(); | ||
315 | result.Dispose(); | ||
316 | |||
317 | return rows; | ||
318 | } | ||
319 | catch (Exception e) | ||
320 | { | ||
321 | dbm.Manager.Reconnect(); | ||
322 | m_log.Error(e.ToString()); | ||
323 | return null; | ||
324 | } | ||
325 | finally | ||
326 | { | ||
327 | dbm.Release(); | ||
328 | } | ||
329 | } | ||
330 | |||
331 | /// <summary> | ||
286 | /// Returns a sim profile from it's location | 332 | /// Returns a sim profile from it's location |
287 | /// </summary> | 333 | /// </summary> |
288 | /// <param name="handle">Region location handle</param> | 334 | /// <param name="handle">Region location handle</param> |
diff --git a/OpenSim/Data/SQLite/SQLiteGridData.cs b/OpenSim/Data/SQLite/SQLiteGridData.cs index 3e1c67a..5b0455d 100644 --- a/OpenSim/Data/SQLite/SQLiteGridData.cs +++ b/OpenSim/Data/SQLite/SQLiteGridData.cs | |||
@@ -108,6 +108,18 @@ namespace OpenSim.Data.SQLite | |||
108 | return null; | 108 | return null; |
109 | } | 109 | } |
110 | 110 | ||
111 | |||
112 | /// <summary> | ||
113 | /// Returns up to maxNum profiles of regions that have a name starting with namePrefix | ||
114 | /// </summary> | ||
115 | /// <param name="name">The name to match against</param> | ||
116 | /// <param name="maxNum">Maximum number of profiles to return</param> | ||
117 | /// <returns>A list of sim profiles</returns> | ||
118 | override public List<RegionProfileData> GetRegionsByName (string namePrefix, uint maxNum) | ||
119 | { | ||
120 | return null; | ||
121 | } | ||
122 | |||
111 | /// <summary> | 123 | /// <summary> |
112 | /// Returns a sim profile from it's handle | 124 | /// Returns a sim profile from it's handle |
113 | /// </summary> | 125 | /// </summary> |
diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index 177009d..69e8756 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs | |||
@@ -70,5 +70,20 @@ namespace OpenSim.Framework.Communications | |||
70 | List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); | 70 | List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); |
71 | // not complete yet, only contains the fields needed for ParcelInfoReqeust | 71 | // not complete yet, only contains the fields needed for ParcelInfoReqeust |
72 | LandData RequestLandData(ulong regionHandle, uint x, uint y); | 72 | LandData RequestLandData(ulong regionHandle, uint x, uint y); |
73 | |||
74 | /// <summary> | ||
75 | /// Get information about regions starting with the provided name. | ||
76 | /// </summary> | ||
77 | /// <param name="name"> | ||
78 | /// The name to match against. | ||
79 | /// </param> | ||
80 | /// <param name="maxNumber"> | ||
81 | /// The maximum number of results to return. | ||
82 | /// </param> | ||
83 | /// <returns> | ||
84 | /// A list of <see cref="RegionInfo"/>s of regions with matching name. If the | ||
85 | /// grid-server couldn't be contacted or returned an error, return null. | ||
86 | /// </returns> | ||
87 | List<RegionInfo> RequestNamedRegions(string name, int maxNumber); | ||
73 | } | 88 | } |
74 | } | 89 | } |
diff --git a/OpenSim/Grid/GridServer/GridManager.cs b/OpenSim/Grid/GridServer/GridManager.cs index ed474c5..1e8ac00 100644 --- a/OpenSim/Grid/GridServer/GridManager.cs +++ b/OpenSim/Grid/GridServer/GridManager.cs | |||
@@ -188,6 +188,26 @@ namespace OpenSim.Grid.GridServer | |||
188 | return regions; | 188 | return regions; |
189 | } | 189 | } |
190 | 190 | ||
191 | public List<RegionProfileData> GetRegions(string name, int maxNum) | ||
192 | { | ||
193 | List<RegionProfileData> regions = new List<RegionProfileData>(); | ||
194 | foreach (IGridDataPlugin plugin in _plugins) | ||
195 | { | ||
196 | try | ||
197 | { | ||
198 | int num = maxNum - regions.Count; | ||
199 | List <RegionProfileData> profiles = plugin.GetRegionsByName(name, (uint)num); | ||
200 | if (profiles != null) regions.AddRange(profiles); | ||
201 | } | ||
202 | catch | ||
203 | { | ||
204 | m_log.Warn("[storage]: Unable to query regionblock via " + plugin.Name); | ||
205 | } | ||
206 | } | ||
207 | |||
208 | return regions; | ||
209 | } | ||
210 | |||
191 | /// <summary> | 211 | /// <summary> |
192 | /// Returns a XML String containing a list of the neighbouring regions | 212 | /// Returns a XML String containing a list of the neighbouring regions |
193 | /// </summary> | 213 | /// </summary> |
@@ -877,6 +897,56 @@ namespace OpenSim.Grid.GridServer | |||
877 | } | 897 | } |
878 | 898 | ||
879 | /// <summary> | 899 | /// <summary> |
900 | /// Returns up to <code>maxNumber</code> profiles of regions that have a name starting with <code>name</code> | ||
901 | /// </summary> | ||
902 | /// <param name="request"></param> | ||
903 | /// <returns></returns> | ||
904 | public XmlRpcResponse XmlRpcSearchForRegionMethod(XmlRpcRequest request) | ||
905 | { | ||
906 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
907 | |||
908 | if (!requestData.ContainsKey("name") || !requestData.Contains("maxNumber")) | ||
909 | { | ||
910 | m_log.Warn("[DATA] Invalid region-search request; missing name or maxNumber"); | ||
911 | return new XmlRpcResponse(500, "Missing name or maxNumber in region search request"); | ||
912 | } | ||
913 | |||
914 | Hashtable responseData = new Hashtable(); | ||
915 | |||
916 | string name = (string)requestData["name"]; | ||
917 | int maxNumber = Convert.ToInt32((string)requestData["maxNumber"]); | ||
918 | if (maxNumber == 0 || name.Length < 3) | ||
919 | { | ||
920 | // either we didn't want any, or we were too unspecific | ||
921 | responseData["numFound"] = 0; | ||
922 | } | ||
923 | else | ||
924 | { | ||
925 | List<RegionProfileData> sims = GetRegions(name, maxNumber); | ||
926 | |||
927 | responseData["numFound"] = sims.Count; | ||
928 | for (int i = 0; i < sims.Count; ++i) | ||
929 | { | ||
930 | RegionProfileData sim = sims[i]; | ||
931 | string prefix = "region" + i + "."; | ||
932 | responseData[prefix + "region_name"] = sim.regionName; | ||
933 | responseData[prefix + "region_UUID"] = sim.UUID.ToString(); | ||
934 | responseData[prefix + "region_locx"] = sim.regionLocX.ToString(); | ||
935 | responseData[prefix + "region_locy"] = sim.regionLocY.ToString(); | ||
936 | responseData[prefix + "sim_ip"] = sim.serverIP.ToString(); | ||
937 | responseData[prefix + "sim_port"] = sim.serverPort.ToString(); | ||
938 | responseData[prefix + "remoting_port"] = sim.remotingPort.ToString(); | ||
939 | responseData[prefix + "http_port"] = sim.httpPort.ToString(); | ||
940 | responseData[prefix + "map_UUID"] = sim.regionMapTextureID.ToString(); | ||
941 | } | ||
942 | } | ||
943 | |||
944 | XmlRpcResponse response = new XmlRpcResponse(); | ||
945 | response.Value = responseData; | ||
946 | return response; | ||
947 | } | ||
948 | |||
949 | /// <summary> | ||
880 | /// Performs a REST Get Operation | 950 | /// Performs a REST Get Operation |
881 | /// </summary> | 951 | /// </summary> |
882 | /// <param name="request"></param> | 952 | /// <param name="request"></param> |
diff --git a/OpenSim/Grid/GridServer/GridServerBase.cs b/OpenSim/Grid/GridServer/GridServerBase.cs index 875b4ac..2ffeb57 100644 --- a/OpenSim/Grid/GridServer/GridServerBase.cs +++ b/OpenSim/Grid/GridServer/GridServerBase.cs | |||
@@ -101,6 +101,7 @@ namespace OpenSim.Grid.GridServer | |||
101 | m_httpServer.AddXmlRPCHandler("simulator_data_request", m_gridManager.XmlRpcSimulatorDataRequestMethod); | 101 | m_httpServer.AddXmlRPCHandler("simulator_data_request", m_gridManager.XmlRpcSimulatorDataRequestMethod); |
102 | m_httpServer.AddXmlRPCHandler("simulator_after_region_moved", m_gridManager.XmlRpcDeleteRegionMethod); | 102 | m_httpServer.AddXmlRPCHandler("simulator_after_region_moved", m_gridManager.XmlRpcDeleteRegionMethod); |
103 | m_httpServer.AddXmlRPCHandler("map_block", m_gridManager.XmlRpcMapBlockMethod); | 103 | m_httpServer.AddXmlRPCHandler("map_block", m_gridManager.XmlRpcMapBlockMethod); |
104 | m_httpServer.AddXmlRPCHandler("search_for_region_by_name", m_gridManager.XmlRpcSearchForRegionMethod); | ||
104 | 105 | ||
105 | // Message Server ---> Grid Server | 106 | // Message Server ---> Grid Server |
106 | m_httpServer.AddXmlRPCHandler("register_messageserver", m_gridManager.XmlRPCRegisterMessageServer); | 107 | m_httpServer.AddXmlRPCHandler("register_messageserver", m_gridManager.XmlRPCRegisterMessageServer); |
diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs index a861ceb..9034e49 100644 --- a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs +++ b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs | |||
@@ -514,5 +514,20 @@ namespace OpenSim.Region.Communications.Local | |||
514 | m_log.Debug("[INTERREGION STANDALONE] didn't find land data locally."); | 514 | m_log.Debug("[INTERREGION STANDALONE] didn't find land data locally."); |
515 | return null; | 515 | return null; |
516 | } | 516 | } |
517 | |||
518 | public List<RegionInfo> RequestNamedRegions (string name, int maxNumber) | ||
519 | { | ||
520 | List<RegionInfo> regions = new List<RegionInfo>(); | ||
521 | foreach (RegionInfo info in m_regions.Values) | ||
522 | { | ||
523 | if (info.RegionName.StartsWith(name)) | ||
524 | { | ||
525 | regions.Add(info); | ||
526 | if (regions.Count >= maxNumber) break; | ||
527 | } | ||
528 | } | ||
529 | |||
530 | return regions; | ||
531 | } | ||
517 | } | 532 | } |
518 | } | 533 | } |
diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index a2d3823..397062b 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs | |||
@@ -352,27 +352,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
352 | return null; | 352 | return null; |
353 | } | 353 | } |
354 | 354 | ||
355 | uint regX = Convert.ToUInt32((string) responseData["region_locx"]); | 355 | regionInfo = buildRegionInfo(responseData, String.Empty); |
356 | uint regY = Convert.ToUInt32((string) responseData["region_locy"]); | ||
357 | string internalIpStr = (string) responseData["sim_ip"]; | ||
358 | uint port = Convert.ToUInt32(responseData["sim_port"]); | ||
359 | // string externalUri = (string) responseData["sim_uri"]; | ||
360 | |||
361 | IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port); | ||
362 | // string neighbourExternalUri = externalUri; | ||
363 | regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); | ||
364 | |||
365 | regionInfo.RemotingPort = Convert.ToUInt32((string) responseData["remoting_port"]); | ||
366 | regionInfo.RemotingAddress = internalIpStr; | ||
367 | |||
368 | if (responseData.ContainsKey("http_port")) | ||
369 | { | ||
370 | regionInfo.HttpPort = Convert.ToUInt32((string) responseData["http_port"]); | ||
371 | } | ||
372 | |||
373 | regionInfo.RegionID = new UUID((string) responseData["region_UUID"]); | ||
374 | regionInfo.RegionName = (string) responseData["region_name"]; | ||
375 | |||
376 | if (requestData.ContainsKey("regionHandle")) | 356 | if (requestData.ContainsKey("regionHandle")) |
377 | { | 357 | { |
378 | m_remoteRegionInfoCache.Add(Convert.ToUInt64((string) requestData["regionHandle"]), regionInfo); | 358 | m_remoteRegionInfoCache.Add(Convert.ToUInt64((string) requestData["regionHandle"]), regionInfo); |
@@ -479,30 +459,11 @@ namespace OpenSim.Region.Communications.OGS1 | |||
479 | 459 | ||
480 | if (responseData.ContainsKey("error")) | 460 | if (responseData.ContainsKey("error")) |
481 | { | 461 | { |
482 | m_log.Error("[OGS1 GRID SERVICES]: Error received from grid server" + responseData["error"]); | 462 | m_log.ErrorFormat("[OGS1 GRID SERVICES]: Error received from grid server: ", responseData["error"]); |
483 | return null; | 463 | return null; |
484 | } | 464 | } |
485 | 465 | ||
486 | uint regX = Convert.ToUInt32((string) responseData["region_locx"]); | 466 | regionInfo = buildRegionInfo(responseData, ""); |
487 | uint regY = Convert.ToUInt32((string) responseData["region_locy"]); | ||
488 | string internalIpStr = (string) responseData["sim_ip"]; | ||
489 | uint port = Convert.ToUInt32(responseData["sim_port"]); | ||
490 | // string externalUri = (string) responseData["sim_uri"]; | ||
491 | |||
492 | IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port); | ||
493 | // string neighbourExternalUri = externalUri; | ||
494 | regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); | ||
495 | |||
496 | regionInfo.RemotingPort = Convert.ToUInt32((string) responseData["remoting_port"]); | ||
497 | regionInfo.RemotingAddress = internalIpStr; | ||
498 | |||
499 | if (responseData.ContainsKey("http_port")) | ||
500 | { | ||
501 | regionInfo.HttpPort = Convert.ToUInt32((string) responseData["http_port"]); | ||
502 | } | ||
503 | |||
504 | regionInfo.RegionID = new UUID((string) responseData["region_UUID"]); | ||
505 | regionInfo.RegionName = (string) responseData["region_name"]; | ||
506 | 467 | ||
507 | if (!m_remoteRegionInfoCache.ContainsKey(regionInfo.RegionHandle)) | 468 | if (!m_remoteRegionInfoCache.ContainsKey(regionInfo.RegionHandle)) |
508 | m_remoteRegionInfoCache.Add(regionInfo.RegionHandle, regionInfo); | 469 | m_remoteRegionInfoCache.Add(regionInfo.RegionHandle, regionInfo); |
@@ -1676,7 +1637,8 @@ namespace OpenSim.Region.Communications.OGS1 | |||
1676 | else | 1637 | else |
1677 | { | 1638 | { |
1678 | hash = (Hashtable)response.Value; | 1639 | hash = (Hashtable)response.Value; |
1679 | try { | 1640 | try |
1641 | { | ||
1680 | landData = new LandData(); | 1642 | landData = new LandData(); |
1681 | landData.AABBMax = Vector3.Parse((string)hash["AABBMax"]); | 1643 | landData.AABBMax = Vector3.Parse((string)hash["AABBMax"]); |
1682 | landData.AABBMin = Vector3.Parse((string)hash["AABBMin"]); | 1644 | landData.AABBMin = Vector3.Parse((string)hash["AABBMin"]); |
@@ -1745,5 +1707,76 @@ namespace OpenSim.Region.Communications.OGS1 | |||
1745 | response.Value = hash; | 1707 | response.Value = hash; |
1746 | return response; | 1708 | return response; |
1747 | } | 1709 | } |
1710 | |||
1711 | public List<RegionInfo> RequestNamedRegions (string name, int maxNumber) | ||
1712 | { | ||
1713 | // no asking of the local backend first, here, as we have to ask the gridserver anyway. | ||
1714 | Hashtable hash = new Hashtable(); | ||
1715 | hash["name"] = name; | ||
1716 | hash["maxNumber"] = maxNumber.ToString(); | ||
1717 | |||
1718 | IList paramList = new ArrayList(); | ||
1719 | paramList.Add(hash); | ||
1720 | |||
1721 | Hashtable result = XmlRpcSearchForRegionByName(paramList); | ||
1722 | if (result == null) return null; | ||
1723 | |||
1724 | uint numberFound = Convert.ToUInt32(result["numFound"]); | ||
1725 | List<RegionInfo> infos = new List<RegionInfo>(); | ||
1726 | for (int i = 0; i < numberFound; ++i) | ||
1727 | { | ||
1728 | string prefix = "region" + i + "."; | ||
1729 | RegionInfo info = buildRegionInfo(result, prefix); | ||
1730 | infos.Add(info); | ||
1731 | } | ||
1732 | return infos; | ||
1733 | } | ||
1734 | |||
1735 | private RegionInfo buildRegionInfo(Hashtable responseData, string prefix) | ||
1736 | { | ||
1737 | uint regX = Convert.ToUInt32((string) responseData[prefix + "region_locx"]); | ||
1738 | uint regY = Convert.ToUInt32((string) responseData[prefix + "region_locy"]); | ||
1739 | string internalIpStr = (string) responseData[prefix + "sim_ip"]; | ||
1740 | uint port = Convert.ToUInt32(responseData[prefix + "sim_port"]); | ||
1741 | |||
1742 | IPEndPoint neighbourInternalEndPoint = new IPEndPoint(Util.GetHostFromDNS(internalIpStr), (int) port); | ||
1743 | |||
1744 | RegionInfo regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); | ||
1745 | regionInfo.RemotingPort = Convert.ToUInt32((string) responseData[prefix + "remoting_port"]); | ||
1746 | regionInfo.RemotingAddress = internalIpStr; | ||
1747 | |||
1748 | if (responseData.ContainsKey(prefix + "http_port")) | ||
1749 | { | ||
1750 | regionInfo.HttpPort = Convert.ToUInt32((string) responseData[prefix + "http_port"]); | ||
1751 | } | ||
1752 | |||
1753 | regionInfo.RegionID = new UUID((string) responseData[prefix + "region_UUID"]); | ||
1754 | regionInfo.RegionName = (string) responseData[prefix + "region_name"]; | ||
1755 | |||
1756 | regionInfo.RegionSettings.TerrainImageID = new UUID((string) responseData[prefix + "map_UUID"]); | ||
1757 | return regionInfo; | ||
1758 | } | ||
1759 | |||
1760 | private Hashtable XmlRpcSearchForRegionByName(IList parameters) | ||
1761 | { | ||
1762 | try | ||
1763 | { | ||
1764 | XmlRpcRequest request = new XmlRpcRequest("search_for_region_by_name", parameters); | ||
1765 | XmlRpcResponse resp = request.Send(serversInfo.GridURL, 10000); | ||
1766 | Hashtable respData = (Hashtable) resp.Value; | ||
1767 | if (respData != null && respData.Contains("faultCode")) | ||
1768 | { | ||
1769 | m_log.WarnFormat("[OGS1 GRID SERVICES]: Got an error while contacting GridServer: {0}", respData["faultString"]); | ||
1770 | return null; | ||
1771 | } | ||
1772 | |||
1773 | return respData; | ||
1774 | } | ||
1775 | catch (Exception e) | ||
1776 | { | ||
1777 | m_log.Error("[OGS1 GRID SERVICES]: MapBlockQuery XMLRPC failure: ", e); | ||
1778 | return null; | ||
1779 | } | ||
1780 | } | ||
1748 | } | 1781 | } |
1749 | } \ No newline at end of file | 1782 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs index 1a15585..8cc707c 100644 --- a/OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs | |||
@@ -78,35 +78,44 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap | |||
78 | 78 | ||
79 | private void OnMapNameRequest(IClientAPI remoteClient, string mapName) | 79 | private void OnMapNameRequest(IClientAPI remoteClient, string mapName) |
80 | { | 80 | { |
81 | m_log.DebugFormat("[MAPSEARCH]: looking for region {0}", mapName); | 81 | if (mapName.Length < 3) |
82 | 82 | { | |
83 | // TODO currently, this only returns one region per name. LL servers will return all starting with the provided name. | 83 | remoteClient.SendAlertMessage("Use a search string with at least 3 characters"); |
84 | RegionInfo info = m_scene.SceneGridService.RequestClosestRegion(mapName); | 84 | return; |
85 | // fetch the mapblock of the named sim. We need this anyway (we have the map open, and just jumped to the sim), | 85 | } |
86 | // so there shouldn't be any penalty for that. | 86 | |
87 | if (info == null) | 87 | // try to fetch from GridServer |
88 | { | 88 | List<RegionInfo> regionInfos = m_scene.SceneGridService.RequestNamedRegions(mapName, 20); |
89 | m_log.Warn("[MAPSEARCHMODULE]: Got Null Region Question!"); | 89 | if (regionInfos == null) |
90 | return; | 90 | { |
91 | m_log.Warn("[MAPSEARCHMODULE]: RequestNamedRegions returned null. Old gridserver?"); | ||
92 | // service wasn't available; maybe still an old GridServer. Try the old API, though it will return only one region | ||
93 | regionInfos = new List<RegionInfo>(); | ||
94 | RegionInfo info = m_scene.SceneGridService.RequestClosestRegion(mapName); | ||
95 | if (info != null) regionInfos.Add(info); | ||
91 | } | 96 | } |
92 | List<MapBlockData> mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks((int)info.RegionLocX, | ||
93 | (int)info.RegionLocY, | ||
94 | (int)info.RegionLocX, | ||
95 | (int)info.RegionLocY); | ||
96 | 97 | ||
97 | List<MapBlockData> blocks = new List<MapBlockData>(); | 98 | List<MapBlockData> blocks = new List<MapBlockData>(); |
98 | 99 | ||
99 | MapBlockData data = new MapBlockData(); | 100 | MapBlockData data; |
100 | data.Agents = 3; // TODO set to number of agents in region | 101 | if (regionInfos.Count > 0) |
101 | data.Access = 21; // TODO what's this? | 102 | { |
102 | data.MapImageId = mapBlocks.Count == 0 ? UUID.Zero : mapBlocks[0].MapImageId; | 103 | foreach (RegionInfo info in regionInfos) |
103 | data.Name = info.RegionName; | 104 | { |
104 | data.RegionFlags = 0; // TODO fix this | 105 | data = new MapBlockData(); |
105 | data.WaterHeight = 0; // not used | 106 | data.Agents = 0; |
106 | data.X = (ushort)info.RegionLocX; | 107 | data.Access = 21; // TODO what's this? |
107 | data.Y = (ushort)info.RegionLocY; | 108 | data.MapImageId = info.RegionSettings.TerrainImageID; |
108 | blocks.Add(data); | 109 | data.Name = info.RegionName; |
110 | data.RegionFlags = 0; // TODO not used? | ||
111 | data.WaterHeight = 0; // not used | ||
112 | data.X = (ushort)info.RegionLocX; | ||
113 | data.Y = (ushort)info.RegionLocY; | ||
114 | blocks.Add(data); | ||
115 | } | ||
116 | } | ||
109 | 117 | ||
118 | // final block, closing the search result | ||
110 | data = new MapBlockData(); | 119 | data = new MapBlockData(); |
111 | data.Agents = 0; | 120 | data.Agents = 0; |
112 | data.Access = 255; | 121 | data.Access = 255; |
diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index c33c777..08793d9 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs | |||
@@ -806,6 +806,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
806 | { | 806 | { |
807 | return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query); | 807 | return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query); |
808 | } | 808 | } |
809 | 809 | ||
810 | public List<RegionInfo> RequestNamedRegions(string name, int maxNumber) | ||
811 | { | ||
812 | return m_commsProvider.GridService.RequestNamedRegions(name, maxNumber); | ||
813 | } | ||
810 | } | 814 | } |
811 | } | 815 | } |