aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/GridService/HypergridLinker.cs
diff options
context:
space:
mode:
authoronefang2019-09-11 16:36:50 +1000
committeronefang2019-09-11 16:36:50 +1000
commit50cd1ffd32f69228e566f2b0b89f86ea0d9fe489 (patch)
tree52f2ab0c04f1a5d7d6ac5dc872981b4b156447e7 /OpenSim/Services/GridService/HypergridLinker.cs
parentRenamed branch to SledjChisl. (diff)
parentBump to release flavour, build 0. (diff)
downloadopensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.zip
opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.gz
opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.bz2
opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.xz
Merge branch 'SledjChisl'
Diffstat (limited to 'OpenSim/Services/GridService/HypergridLinker.cs')
-rw-r--r--OpenSim/Services/GridService/HypergridLinker.cs113
1 files changed, 33 insertions, 80 deletions
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs
index aebbf7c..7c384d5 100644
--- a/OpenSim/Services/GridService/HypergridLinker.cs
+++ b/OpenSim/Services/GridService/HypergridLinker.cs
@@ -119,13 +119,13 @@ namespace OpenSim.Services.GridService
119 if (scope != string.Empty) 119 if (scope != string.Empty)
120 UUID.TryParse(scope, out m_ScopeID); 120 UUID.TryParse(scope, out m_ScopeID);
121 121
122// TODO OpenSim is crazy, this is called from Robust and OpenSim, Robust needs the ../caches bit, OpenSim somehow adds a path already. I can't tell why. So strip the path. 122//// TODO OpenSim is crazy, this is called from Robust and OpenSim, Robust needs the ../caches bit, OpenSim somehow adds a path already. I can't tell why. So strip the path.
123 m_MapTileDirectory = "../caches/" + Path.GetFileName(gridConfig.GetString("MapTileDirectory", "maptiles")); 123 m_MapTileDirectory = Path.Combine(Util.cacheDir(), Path.GetFileName(gridConfig.GetString("MapTileDirectory", "maptiles")));
124 124
125 m_ThisGatekeeper = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", 125 m_ThisGatekeeper = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI",
126 new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty); 126 new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty);
127 // Legacy. Remove soon! 127 // Legacy. Remove soon!
128 m_ThisGatekeeper = gridConfig.GetString("Gatekeeper", m_ThisGatekeeper); 128//// m_ThisGatekeeper = gridConfig.GetString("Gatekeeper", m_ThisGatekeeper);
129 try 129 try
130 { 130 {
131 m_ThisGatekeeperURI = new Uri(m_ThisGatekeeper); 131 m_ThisGatekeeperURI = new Uri(m_ThisGatekeeper);
@@ -135,6 +135,12 @@ namespace OpenSim.Services.GridService
135 m_log.WarnFormat("[HYPERGRID LINKER]: Malformed URL in [GridService], variable Gatekeeper = {0}", m_ThisGatekeeper); 135 m_log.WarnFormat("[HYPERGRID LINKER]: Malformed URL in [GridService], variable Gatekeeper = {0}", m_ThisGatekeeper);
136 } 136 }
137 137
138 m_ThisGatekeeper = m_ThisGatekeeperURI.AbsoluteUri;
139 if(m_ThisGatekeeperURI.Port == 80)
140 m_ThisGatekeeper = m_ThisGatekeeper.Trim(new char[] { '/', ' ' }) +":80/";
141 else if(m_ThisGatekeeperURI.Port == 443)
142 m_ThisGatekeeper = m_ThisGatekeeper.Trim(new char[] { '/', ' ' }) +":443/";
143
138 m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService); 144 m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService);
139 145
140 m_log.Debug("[HYPERGRID LINKER]: Loaded all services..."); 146 m_log.Debug("[HYPERGRID LINKER]: Loaded all services...");
@@ -186,85 +192,29 @@ namespace OpenSim.Services.GridService
186 return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason); 192 return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason);
187 } 193 }
188 194
195 public bool IsLocalGrid(string serverURI)
196 {
197 return serverURI == m_ThisGatekeeper;
198 }
199
189 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason) 200 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason)
190 { 201 {
191 reason = string.Empty; 202 reason = string.Empty;
192 GridRegion regInfo = null; 203 GridRegion regInfo = null;
193 204
194 mapName = mapName.Trim(); 205 string serverURI = string.Empty;
206 string regionName = string.Empty;
195 207
196 if (!mapName.StartsWith("http")) 208 if(!Util.buildHGRegionURI(mapName, out serverURI, out regionName))
197 { 209 {
198 // Formats: grid.example.com:8002:region name 210 reason = "Wrong URI format for link-region";
199 // grid.example.com:region name 211 return null;
200 // grid.example.com:8002
201 // grid.example.com
202
203 string host;
204 uint port = 80;
205 string regionName = "";
206
207 string[] parts = mapName.Split(new char[] { ':' });
208
209 if (parts.Length == 0)
210 {
211 reason = "Wrong format for link-region";
212 return null;
213 }
214
215 host = parts[0];
216
217 if (parts.Length >= 2)
218 {
219 // If it's a number then assume it's a port. Otherwise, it's a region name.
220 if (!UInt32.TryParse(parts[1], out port))
221 regionName = parts[1];
222 }
223
224 // always take the last one
225 if (parts.Length >= 3)
226 {
227 regionName = parts[2];
228 }
229
230
231 bool success = TryCreateLink(scopeID, xloc, yloc, regionName, port, host, ownerID, out regInfo, out reason);
232 if (success)
233 {
234 regInfo.RegionName = mapName;
235 return regInfo;
236 }
237 } 212 }
238 else
239 {
240 // Formats: http://grid.example.com region name
241 // http://grid.example.com "region name"
242 // http://grid.example.com
243
244 string serverURI;
245 string regionName = "";
246
247 string[] parts = mapName.Split(new char[] { ' ' });
248
249 if (parts.Length == 0)
250 {
251 reason = "Wrong format for link-region";
252 return null;
253 }
254 213
255 serverURI = parts[0]; 214 if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, serverURI, ownerID, out regInfo, out reason))
256 215 {
257 if (parts.Length >= 2) 216 regInfo.RegionName = serverURI + regionName;
258 { 217 return regInfo;
259 regionName = mapName.Substring(serverURI.Length);
260 regionName = regionName.Trim(new char[] { '"', ' ' });
261 }
262
263 if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, serverURI, ownerID, out regInfo, out reason))
264 {
265 regInfo.RegionName = mapName;
266 return regInfo;
267 }
268 } 218 }
269 219
270 return null; 220 return null;
@@ -285,7 +235,7 @@ namespace OpenSim.Services.GridService
285 235
286 private bool TryCreateLinkImpl(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason) 236 private bool TryCreateLinkImpl(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason)
287 { 237 {
288 m_log.InfoFormat("[HYPERGRID LINKER]: Link to {0} {1}, in <{2},{3}>", 238 m_log.InfoFormat("[HYPERGRID LINKER]: Link to {0} {1}, in <{2},{3}>",
289 ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI), 239 ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI),
290 remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc)); 240 remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc));
291 241
@@ -361,7 +311,9 @@ namespace OpenSim.Services.GridService
361 UUID regionID = UUID.Zero; 311 UUID regionID = UUID.Zero;
362 string externalName = string.Empty; 312 string externalName = string.Empty;
363 string imageURL = string.Empty; 313 string imageURL = string.Empty;
364 if (!m_GatekeeperConnector.LinkRegion(regInfo, out regionID, out handle, out externalName, out imageURL, out reason)) 314 int sizeX = (int)Constants.RegionSize;
315 int sizeY = (int)Constants.RegionSize;
316 if (!m_GatekeeperConnector.LinkRegion(regInfo, out regionID, out handle, out externalName, out imageURL, out reason, out sizeX, out sizeY))
365 return false; 317 return false;
366 318
367 if (regionID == UUID.Zero) 319 if (regionID == UUID.Zero)
@@ -374,13 +326,14 @@ namespace OpenSim.Services.GridService
374 region = m_GridService.GetRegionByUUID(scopeID, regionID); 326 region = m_GridService.GetRegionByUUID(scopeID, regionID);
375 if (region != null) 327 if (region != null)
376 { 328 {
377 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates <{0},{1}>", 329 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates <{0},{1}>", Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
378 Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
379 regInfo = region; 330 regInfo = region;
380 return true; 331 return true;
381 } 332 }
382 333
383 regInfo.RegionID = regionID; 334 regInfo.RegionID = regionID;
335 regInfo.RegionSizeX = sizeX;
336 regInfo.RegionSizeY = sizeY;
384 337
385 if (externalName == string.Empty) 338 if (externalName == string.Empty)
386 regInfo.RegionName = regInfo.ServerURI; 339 regInfo.RegionName = regInfo.ServerURI;
@@ -412,7 +365,7 @@ namespace OpenSim.Services.GridService
412 OpenSim.Framework.RegionFlags rflags = (OpenSim.Framework.RegionFlags)Convert.ToInt32(regions[0].Data["flags"]); 365 OpenSim.Framework.RegionFlags rflags = (OpenSim.Framework.RegionFlags)Convert.ToInt32(regions[0].Data["flags"]);
413 if ((rflags & OpenSim.Framework.RegionFlags.Hyperlink) != 0) 366 if ((rflags & OpenSim.Framework.RegionFlags.Hyperlink) != 0)
414 { 367 {
415 regInfo = new GridRegion(); 368 regInfo = new GridRegion();
416 regInfo.RegionID = regions[0].RegionID; 369 regInfo.RegionID = regions[0].RegionID;
417 regInfo.ScopeID = m_ScopeID; 370 regInfo.ScopeID = m_ScopeID;
418 } 371 }
@@ -474,7 +427,7 @@ namespace OpenSim.Services.GridService
474 { 427 {
475 MainConsole.Instance.Output( 428 MainConsole.Instance.Output(
476 String.Format("{0}\n{2,-32} {1}\n", 429 String.Format("{0}\n{2,-32} {1}\n",
477 r.RegionName, r.RegionID, 430 r.RegionName, r.RegionID,
478 String.Format("{0},{1} ({2},{3})", r.posX, r.posY, 431 String.Format("{0},{1} ({2},{3})", r.posX, r.posY,
479 Util.WorldToRegionLoc((uint)r.posX), Util.WorldToRegionLoc((uint)r.posY) 432 Util.WorldToRegionLoc((uint)r.posX), Util.WorldToRegionLoc((uint)r.posY)
480 ) 433 )
@@ -556,7 +509,7 @@ namespace OpenSim.Services.GridService
556 if (cmdparams[2].StartsWith("http")) 509 if (cmdparams[2].StartsWith("http"))
557 { 510 {
558 RunLinkRegionCommand(cmdparams); 511 RunLinkRegionCommand(cmdparams);
559 } 512 }
560 else if (cmdparams[2].Contains(":")) 513 else if (cmdparams[2].Contains(":"))
561 { 514 {
562 // New format 515 // New format