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)
        {
            m_log.InfoFormat("[HYPERGRID LINKER]: Link to {0} {1}, in <{2},{3}>",
                             ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI),
                             remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc));

            reason = string.Empty;
            Uri uri = null;

            regInfo = new GridRegion();
            if (externalPort > 0)
            {
                regInfo.HttpPort = externalPort;
            }
            else
            {
                regInfo.HttpPort = 80;
            }
            if (externalHostName != null)
            {
                regInfo.ExternalHostName = externalHostName;
            }
            else
            {
                regInfo.ExternalHostName = "0.0.0.0";
            }
            if (serverURI != null)
            {
                regInfo.ServerURI = serverURI;
                try
                {
                    uri = new Uri(serverURI);
                    regInfo.ExternalHostName = uri.Host;
                    regInfo.HttpPort         = (uint)uri.Port;
                }
                catch {}
            }

            if (remoteRegionName != string.Empty)
            {
                regInfo.RegionName = remoteRegionName;
            }

            regInfo.RegionLocX  = xloc;
            regInfo.RegionLocY  = yloc;
            regInfo.ScopeID     = scopeID;
            regInfo.EstateOwner = ownerID;

            // Make sure we're not hyperlinking to regions on this grid!
            if (m_ThisGatekeeperURI != null)
            {
                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";
                    return(false);
                }
            }
            else
            {
                m_log.WarnFormat("[HYPERGRID LINKER]: Please set this grid's Gatekeeper's address in [GridService]!");
            }

            // Check for free coordinates
            GridRegion region = m_GridService.GetRegionByPosition(regInfo.ScopeID, regInfo.RegionLocX, regInfo.RegionLocY);

            if (region != null)
            {
                m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates <{0},{1}> are already occupied by region {2} with uuid {3}",
                                 Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY),
                                 region.RegionName, region.RegionID);
                reason = "Coordinates are already in use";
                return(false);
            }

            try
            {
                regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
            }
            catch (Exception e)
            {
                m_log.Warn("[HYPERGRID LINKER]: Wrong format for link-region: " + e.Message);
                reason = "Internal error";
                return(false);
            }

            // Finally, link it
            ulong  handle       = 0;
            UUID   regionID     = UUID.Zero;
            string externalName = string.Empty;
            string imageURL     = string.Empty;
            int    sizeX        = (int)Constants.RegionSize;
            int    sizeY        = (int)Constants.RegionSize;

            if (!m_GatekeeperConnector.LinkRegion(regInfo, out regionID, out handle, out externalName, out imageURL, out reason, out sizeX, out sizeY))
            {
                return(false);
            }

            if (regionID == UUID.Zero)
            {
                m_log.Warn("[HYPERGRID LINKER]: Unable to link region");
                reason = "Remote region could not be found";
                return(false);
            }

            region = m_GridService.GetRegionByUUID(scopeID, regionID);
            if (region != null)
            {
                m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates <{0},{1}>",
                                  Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
                regInfo = region;
                return(true);
            }

            // We are now performing this check for each individual teleport in the EntityTransferModule instead.  This
            // allows us to give better feedback when teleports fail because of the distance reason (which can't be
            // done here) and it also hypergrid teleports that are within range (possibly because the source grid
            // itself has regions that are very far apart).
//            uint x, y;
//            if (m_Check4096 && !Check4096(handle, out x, out y))
//            {
//                //RemoveHyperlinkRegion(regInfo.RegionID);
//                reason = "Region is too far (" + x + ", " + y + ")";
//                m_log.Info("[HYPERGRID LINKER]: Unable to link, region is too far (" + x + ", " + y + ")");
//                //return false;
//            }

            regInfo.RegionID    = regionID;
            regInfo.RegionSizeX = sizeX;
            regInfo.RegionSizeY = sizeY;

            if (externalName == string.Empty)
            {
                regInfo.RegionName = regInfo.ServerURI;
            }
            else
            {
                regInfo.RegionName = externalName;
            }

            m_log.DebugFormat("[HYPERGRID LINKER]: naming linked region {0}, handle {1}", regInfo.RegionName, handle.ToString());

            // Get the map image
            regInfo.TerrainImage = GetMapImage(regionID, imageURL);

            // Store the origin's coordinates somewhere
            regInfo.RegionSecret = handle.ToString();

            AddHyperlinkRegion(regInfo, handle);
            m_log.InfoFormat("[HYPERGRID LINKER]: Successfully linked to region {0} at <{1},{2}> with image {3}",
                             regInfo.RegionName, Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY), regInfo.TerrainImage);
            return(true);
        }
