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.0.8.0.3
parent
c8914d22eb
commit
e1dd228f18
|
@ -202,18 +202,27 @@ namespace OpenSim.Services.GridService
|
||||||
|
|
||||||
if (!mapName.StartsWith("http"))
|
if (!mapName.StartsWith("http"))
|
||||||
{
|
{
|
||||||
string host = "127.0.0.1";
|
// Formats: grid.example.com:8002:region name
|
||||||
string portstr;
|
// grid.example.com:region name
|
||||||
|
// grid.example.com
|
||||||
|
|
||||||
|
string host;
|
||||||
|
uint port = 80;
|
||||||
string regionName = "";
|
string regionName = "";
|
||||||
uint port = 0;
|
|
||||||
string[] parts = mapName.Split(new char[] { ':' });
|
string[] parts = mapName.Split(new char[] { ':' });
|
||||||
if (parts.Length >= 1)
|
|
||||||
|
if (parts.Length == 0)
|
||||||
{
|
{
|
||||||
host = parts[0];
|
reason = "Wrong format for link-region";
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
host = parts[0];
|
||||||
|
|
||||||
if (parts.Length >= 2)
|
if (parts.Length >= 2)
|
||||||
{
|
{
|
||||||
portstr = parts[1];
|
string portstr = parts[1];
|
||||||
//m_log.Debug("-- port = " + portstr);
|
//m_log.Debug("-- port = " + portstr);
|
||||||
if (!UInt32.TryParse(portstr, out port))
|
if (!UInt32.TryParse(portstr, out port))
|
||||||
regionName = parts[1];
|
regionName = parts[1];
|
||||||
|
@ -234,13 +243,22 @@ namespace OpenSim.Services.GridService
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Formats: http://grid.example.com region name
|
||||||
|
// http://grid.example.com "region name"
|
||||||
|
|
||||||
|
string regionName;
|
||||||
|
|
||||||
string[] parts = mapName.Split(new char[] { ' ' });
|
string[] parts = mapName.Split(new char[] { ' ' });
|
||||||
string regionName = String.Empty;
|
|
||||||
if (parts.Length > 1)
|
if (parts.Length < 2)
|
||||||
{
|
{
|
||||||
|
reason = "Wrong format for link-region";
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
regionName = mapName.Substring(parts[0].Length + 1);
|
regionName = mapName.Substring(parts[0].Length + 1);
|
||||||
regionName = regionName.Trim(new char[] {'"'});
|
regionName = regionName.Trim(new char[] {'"'});
|
||||||
}
|
|
||||||
if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, parts[0], ownerID, out regInfo, out reason))
|
if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, parts[0], ownerID, out regInfo, out reason))
|
||||||
{
|
{
|
||||||
regInfo.RegionName = mapName;
|
regInfo.RegionName = mapName;
|
||||||
|
@ -258,7 +276,7 @@ namespace OpenSim.Services.GridService
|
||||||
|
|
||||||
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)
|
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)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0} {1}, in {2}-{3}",
|
m_log.InfoFormat("[HYPERGRID LINKER]: Link to {0} {1}, in {2}-{3}",
|
||||||
((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI),
|
((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI),
|
||||||
remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc));
|
remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc));
|
||||||
|
|
||||||
|
@ -269,7 +287,7 @@ namespace OpenSim.Services.GridService
|
||||||
if (externalPort > 0)
|
if (externalPort > 0)
|
||||||
regInfo.HttpPort = externalPort;
|
regInfo.HttpPort = externalPort;
|
||||||
else
|
else
|
||||||
regInfo.HttpPort = 0;
|
regInfo.HttpPort = 80;
|
||||||
if (externalHostName != null)
|
if (externalHostName != null)
|
||||||
regInfo.ExternalHostName = externalHostName;
|
regInfo.ExternalHostName = externalHostName;
|
||||||
else
|
else
|
||||||
|
@ -299,6 +317,7 @@ namespace OpenSim.Services.GridService
|
||||||
{
|
{
|
||||||
if (regInfo.ExternalHostName == m_ThisGatekeeperURI.Host && regInfo.HttpPort == m_ThisGatekeeperURI.Port)
|
if (regInfo.ExternalHostName == m_ThisGatekeeperURI.Host && regInfo.HttpPort == m_ThisGatekeeperURI.Port)
|
||||||
{
|
{
|
||||||
|
m_log.InfoFormat("[HYPERGRID LINKER]: Cannot hyperlink to regions on the same grid");
|
||||||
reason = "Cannot hyperlink to regions on the same grid";
|
reason = "Cannot hyperlink to regions on the same grid";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue