aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/GridService/HypergridLinker.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/GridService/HypergridLinker.cs123
1 files changed, 10 insertions, 113 deletions
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs
index ceb2c6e..aa394ce 100644
--- a/OpenSim/Services/GridService/HypergridLinker.cs
+++ b/OpenSim/Services/GridService/HypergridLinker.cs
@@ -137,6 +137,12 @@ namespace OpenSim.Services.GridService
137 m_log.WarnFormat("[HYPERGRID LINKER]: Malformed URL in [GridService], variable Gatekeeper = {0}", m_ThisGatekeeper); 137 m_log.WarnFormat("[HYPERGRID LINKER]: Malformed URL in [GridService], variable Gatekeeper = {0}", m_ThisGatekeeper);
138 } 138 }
139 139
140 m_ThisGatekeeper = m_ThisGatekeeperURI.AbsoluteUri;
141 if(m_ThisGatekeeperURI.Port == 80)
142 m_ThisGatekeeper = m_ThisGatekeeper.Trim(new char[] { '/', ' ' }) +":80/";
143 else if(m_ThisGatekeeperURI.Port == 443)
144 m_ThisGatekeeper = m_ThisGatekeeper.Trim(new char[] { '/', ' ' }) +":443/";
145
140 m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService); 146 m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService);
141 147
142 m_log.Debug("[HYPERGRID LINKER]: Loaded all services..."); 148 m_log.Debug("[HYPERGRID LINKER]: Loaded all services...");
@@ -190,119 +196,10 @@ namespace OpenSim.Services.GridService
190 { 196 {
191 return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason); 197 return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason);
192 } 198 }
193 199
194 public bool buildHGRegionURI(string inputName, out string serverURI, out string regionName) 200 public bool IsLocalGrid(string serverURI)
195 { 201 {
196 serverURI = string.Empty; 202 return serverURI == m_ThisGatekeeper;
197 regionName = string.Empty;
198
199 inputName = inputName.Trim();
200
201 if (!inputName.StartsWith("http") && !inputName.StartsWith("https"))
202 {
203 // Formats: grid.example.com:8002:region name
204 // grid.example.com:region name
205 // grid.example.com:8002
206 // grid.example.com
207
208 string host;
209 uint port = 80;
210
211 string[] parts = inputName.Split(new char[] { ':' });
212 int indx;
213 if(parts.Length == 0)
214 return false;
215 if (parts.Length == 1)
216 {
217 indx = inputName.IndexOf('/');
218 if (indx < 0)
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 }
226 }
227 else
228 {
229 host = parts[0];
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 }
257
258 serverURI = "http://"+ host +":"+ port.ToString() + "/";
259 }
260 }
261 else
262 {
263 // Formats: http://grid.example.com region name
264 // http://grid.example.com "region name"
265 // http://grid.example.com
266
267 string[] parts = inputName.Split(new char[] { ' ' });
268
269 if (parts.Length == 0)
270 return false;
271
272 serverURI = parts[0];
273
274 int indx = serverURI.LastIndexOf('/');
275 if(indx > 10)
276 {
277 if(indx + 2 < inputName.Length)
278 regionName = inputName.Substring(indx + 1);
279 serverURI = inputName.Substring(0, indx + 1);
280 }
281 else if (parts.Length >= 2)
282 {
283 regionName = inputName.Substring(serverURI.Length);
284 }
285 }
286
287 // use better code for sanity check
288 Uri uri;
289 try
290 {
291 uri = new Uri(serverURI);
292 }
293 catch
294 {
295 return false;
296 }
297
298 if(!string.IsNullOrEmpty(regionName))
299 regionName = regionName.Trim(new char[] { '"', ' ' });
300 serverURI = uri.AbsoluteUri;
301 if(uri.Port == 80)
302 serverURI = serverURI.Trim(new char[] { '/', ' ' }) +":80/";
303 else if(uri.Port == 443)
304 serverURI = serverURI.Trim(new char[] { '/', ' ' }) +":443/";
305 return true;
306 } 203 }
307 204
308 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)
@@ -313,7 +210,7 @@ namespace OpenSim.Services.GridService
313 string serverURI = string.Empty; 210 string serverURI = string.Empty;
314 string regionName = string.Empty; 211 string regionName = string.Empty;
315 212
316 if(!buildHGRegionURI(mapName, out serverURI, out regionName)) 213 if(!Util.buildHGRegionURI(mapName, out serverURI, out regionName))
317 { 214 {
318 reason = "Wrong URI format for link-region"; 215 reason = "Wrong URI format for link-region";
319 return null; 216 return null;