Example #2
0
        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}",
                              ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI),
                              remoteRegionName, xloc / Constants.RegionSize, yloc / Constants.RegionSize);

            reason = string.Empty;
            Uri uri = null;

            regInfo = new GridRegion();
            if (externalPort > 0)
            {
                regInfo.HttpPort = externalPort;
            }
            else
            {
                regInfo.HttpPort = 0;
            }
            if (externalHostName != null)
            {
                regInfo.ExternalHostName = externalHostName;
            }
            else
            {
                regInfo.ExternalHostName = "0.0.0.0";
            }
            if (serverURI != null)
            {
                regInfo.ServerURI = serverURI;
                try
                {
                    uri = new Uri(serverURI);
                    regInfo.ExternalHostName = uri.Host;
                    regInfo.HttpPort         = (uint)uri.Port;
                }
                catch {}
            }

            if (remoteRegionName != string.Empty)
            {
                regInfo.RegionName = remoteRegionName;
            }

            regInfo.RegionLocX  = xloc;
            regInfo.RegionLocY  = yloc;
            regInfo.ScopeID     = scopeID;
            regInfo.EstateOwner = ownerID;

            // Make sure we're not hyperlinking to regions on this grid!
            if (m_ThisGatekeeperURI != null)
            {
                if (regInfo.ExternalHostName == m_ThisGatekeeperURI.Host && regInfo.HttpPort == m_ThisGatekeeperURI.Port)
                {
                    reason = "Cannot hyperlink to regions on the same grid";
                    return(false);
                }
            }
            else
            {
                m_log.WarnFormat("[HYPERGRID LINKER]: Please set this grid's Gatekeeper's address in [GridService]!");
            }

            // Check for free coordinates
            GridRegion region = m_GridService.GetRegionByPosition(regInfo.ScopeID, regInfo.RegionLocX, regInfo.RegionLocY);

            if (region != null)
            {
                m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates {0}-{1} are already occupied by region {2} with uuid {3}",
                                 regInfo.RegionLocX / Constants.RegionSize, regInfo.RegionLocY / Constants.RegionSize,
                                 region.RegionName, region.RegionID);
                reason = "Coordinates are already in use";
                return(false);
            }

            try
            {
                regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
            }
            catch (Exception e)
            {
                m_log.Warn("[HYPERGRID LINKER]: Wrong format for link-region: " + e.Message);
                reason = "Internal error";
                return(false);
            }

            // Finally, link it
            ulong  handle       = 0;
            UUID   regionID     = UUID.Zero;
            string externalName = string.Empty;
            string imageURL     = string.Empty;

            if (!m_GatekeeperConnector.LinkRegion(regInfo, out regionID, out handle, out externalName, out imageURL, out reason))
            {
                return(false);
            }

            if (regionID == UUID.Zero)
            {
                m_log.Warn("[HYPERGRID LINKER]: Unable to link region");
                reason = "Remote region could not be found";
                return(false);
            }

            region = m_GridService.GetRegionByUUID(scopeID, regionID);
            if (region != null)
            {
                m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}",
                                  region.RegionLocX / Constants.RegionSize, region.RegionLocY / Constants.RegionSize);
                regInfo = region;
                return(true);
            }

            uint x, y;

            if (m_Check4096 && !Check4096(handle, out x, out y))
            {
                RemoveHyperlinkRegion(regInfo.RegionID);
                reason = "Region is too far (" + x + ", " + y + ")";
                m_log.Info("[HYPERGRID LINKER]: Unable to link, region is too far (" + x + ", " + y + ")");
                return(false);
            }

            regInfo.RegionID = regionID;

            if (externalName == string.Empty)
            {
                regInfo.RegionName = regInfo.ServerURI;
            }
            else
            {
                regInfo.RegionName = externalName;
            }

            m_log.Debug("[HYPERGRID LINKER]: naming linked region " + regInfo.RegionName);

            // Get the map image
            regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL, m_MapTileDirectory);

            AddHyperlinkRegion(regInfo, handle);
            m_log.InfoFormat("[HYPERGRID LINKER]: Successfully linked to region {0} with image {1}", regInfo.RegionName, regInfo.TerrainImage);
            return(true);
        }
