aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/GridService/HypergridLinker.cs
diff options
context:
space:
mode:
authorUbitUmarov2016-11-28 04:29:57 +0000
committerUbitUmarov2016-11-28 04:29:57 +0000
commit1aa4dbdb3fd5c3c8382dad53d6b7c105fb7cec85 (patch)
tree46738fbb9799ffeb47a7b6f3eb574c4c5c463302 /OpenSim/Services/GridService/HypergridLinker.cs
parentHG on links request build the URI in http format with a / at end, this should... (diff)
downloadopensim-SC-1aa4dbdb3fd5c3c8382dad53d6b7c105fb7cec85.zip
opensim-SC-1aa4dbdb3fd5c3c8382dad53d6b7c105fb7cec85.tar.gz
opensim-SC-1aa4dbdb3fd5c3c8382dad53d6b7c105fb7cec85.tar.bz2
opensim-SC-1aa4dbdb3fd5c3c8382dad53d6b7c105fb7cec85.tar.xz
increase HG mapsearch spargetti; add more flexibility on input uri formats. To find regions in memory for a grid the http format needs to be used, because aditional compares made by viewers
Diffstat (limited to 'OpenSim/Services/GridService/HypergridLinker.cs')
-rw-r--r--OpenSim/Services/GridService/HypergridLinker.cs148
1 files changed, 99 insertions, 49 deletions
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs
index 2869349..e00025b 100644
--- a/OpenSim/Services/GridService/HypergridLinker.cs
+++ b/OpenSim/Services/GridService/HypergridLinker.cs
@@ -191,14 +191,14 @@ namespace OpenSim.Services.GridService
191 return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason); 191 return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason);
192 } 192 }
193 193
194 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason) 194 public bool buildHGRegionURI(string inputName, out string serverURI, out string regionName)
195 { 195 {
196 reason = string.Empty; 196 serverURI = string.Empty;
197 GridRegion regInfo = null; 197 regionName = string.Empty;
198 198
199 mapName = mapName.Trim(); 199 inputName = inputName.Trim();
200 200
201 if (!mapName.StartsWith("http") && !mapName.StartsWith("https")) 201 if (!inputName.StartsWith("http") && !inputName.StartsWith("https"))
202 { 202 {
203 // Formats: grid.example.com:8002:region name 203 // Formats: grid.example.com:8002:region name
204 // grid.example.com:region name 204 // grid.example.com:region name
@@ -207,38 +207,59 @@ namespace OpenSim.Services.GridService
207 207
208 string host; 208 string host;
209 uint port = 80; 209 uint port = 80;
210 string regionName = "";
211
212 string[] parts = mapName.Split(new char[] { ':' });
213
214 if (parts.Length == 0)
215 {
216 reason = "Wrong format for link-region";
217 return null;
218 }
219 210
220 host = parts[0]; 211 string[] parts = inputName.Split(new char[] { ':' });
221 212 int indx;
222 if (parts.Length >= 2) 213 if(parts.Length == 0)
214 return false;
215 if (parts.Length == 1)
223 { 216 {
224 // If it's a number then assume it's a port. Otherwise, it's a region name. 217 indx = inputName.IndexOf('/');
225 if (!UInt32.TryParse(parts[1], out port)) 218 if (indx < 0)
226 regionName = parts[1]; 219 serverURI = "http://"+ inputName + "/";
220 else
221 {
222 serverURI = "http://"+ inputName.Substring(0,indx + 1);
223 if(indx + 2 < inputName.Length)
224 regionName = inputName.Substring(indx + 1);
225 }
227 } 226 }
228 227 else
229 // always take the last one
230 if (parts.Length >= 3)
231 { 228 {
232 regionName = parts[2]; 229 host = parts[0];
233 } 230
231 if (parts.Length >= 2)
232 {
233 indx = parts[1].IndexOf('/');
234 if(indx < 0)
235 {
236 // If it's a number then assume it's a port. Otherwise, it's a region name.
237 if (!UInt32.TryParse(parts[1], out port))
238 {
239 port = 80;
240 regionName = parts[1];
241 }
242 }
243 else
244 {
245 string portstr = parts[1].Substring(0, indx);
246 if(indx + 2 < parts[1].Length)
247 regionName = parts[1].Substring(indx + 1);
248 if (!UInt32.TryParse(portstr, out port))
249 port = 80;
250 }
251 }
252 // always take the last one
253 if (parts.Length >= 3)
254 {
255 regionName = parts[2];
256 }
234 257
235 string serverURI = "http://"+ host +":"+ port.ToString() + "/"; 258 if(port == 80)
236// bool success = TryCreateLink(scopeID, xloc, yloc, regionName, port, host, ownerID, out regInfo, out reason); 259 serverURI = "http://"+ host + "/";
237 if(TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, serverURI, ownerID, out regInfo, out reason)) 260 else
238 { 261 serverURI = "http://"+ host +":"+ port.ToString() + "/";
239 regInfo.RegionName = mapName; 262 }
240 return regInfo;
241 }
242 } 263 }
243 else 264 else
244 { 265 {
@@ -246,34 +267,63 @@ namespace OpenSim.Services.GridService
246 // http://grid.example.com "region name" 267 // http://grid.example.com "region name"
247 // http://grid.example.com 268 // http://grid.example.com
248 269
249 string serverURI; 270 string[] parts = inputName.Split(new char[] { ' ' });
250 string regionName = "";
251
252 string[] parts = mapName.Split(new char[] { ' ' });
253 271
254 if (parts.Length == 0) 272 if (parts.Length == 0)
255 { 273 return false;
256 reason = "Wrong format for link-region";
257 return null;
258 }
259 274
260 serverURI = parts[0]; 275 serverURI = parts[0];
261 if (!serverURI.EndsWith("/"))
262 serverURI = serverURI + "/";
263 276
264 if (parts.Length >= 2) 277 int indx = serverURI.LastIndexOf('/');
278 if(indx > 10)
265 { 279 {
266 regionName = mapName.Substring(serverURI.Length); 280 if(indx + 2 < inputName.Length)
267 regionName = regionName.Trim(new char[] { '"', ' ' }); 281 regionName = inputName.Substring(indx + 1);
282 serverURI = inputName.Substring(0, indx + 1);
268 } 283 }
269 284 else if (parts.Length >= 2)
270 if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, serverURI, ownerID, out regInfo, out reason))
271 { 285 {
272 regInfo.RegionName = mapName; 286 regionName = inputName.Substring(serverURI.Length);
273 return regInfo;
274 } 287 }
275 } 288 }
276 289
290 // use better code for sanity check
291 Uri uri;
292 try
293 {
294 uri = new Uri(serverURI);
295 }
296 catch
297 {
298 return false;
299 }
300
301 if(!string.IsNullOrEmpty(regionName))
302 regionName = regionName.Trim(new char[] { '"', ' ' });
303 serverURI = uri.AbsoluteUri;
304 return true;
305 }
306
307 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason)
308 {
309 reason = string.Empty;
310 GridRegion regInfo = null;
311
312 string serverURI = string.Empty;
313 string regionName = string.Empty;
314
315 if(!buildHGRegionURI(mapName, out serverURI, out regionName))
316 {
317 reason = "Wrong URI format for link-region";
318 return null;
319 }
320
321 if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, serverURI, ownerID, out regInfo, out reason))
322 {
323 regInfo.RegionName = serverURI + regionName;
324 return regInfo;
325 }
326
277 return null; 327 return null;
278 } 328 }
279 329