aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/GridService/HypergridLinker.cs
diff options
context:
space:
mode:
authorUbitUmarov2016-12-16 03:38:20 +0000
committerUbitUmarov2016-12-16 03:38:20 +0000
commite2d46c060c4b9557cf596d6d828ddd296fa0af70 (patch)
treec2c44730340c9785b9b373c937a2a54b2e6ec34e /OpenSim/Services/GridService/HypergridLinker.cs
parentreserve constant OBJECT_ATTACHED_SLOTS_AVAILABLE from mantis 8096. But do not... (diff)
downloadopensim-SC-e2d46c060c4b9557cf596d6d828ddd296fa0af70.zip
opensim-SC-e2d46c060c4b9557cf596d6d828ddd296fa0af70.tar.gz
opensim-SC-e2d46c060c4b9557cf596d6d828ddd296fa0af70.tar.bz2
opensim-SC-e2d46c060c4b9557cf596d6d828ddd296fa0af70.tar.xz
ok.. another try on the HG uri
Diffstat (limited to 'OpenSim/Services/GridService/HypergridLinker.cs')
-rw-r--r--OpenSim/Services/GridService/HypergridLinker.cs121
1 files changed, 4 insertions, 117 deletions
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs
index 185f2ff..aa394ce 100644
--- a/OpenSim/Services/GridService/HypergridLinker.cs
+++ b/OpenSim/Services/GridService/HypergridLinker.cs
@@ -196,123 +196,10 @@ namespace OpenSim.Services.GridService
196 { 196 {
197 return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason); 197 return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason);
198 } 198 }
199 199
200 public bool buildHGRegionURI(string inputName, out string serverURI, out string regionName) 200 public bool IsLocalGrid(string serverURI)
201 { 201 {
202 serverURI = string.Empty; 202 return serverURI == m_ThisGatekeeper;
203 regionName = string.Empty;
204
205 inputName = inputName.Trim();
206
207 if (!inputName.StartsWith("http") && !inputName.StartsWith("https"))
208 {
209 // Formats: grid.example.com:8002:region name
210 // grid.example.com:region name
211 // grid.example.com:8002
212 // grid.example.com
213
214 string host;
215 uint port = 80;
216
217 string[] parts = inputName.Split(new char[] { ':' });
218 int indx;
219 if(parts.Length == 0)
220 return false;
221 if (parts.Length == 1)
222 {
223 indx = inputName.IndexOf('/');
224 if (indx < 0)
225 serverURI = "http://"+ inputName + "/";
226 else
227 {
228 serverURI = "http://"+ inputName.Substring(0,indx + 1);
229 if(indx + 2 < inputName.Length)
230 regionName = inputName.Substring(indx + 1);
231 }
232 }
233 else
234 {
235 host = parts[0];
236
237 if (parts.Length >= 2)
238 {
239 indx = parts[1].IndexOf('/');
240 if(indx < 0)
241 {
242 // If it's a number then assume it's a port. Otherwise, it's a region name.
243 if (!UInt32.TryParse(parts[1], out port))
244 {
245 port = 80;
246 regionName = parts[1];
247 }
248 }
249 else
250 {
251 string portstr = parts[1].Substring(0, indx);
252 if(indx + 2 < parts[1].Length)
253 regionName = parts[1].Substring(indx + 1);
254 if (!UInt32.TryParse(portstr, out port))
255 port = 80;
256 }
257 }
258 // always take the last one
259 if (parts.Length >= 3)
260 {
261 regionName = parts[2];
262 }
263
264 serverURI = "http://"+ host +":"+ port.ToString() + "/";
265 }
266 }
267 else
268 {
269 // Formats: http://grid.example.com region name
270 // http://grid.example.com "region name"
271 // http://grid.example.com
272
273 string[] parts = inputName.Split(new char[] { ' ' });
274
275 if (parts.Length == 0)
276 return false;
277
278 serverURI = parts[0];
279
280 int indx = serverURI.LastIndexOf('/');
281 if(indx > 10)
282 {
283 if(indx + 2 < inputName.Length)
284 regionName = inputName.Substring(indx + 1);
285 serverURI = inputName.Substring(0, indx + 1);
286 }
287 else if (parts.Length >= 2)
288 {
289 regionName = inputName.Substring(serverURI.Length);
290 }
291 }
292
293 // use better code for sanity check
294 Uri uri;
295 try
296 {
297 uri = new Uri(serverURI);
298 }
299 catch
300 {
301 return false;
302 }
303
304 if(!string.IsNullOrEmpty(regionName))
305 regionName = regionName.Trim(new char[] { '"', ' ' });
306 serverURI = uri.AbsoluteUri;
307 if(uri.Port == 80)
308 serverURI = serverURI.Trim(new char[] { '/', ' ' }) +":80/";
309 else if(uri.Port == 443)
310 serverURI = serverURI.Trim(new char[] { '/', ' ' }) +":443/";
311
312 if(serverURI == m_ThisGatekeeper)
313 serverURI = ""; // local grid, look for region name only
314
315 return true;
316 } 203 }
317 204
318 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason) 205 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason)
@@ -323,7 +210,7 @@ namespace OpenSim.Services.GridService
323 string serverURI = string.Empty; 210 string serverURI = string.Empty;
324 string regionName = string.Empty; 211 string regionName = string.Empty;
325 212
326 if(!buildHGRegionURI(mapName, out serverURI, out regionName)) 213 if(!Util.buildHGRegionURI(mapName, out serverURI, out regionName))
327 { 214 {
328 reason = "Wrong URI format for link-region"; 215 reason = "Wrong URI format for link-region";
329 return null; 216 return null;