Example #3
0
        // From the command line and the 2 above
        public bool TryCreateLink(UUID scopeID, int xloc, int yloc,
                                  string externalRegionName, uint externalPort, string externalHostName, UUID ownerID,
                                  out GridRegion regInfo, out string reason)
        {
            m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0}:{1}:{2}, in {3}-{4}", externalHostName, externalPort, externalRegionName, xloc, yloc);

            reason                   = string.Empty;
            regInfo                  = new GridRegion();
            regInfo.RegionName       = externalRegionName;
            regInfo.HttpPort         = externalPort;
            regInfo.ExternalHostName = externalHostName;
            regInfo.RegionLocX       = xloc;
            regInfo.RegionLocY       = yloc;
            regInfo.ScopeID          = scopeID;
            regInfo.EstateOwner      = ownerID;

            // Big HACK for Simian Grid !!!
            // We need to clean up all URLs used in OpenSim !!!
            if (externalHostName.Contains("/"))
            {
                regInfo.ServerURI = externalHostName;
            }

            // Check for free coordinates
            GridRegion region = m_GridService.GetRegionByPosition(regInfo.ScopeID, regInfo.RegionLocX, regInfo.RegionLocY);

            if (region != null)
            {
                m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates {0}-{1} are already occupied by region {2} with uuid {3}", regInfo.RegionLocX, regInfo.RegionLocY, region.RegionName, region.RegionID);
                reason = "Coordinates are already in use";
                return(false);
            }

            try
            {
                regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
            }
            catch (Exception e)
            {
                m_log.Warn("[HYPERGRID LINKER]: Wrong format for link-region: " + e.Message);
                reason = "Internal error";
                return(false);
            }

            // Finally, link it
            ulong  handle       = 0;
            UUID   regionID     = UUID.Zero;
            string externalName = string.Empty;
            string imageURL     = string.Empty;

            if (!m_GatekeeperConnector.LinkRegion(regInfo, out regionID, out handle, out externalName, out imageURL, out reason))
            {
                return(false);
            }

            if (regionID != UUID.Zero)
            {
                region = m_GridService.GetRegionByUUID(scopeID, regionID);
                if (region != null)
                {
                    m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", region.RegionLocX / Constants.RegionSize, region.RegionLocY / Constants.RegionSize);
                    regInfo = region;
                    return(true);
                }

                regInfo.RegionID = regionID;
                if (regInfo.RegionName == string.Empty)
                {
                    regInfo.RegionName = regInfo.ExternalHostName;
                }

                // Try get the map image
                //regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL);
                // I need a texture that works for this... the one I tried doesn't seem to be working
                regInfo.TerrainImage = m_HGMapImage;

                AddHyperlinkRegion(regInfo, handle);
                m_log.Info("[HYPERGRID LINKER]: Successfully linked to region_uuid " + regInfo.RegionID);
            }
            else
            {
                m_log.Warn("[HYPERGRID LINKER]: Unable to link region");
                reason = "Remote region could not be found";
                return(false);
            }

            uint x, y;

            if (m_Check4096 && !Check4096(handle, out x, out y))
            {
                RemoveHyperlinkRegion(regInfo.RegionID);
                reason = "Region is too far (" + x + ", " + y + ")";
                m_log.Info("[HYPERGRID LINKER]: Unable to link, region is too far (" + x + ", " + y + ")");
                return(false);
            }

            m_log.Debug("[HYPERGRID LINKER]: link region succeeded");
            return(true);
        }
Example #4
0
        private bool TryCreateLinkImpl(UUID scopeID, int xloc, int yloc, RegionURI rurl, UUID ownerID, out GridRegion regInfo)
        {
            m_log.InfoFormat("[HYPERGRID LINKER]: Link to {0} {1}, in <{2},{3}>",
                             rurl.HostUrl, rurl.RegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc));


            // Check for free coordinates
            GridRegion region = m_GridService.GetRegionByPosition(scopeID, xloc, yloc);

            if (region != null)
            {
                m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates <{0},{1}> are already occupied by region {2} with uuid {3}",
                                 Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc),
                                 region.RegionName, region.RegionID);
                regInfo = null;
                return(false);
            }

            regInfo = new GridRegion()
            {
                HttpPort         = (uint)rurl.Port,
                ExternalHostName = rurl.Host,
                ServerURI        = rurl.HostUrl,
                RegionName       = rurl.RegionName,

                RegionLocX       = xloc,
                RegionLocY       = yloc,
                ScopeID          = scopeID,
                EstateOwner      = ownerID,
                InternalEndPoint = dummyIP
            };

            // Finally, link it
            ulong  handle       = 0;
            UUID   regionID     = UUID.Zero;
            string externalName = string.Empty;
            string imageURL     = string.Empty;
            int    sizeX        = (int)Constants.RegionSize;
            int    sizeY        = (int)Constants.RegionSize;

            if (!m_GatekeeperConnector.LinkRegion(regInfo, out regionID, out handle, out externalName, out imageURL, out string reason, out sizeX, out sizeY))
            {
                return(false);
            }

            if (regionID == UUID.Zero)
            {
                m_log.Warn("[HYPERGRID LINKER]: Unable to link region: " + reason);
                return(false);
            }

            region = m_GridService.GetRegionByUUID(scopeID, regionID);
            if (region != null)
            {
                m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates <{0},{1}>",
                                  Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
                regInfo = region;
                return(true);
            }

            regInfo.RegionID    = regionID;
            regInfo.RegionSizeX = sizeX;
            regInfo.RegionSizeY = sizeY;

            if (externalName == string.Empty)
            {
                regInfo.RegionName = regInfo.ServerURI;
            }
            else
            {
                regInfo.RegionName = externalName;
            }

            m_log.DebugFormat("[HYPERGRID LINKER]: naming linked region {0}, handle {1}", regInfo.RegionName, handle.ToString());

            // Get the map image
            regInfo.TerrainImage = GetMapImage(regionID, imageURL);

            // Store the origin's coordinates somewhere
            regInfo.RegionSecret = handle.ToString();

            AddHyperlinkRegion(regInfo, handle);
            m_log.InfoFormat("[HYPERGRID LINKER]: Successfully linked to region {0} at <{1},{2}> with image {3}",
                             regInfo.RegionName, Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY), regInfo.TerrainImage);
            return(true);
        }