diff options
author | Oren Hurvitz | 2014-04-13 11:51:47 +0300 |
---|---|---|
committer | Oren Hurvitz | 2014-04-13 09:54:56 +0100 |
commit | e1dd228f1851bc3ac6da896d5564c19746065d0f (patch) | |
tree | ca6263f19010b76b48202f33cbf76ee9ba011ec6 /OpenSim/Services/GridService/HypergridLinker.cs | |
parent | BulletSim: reduce the terrain collison margin to be the same as other (diff) | |
download | opensim-SC-e1dd228f1851bc3ac6da896d5564c19746065d0f.zip opensim-SC-e1dd228f1851bc3ac6da896d5564c19746065d0f.tar.gz opensim-SC-e1dd228f1851bc3ac6da896d5564c19746065d0f.tar.bz2 opensim-SC-e1dd228f1851bc3ac6da896d5564c19746065d0f.tar.xz |
Better error checking when creating hyperlinks: a) Reject invalid strings; b) Default port is 80, not 0
The change of default port may fix http://opensimulator.org/mantis/view.php?id=7108 , where a user was able to create a Hyperlink to OSGrid from inside OSGrid.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Services/GridService/HypergridLinker.cs | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 4ebfd5c..1cc75c1 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs | |||
@@ -202,18 +202,27 @@ namespace OpenSim.Services.GridService | |||
202 | 202 | ||
203 | if (!mapName.StartsWith("http")) | 203 | if (!mapName.StartsWith("http")) |
204 | { | 204 | { |
205 | string host = "127.0.0.1"; | 205 | // Formats: grid.example.com:8002:region name |
206 | string portstr; | 206 | // grid.example.com:region name |
207 | // grid.example.com | ||
208 | |||
209 | string host; | ||
210 | uint port = 80; | ||
207 | string regionName = ""; | 211 | string regionName = ""; |
208 | uint port = 0; | 212 | |
209 | string[] parts = mapName.Split(new char[] { ':' }); | 213 | string[] parts = mapName.Split(new char[] { ':' }); |
210 | if (parts.Length >= 1) | 214 | |
215 | if (parts.Length == 0) | ||
211 | { | 216 | { |
212 | host = parts[0]; | 217 | reason = "Wrong format for link-region"; |
218 | return null; | ||
213 | } | 219 | } |
220 | |||
221 | host = parts[0]; | ||
222 | |||
214 | if (parts.Length >= 2) | 223 | if (parts.Length >= 2) |
215 | { | 224 | { |
216 | portstr = parts[1]; | 225 | string portstr = parts[1]; |
217 | //m_log.Debug("-- port = " + portstr); | 226 | //m_log.Debug("-- port = " + portstr); |
218 | if (!UInt32.TryParse(portstr, out port)) | 227 | if (!UInt32.TryParse(portstr, out port)) |
219 | regionName = parts[1]; | 228 | regionName = parts[1]; |
@@ -234,13 +243,22 @@ namespace OpenSim.Services.GridService | |||
234 | } | 243 | } |
235 | else | 244 | else |
236 | { | 245 | { |
237 | string[] parts = mapName.Split(new char[] {' '}); | 246 | // Formats: http://grid.example.com region name |
238 | string regionName = String.Empty; | 247 | // http://grid.example.com "region name" |
239 | if (parts.Length > 1) | 248 | |
249 | string regionName; | ||
250 | |||
251 | string[] parts = mapName.Split(new char[] { ' ' }); | ||
252 | |||
253 | if (parts.Length < 2) | ||
240 | { | 254 | { |
241 | regionName = mapName.Substring(parts[0].Length + 1); | 255 | reason = "Wrong format for link-region"; |
242 | regionName = regionName.Trim(new char[] {'"'}); | 256 | return null; |
243 | } | 257 | } |
258 | |||
259 | regionName = mapName.Substring(parts[0].Length + 1); | ||
260 | regionName = regionName.Trim(new char[] {'"'}); | ||
261 | |||
244 | if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, parts[0], ownerID, out regInfo, out reason)) | 262 | if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, parts[0], ownerID, out regInfo, out reason)) |
245 | { | 263 | { |
246 | regInfo.RegionName = mapName; | 264 | regInfo.RegionName = mapName; |
@@ -258,7 +276,7 @@ namespace OpenSim.Services.GridService | |||
258 | 276 | ||
259 | public bool TryCreateLink(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason) | 277 | public bool TryCreateLink(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason) |
260 | { | 278 | { |
261 | m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0} {1}, in {2}-{3}", | 279 | m_log.InfoFormat("[HYPERGRID LINKER]: Link to {0} {1}, in {2}-{3}", |
262 | ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI), | 280 | ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI), |
263 | remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc)); | 281 | remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc)); |
264 | 282 | ||
@@ -266,15 +284,15 @@ namespace OpenSim.Services.GridService | |||
266 | Uri uri = null; | 284 | Uri uri = null; |
267 | 285 | ||
268 | regInfo = new GridRegion(); | 286 | regInfo = new GridRegion(); |
269 | if ( externalPort > 0) | 287 | if (externalPort > 0) |
270 | regInfo.HttpPort = externalPort; | 288 | regInfo.HttpPort = externalPort; |
271 | else | 289 | else |
272 | regInfo.HttpPort = 0; | 290 | regInfo.HttpPort = 80; |
273 | if ( externalHostName != null) | 291 | if (externalHostName != null) |
274 | regInfo.ExternalHostName = externalHostName; | 292 | regInfo.ExternalHostName = externalHostName; |
275 | else | 293 | else |
276 | regInfo.ExternalHostName = "0.0.0.0"; | 294 | regInfo.ExternalHostName = "0.0.0.0"; |
277 | if ( serverURI != null) | 295 | if (serverURI != null) |
278 | { | 296 | { |
279 | regInfo.ServerURI = serverURI; | 297 | regInfo.ServerURI = serverURI; |
280 | try | 298 | try |
@@ -286,7 +304,7 @@ namespace OpenSim.Services.GridService | |||
286 | catch {} | 304 | catch {} |
287 | } | 305 | } |
288 | 306 | ||
289 | if ( remoteRegionName != string.Empty ) | 307 | if (remoteRegionName != string.Empty) |
290 | regInfo.RegionName = remoteRegionName; | 308 | regInfo.RegionName = remoteRegionName; |
291 | 309 | ||
292 | regInfo.RegionLocX = xloc; | 310 | regInfo.RegionLocX = xloc; |
@@ -299,6 +317,7 @@ namespace OpenSim.Services.GridService | |||
299 | { | 317 | { |
300 | if (regInfo.ExternalHostName == m_ThisGatekeeperURI.Host && regInfo.HttpPort == m_ThisGatekeeperURI.Port) | 318 | if (regInfo.ExternalHostName == m_ThisGatekeeperURI.Host && regInfo.HttpPort == m_ThisGatekeeperURI.Port) |
301 | { | 319 | { |
320 | m_log.InfoFormat("[HYPERGRID LINKER]: Cannot hyperlink to regions on the same grid"); | ||
302 | reason = "Cannot hyperlink to regions on the same grid"; | 321 | reason = "Cannot hyperlink to regions on the same grid"; |
303 | return false; | 322 | return false; |
304 | } | 323 | } |