Example #1
0
        public virtual void Configure(IConfigSource config, IRegistryCore registry)
        {
            m_config = config;
            IConfig gridConfig = config.Configs["GridService"];

            if (gridConfig != null)
            {
                m_DisableRegistrations  = gridConfig.GetBoolean("DisableRegistrations", m_DisableRegistrations);
                m_AllowNewRegistrations = gridConfig.GetBoolean("AllowNewRegistrations", m_AllowNewRegistrations);
                m_DeleteOnUnregister    = gridConfig.GetBoolean("DeleteOnUnregister", m_DeleteOnUnregister);
                m_maxRegionSize         = gridConfig.GetInt("MaxRegionSize", m_maxRegionSize);
                m_RegionViewSize        = gridConfig.GetInt("RegionViewSize", m_RegionViewSize / Constants.RegionSize) *
                                          Constants.RegionSize;
                m_DeleteOnUnregister  = gridConfig.GetBoolean("DeleteOnUnregister", m_DeleteOnUnregister);
                m_UseSessionID        = !gridConfig.GetBoolean("DisableSessionID", !m_UseSessionID);
                m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames);
            }

            if (m_RootInstance == null)
            {
                m_RootInstance = this;

                if (MainConsole.Instance != null)
                {
                    MainConsole.Instance.Commands.AddCommand("show region",
                                                             "show region [Region name]",
                                                             "Show details on a region",
                                                             HandleShowRegion);

                    MainConsole.Instance.Commands.AddCommand("set region flags",
                                                             "set region flags [Region name] [flags]",
                                                             "Set database flags for region",
                                                             HandleSetFlags);

                    MainConsole.Instance.Commands.AddCommand("grid clear regions",
                                                             "grid clear regions",
                                                             "Clears all regions from the database",
                                                             HandleClearAllRegions);

                    MainConsole.Instance.Commands.AddCommand("grid clear down regions",
                                                             "grid clear down regions",
                                                             "Clears all regions that are offline from the database",
                                                             HandleClearAllDownRegions);

                    MainConsole.Instance.Commands.AddCommand("grid clear region",
                                                             "grid clear region [RegionName]",
                                                             "Clears the regions with the given name from the database",
                                                             HandleClearRegion);
                }
            }
            registry.RegisterModuleInterface <IGridService>(this);
        }
Example #2
0
        public void Initialize(IConfigSource config, IRegistryCore registry)
        {
            IConfig handlerConfig = config.Configs["Handlers"];
            if (handlerConfig.GetString("GridHandler", "") != Name)
                return;

            m_registry = registry;
            m_localService = new GridService();
            m_localService.Configure(config, registry);
            m_remoteService = new GridServicesConnector();
            m_remoteService.Initialize(config, registry);
            registry.RegisterModuleInterface<IGridService>(this);
        }
Example #3
0
        public HypergridLinker(IConfigSource config, GridService gridService, IRegionData db)
        {
            m_log.DebugFormat("[HYPERGRID LINKER]: Starting with db {0}", db.GetType());

            m_Database    = db;
            m_GridService = gridService;

            IConfig gridConfig = config.Configs["GridService"];

            if (gridConfig != null)
            {
                string assetService = gridConfig.GetString("AssetService", string.Empty);

                Object[] args = new Object[] { config };

                if (assetService != string.Empty)
                {
                    m_AssetService = ServerUtils.LoadPlugin <IAssetService>(assetService, args);
                }

                string scope = gridConfig.GetString("ScopeID", string.Empty);
                if (scope != string.Empty)
                {
                    UUID.TryParse(scope, out m_ScopeID);
                }

                m_Check4096 = gridConfig.GetBoolean("Check4096", true);

                m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService);

                m_log.DebugFormat("[HYPERGRID LINKER]: Loaded all services...");
            }

            if (MainConsole.Instance != null)
            {
                MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region",
                                                         "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
                                                         "Link a hypergrid region", RunCommand);
                MainConsole.Instance.Commands.AddCommand("hypergrid", false, "unlink-region",
                                                         "unlink-region <local name> or <HostName>:<HttpPort> <cr>",
                                                         "Unlink a hypergrid region", RunCommand);
                MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [<x> <y>] <cr>",
                                                         "Set local coordinate to map HG regions to", RunCommand);
                MainConsole.Instance.Commands.AddCommand("hypergrid", false, "show hyperlinks", "show hyperlinks <cr>",
                                                         "List the HG regions", HandleShow);
            }
        }
        public GridService(IConfigSource config)
            : base(config)
        {
            m_log.DebugFormat("[GRID SERVICE]: Starting...");

            m_config = config;
            IConfig gridConfig = config.Configs["GridService"];

            if (gridConfig != null)
            {
                m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true);

                string authService = gridConfig.GetString("AuthenticationService", String.Empty);

                if (authService != String.Empty)
                {
                    Object[] args = new Object[] { config };
                    m_AuthenticationService = ServerUtils.LoadPlugin <IAuthenticationService>(authService, args);
                }
                m_AllowDuplicateNames     = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames);
                m_AllowHypergridMapSearch = gridConfig.GetBoolean("AllowHypergridMapSearch", m_AllowHypergridMapSearch);
            }

            if (m_RootInstance == null)
            {
                m_RootInstance = this;

                if (MainConsole.Instance != null)
                {
                    MainConsole.Instance.Commands.AddCommand("grid", true,
                                                             "show region",
                                                             "show region <Region name>",
                                                             "Show details on a region",
                                                             String.Empty,
                                                             HandleShowRegion);

                    MainConsole.Instance.Commands.AddCommand("grid", true,
                                                             "set region flags",
                                                             "set region flags <Region name> <flags>",
                                                             "Set database flags for region",
                                                             String.Empty,
                                                             HandleSetFlags);
                }
                m_HypergridLinker = new HypergridLinker(m_config, this, m_Database);
            }
        }
        public GridService(IConfigSource config)
            : base(config)
        {
            m_log.DebugFormat("[GRID SERVICE]: Starting...");

            m_config = config;
            IConfig gridConfig = config.Configs["GridService"];
            if (gridConfig != null)
            {
                m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true);
                
                string authService = gridConfig.GetString("AuthenticationService", String.Empty);

                if (authService != String.Empty)
                {
                    Object[] args = new Object[] { config };
                    m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args);
                }
                m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames);
                m_AllowHypergridMapSearch = gridConfig.GetBoolean("AllowHypergridMapSearch", m_AllowHypergridMapSearch);
            }
            
            if (m_RootInstance == null)
            {
                m_RootInstance = this;

                if (MainConsole.Instance != null)
                {
                    MainConsole.Instance.Commands.AddCommand("grid", true,
                            "show region",
                            "show region <Region name>",
                            "Show details on a region",
                            String.Empty,
                            HandleShowRegion);

                    MainConsole.Instance.Commands.AddCommand("grid", true,
                            "set region flags",
                            "set region flags <Region name> <flags>",
                            "Set database flags for region",
                            String.Empty,
                            HandleSetFlags);
                }
                m_HypergridLinker = new HypergridLinker(m_config, this, m_Database);
            }
        }
Example #6
0
        public GridService(IConfigSource config)
            : base(config)
        {
            m_log.DebugFormat("[GRID SERVICE]: Starting...");

            m_config = config;
            IConfig gridConfig = config.Configs["GridService"];
            if (gridConfig != null)
            {
                m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true);
                
                string authService = gridConfig.GetString("AuthenticationService", String.Empty);

                if (authService != String.Empty)
                {
                    Object[] args = new Object[] { config };
                    m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args);
                }
                m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames);
                m_AllowHypergridMapSearch = gridConfig.GetBoolean("AllowHypergridMapSearch", m_AllowHypergridMapSearch);
            }
            
            if (m_RootInstance == null)
            {
                m_RootInstance = this;

                if (MainConsole.Instance != null)
                {
                    MainConsole.Instance.Commands.AddCommand("Regions", true,
                            "deregister region id",
                            "deregister region id <Region UUID>",
                            "Deregister a region manually.",
                            String.Empty,
                            HandleDeregisterRegion);

                    // A messy way of stopping this command being added if we are in standalone (since the simulator
                    // has an identically named command
                    //
                    // XXX: We're relying on the OpenSimulator version being registered first, which is not well defined.
                    if (MainConsole.Instance.Commands.Resolve(new string[] { "show", "regions" }).Length == 0)
                        MainConsole.Instance.Commands.AddCommand("Regions", true,
                                "show regions",
                                "show regions",
                                "Show details on all regions",
                                String.Empty,
                                HandleShowRegions);

                    MainConsole.Instance.Commands.AddCommand("Regions", true,
                            "show region name",
                            "show region name <Region name>",
                            "Show details on a region",
                            String.Empty,
                            HandleShowRegion);

                    MainConsole.Instance.Commands.AddCommand("Regions", true,
                            "show region at",
                            "show region at <x-coord> <y-coord>",
                            "Show details on a region at the given co-ordinate.",
                            "For example, show region at 1000 1000",
                            HandleShowRegionAt);

                    MainConsole.Instance.Commands.AddCommand("Regions", true,
                            "set region flags",
                            "set region flags <Region name> <flags>",
                            "Set database flags for region",
                            String.Empty,
                            HandleSetFlags);
                }
                m_HypergridLinker = new HypergridLinker(m_config, this, m_Database);
            }
        }
        public HypergridLinker(IConfigSource config, GridService gridService, IRegionData db)
        {
            IConfig gridConfig = config.Configs["GridService"];

            if (gridConfig == null)
            {
                return;
            }

            if (!gridConfig.GetBoolean("HypergridLinker", false))
            {
                return;
            }

            m_Database    = db;
            m_GridService = gridService;
            m_log.DebugFormat("[HYPERGRID LINKER]: Starting with db {0}", db.GetType());

            string assetService = gridConfig.GetString("AssetService", string.Empty);

            Object[] args = new Object[] { config };

            if (assetService != string.Empty)
            {
                m_AssetService = ServerUtils.LoadPlugin <IAssetService>(assetService, args);
            }

            string scope = gridConfig.GetString("ScopeID", string.Empty);

            if (scope != string.Empty)
            {
                UUID.TryParse(scope, out m_ScopeID);
            }

//                m_Check4096 = gridConfig.GetBoolean("Check4096", true);

            m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", "maptiles");

            m_ThisGatekeeper = Util.GetConfigVarFromSections <string>(config, "GatekeeperURI",
                                                                      new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty);
            // Legacy. Remove soon!
            m_ThisGatekeeper = gridConfig.GetString("Gatekeeper", m_ThisGatekeeper);
            try
            {
                m_ThisGatekeeperURI = new Uri(m_ThisGatekeeper);
            }
            catch
            {
                m_log.WarnFormat("[HYPERGRID LINKER]: Malformed URL in [GridService], variable Gatekeeper = {0}", m_ThisGatekeeper);
            }

            m_ThisGatekeeper = m_ThisGatekeeperURI.AbsoluteUri;
            if (m_ThisGatekeeperURI.Port == 80)
            {
                m_ThisGatekeeper = m_ThisGatekeeper.Trim(new char[] { '/', ' ' }) + ":80/";
            }
            else if (m_ThisGatekeeperURI.Port == 443)
            {
                m_ThisGatekeeper = m_ThisGatekeeper.Trim(new char[] { '/', ' ' }) + ":443/";
            }

            m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService);

            m_log.Debug("[HYPERGRID LINKER]: Loaded all services...");

            if (!string.IsNullOrEmpty(m_MapTileDirectory))
            {
                try
                {
                    Directory.CreateDirectory(m_MapTileDirectory);
                }
                catch (Exception e)
                {
                    m_log.WarnFormat("[HYPERGRID LINKER]: Could not create map tile storage directory {0}: {1}", m_MapTileDirectory, e);
                    m_MapTileDirectory = string.Empty;
                }
            }

            if (MainConsole.Instance != null)
            {
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region",
                                                         "link-region <Xloc> <Yloc> <ServerURI> [<RemoteRegionName>]",
                                                         "Link a HyperGrid Region. Examples for <ServerURI>: http://grid.net:8002/ or http://example.org/path/foo.php", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region",
                                                         "link-region <Xloc> <Yloc> <RegionIP> <RegionPort> [<RemoteRegionName>]",
                                                         "Link a hypergrid region (deprecated)", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "unlink-region",
                                                         "unlink-region <local name>",
                                                         "Unlink a hypergrid region", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-mapping", "link-mapping [<x> <y>]",
                                                         "Set local coordinate to map HG regions to", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "show hyperlinks", "show hyperlinks",
                                                         "List the HG regions", HandleShow);
            }
        }
Example #8
0
        public GridService(IConfigSource config)
            : base(config)
        {
            m_log.DebugFormat("[GRID SERVICE]: Starting...");

            m_config = config;
            IConfig gridConfig = config.Configs["GridService"];

            bool suppressConsoleCommands = false;

            if (gridConfig != null)
            {
                m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true);
                
                string authService = gridConfig.GetString("AuthenticationService", String.Empty);

                if (authService != String.Empty)
                {
                    Object[] args = new Object[] { config };
                    m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args);
                }
                m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames);
                m_AllowHypergridMapSearch = gridConfig.GetBoolean("AllowHypergridMapSearch", m_AllowHypergridMapSearch);

                m_SuppressVarregionOverlapCheckOnRegistration = gridConfig.GetBoolean("SuppressVarregionOverlapCheckOnRegistration", m_SuppressVarregionOverlapCheckOnRegistration);

                // This service is also used locally by a simulator running in grid mode.  This switches prevents
                // inappropriate console commands from being registered
                suppressConsoleCommands = gridConfig.GetBoolean("SuppressConsoleCommands", suppressConsoleCommands);
            }

            if (m_RootInstance == null)
            {
                m_RootInstance = this;

                if (!suppressConsoleCommands && MainConsole.Instance != null)
                {
                    MainConsole.Instance.Commands.AddCommand("Regions", true,
                            "deregister region id",
                            "deregister region id <region-id>+",
                            "Deregister a region manually.",
                            String.Empty,
                            HandleDeregisterRegion);

                    MainConsole.Instance.Commands.AddCommand("Regions", true,
                            "show regions",
                            "show regions",
                            "Show details on all regions",
                            String.Empty,
                            HandleShowRegions);

                    MainConsole.Instance.Commands.AddCommand("Regions", true,
                            "show region name",
                            "show region name <Region name>",
                            "Show details on a region",
                            String.Empty,
                            HandleShowRegion);

                    MainConsole.Instance.Commands.AddCommand("Regions", true,
                            "show region at",
                            "show region at <x-coord> <y-coord>",
                            "Show details on a region at the given co-ordinate.",
                            "For example, show region at 1000 1000",
                            HandleShowRegionAt);

                    MainConsole.Instance.Commands.AddCommand("General", true,
                            "show grid size",
                            "show grid size",
                            "Show the current grid size (excluding hyperlink references)",
                            String.Empty,
                            HandleShowGridSize);

                    MainConsole.Instance.Commands.AddCommand("Regions", true,
                             "set region flags",
                             "set region flags <Region name> <flags>",
                             "Set database flags for region",
                             String.Empty,
                             HandleSetFlags);
                }

                if (!suppressConsoleCommands)
                    SetExtraServiceURLs(config);

                m_HypergridLinker = new HypergridLinker(m_config, this, m_Database);
            }
        }
        public HypergridLinker(IConfigSource config, GridService gridService, IRegionData db)
        {
            m_log.DebugFormat("[HYPERGRID LINKER]: Starting with db {0}", db.GetType());

            m_Database = db;
            m_GridService = gridService;

            IConfig gridConfig = config.Configs["GridService"];
            if (gridConfig != null)
            {
                string assetService = gridConfig.GetString("AssetService", string.Empty);

                Object[] args = new Object[] { config };

                if (assetService != string.Empty)
                    m_AssetService = ServerUtils.LoadPlugin<IAssetService>(assetService, args);

                string scope = gridConfig.GetString("ScopeID", string.Empty);
                if (scope != string.Empty)
                    UUID.TryParse(scope, out m_ScopeID);

                m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService);

                m_log.DebugFormat("[HYPERGRID LINKER]: Loaded all services...");
            }

            if (MainConsole.Instance != null)
            {
                MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region",
                    "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
                    "Link a hypergrid region", RunCommand);
                MainConsole.Instance.Commands.AddCommand("hypergrid", false, "unlink-region",
                    "unlink-region <local name> or <HostName>:<HttpPort> <cr>",
                    "Unlink a hypergrid region", RunCommand);
                MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [<x> <y>] <cr>",
                    "Set local coordinate to map HG regions to", RunCommand);
                MainConsole.Instance.Commands.AddCommand("hypergrid", false, "show hyperlinks", "show hyperlinks <cr>",
                    "List the HG regions", HandleShow);
            }
        }
        public GridService(IConfigSource config)
            : base(config)
        {
            m_log.DebugFormat("[GRID SERVICE]: Starting...");

            m_config = config;
            IConfig gridConfig = config.Configs["GridService"];

            if (gridConfig != null)
            {
                m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true);

                string authService = gridConfig.GetString("AuthenticationService", String.Empty);

                if (authService != String.Empty)
                {
                    Object[] args = new Object[] { config };
                    m_AuthenticationService = ServerUtils.LoadPlugin <IAuthenticationService>(authService, args);
                }
                m_AllowDuplicateNames     = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames);
                m_AllowHypergridMapSearch = gridConfig.GetBoolean("AllowHypergridMapSearch", m_AllowHypergridMapSearch);
            }

            if (m_RootInstance == null)
            {
                m_RootInstance = this;

                if (MainConsole.Instance != null)
                {
                    MainConsole.Instance.Commands.AddCommand("Regions", true,
                                                             "deregister region id",
                                                             "deregister region id <region-id>+",
                                                             "Deregister a region manually.",
                                                             String.Empty,
                                                             HandleDeregisterRegion);

                    // A messy way of stopping this command being added if we are in standalone (since the simulator
                    // has an identically named command
                    //
                    // XXX: We're relying on the OpenSimulator version being registered first, which is not well defined.
                    if (MainConsole.Instance.Commands.Resolve(new string[] { "show", "regions" }).Length == 0)
                    {
                        MainConsole.Instance.Commands.AddCommand("Regions", true,
                                                                 "show regions",
                                                                 "show regions",
                                                                 "Show details on all regions",
                                                                 String.Empty,
                                                                 HandleShowRegions);
                    }

                    MainConsole.Instance.Commands.AddCommand("Regions", true,
                                                             "show region name",
                                                             "show region name <Region name>",
                                                             "Show details on a region",
                                                             String.Empty,
                                                             HandleShowRegion);

                    MainConsole.Instance.Commands.AddCommand("Regions", true,
                                                             "show region at",
                                                             "show region at <x-coord> <y-coord>",
                                                             "Show details on a region at the given co-ordinate.",
                                                             "For example, show region at 1000 1000",
                                                             HandleShowRegionAt);

                    MainConsole.Instance.Commands.AddCommand("Regions", true,
                                                             "set region flags",
                                                             "set region flags <Region name> <flags>",
                                                             "Set database flags for region",
                                                             String.Empty,
                                                             HandleSetFlags);
                }
                m_HypergridLinker = new HypergridLinker(m_config, this, m_Database);
            }
        }
Example #11
0
        public HypergridLinker(IConfigSource config, GridService gridService, IRegionData db)
        {
            IConfig gridConfig = config.Configs["GridService"];

            if (gridConfig == null)
            {
                return;
            }

            if (!gridConfig.GetBoolean("HypergridLinker", false))
            {
                return;
            }

            m_Database    = db;
            m_GridService = gridService;
            m_log.DebugFormat("[HYPERGRID LINKER]: Starting with db {0}", db.GetType());

            string assetService = gridConfig.GetString("AssetService", string.Empty);

            Object[] args = new Object[] { config };

            if (assetService != string.Empty)
            {
                m_AssetService = ServerUtils.LoadPlugin <IAssetService>(assetService, args);
            }

            string scope = gridConfig.GetString("ScopeID", string.Empty);

            if (scope != string.Empty)
            {
                UUID.TryParse(scope, out m_ScopeID);
            }

//                m_Check4096 = gridConfig.GetBoolean("Check4096", true);

            m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", "maptiles");

            m_ThisGridInfo = new GridInfo(config);
            if (!m_ThisGridInfo.HasHGConfig)
            {
                throw new Exception("missing HyperGrid configuration");
            }

            m_log.DebugFormat("[HYPERGRID LINKER]: Local Gatekeeper: {0}", m_ThisGridInfo.GateKeeperURL);

            m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService);

            m_log.Debug("[HYPERGRID LINKER]: Loaded all services...");

            if (!string.IsNullOrEmpty(m_MapTileDirectory))
            {
                try
                {
                    Directory.CreateDirectory(m_MapTileDirectory);
                }
                catch (Exception e)
                {
                    m_log.WarnFormat("[HYPERGRID LINKER]: Could not create map tile storage directory {0}: {1}", m_MapTileDirectory, e);
                    m_MapTileDirectory = string.Empty;
                }
            }

            if (MainConsole.Instance != null)
            {
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region",
                                                         "link-region <Xloc> <Yloc> <ServerURI> [<RemoteRegionName>]",
                                                         "Link a HyperGrid Region. Examples for <ServerURI>: http://grid.net:8002/ or http://example.org/path/foo.php", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region",
                                                         "link-region <Xloc> <Yloc> <RegionIP> <RegionPort> [<RemoteRegionName>]",
                                                         "Link a hypergrid region (deprecated)", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "unlink-region",
                                                         "unlink-region <local name>",
                                                         "Unlink a hypergrid region", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-mapping", "link-mapping [<x> <y>]",
                                                         "Set local coordinate to map HG regions to", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "show hyperlinks", "show hyperlinks",
                                                         "List the HG regions", HandleShow);
            }
        }
Example #12
0
        public GridService(IConfigSource config)
            : base(config)
        {
            m_log.DebugFormat("[GRID SERVICE]: Starting...");

            m_config = config;
            IConfig gridConfig = config.Configs["GridService"];

            bool suppressConsoleCommands = false;

            if (gridConfig != null)
            {
                m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true);

                string authService = gridConfig.GetString("AuthenticationService", String.Empty);

                if (authService != String.Empty)
                {
                    Object[] args = new Object[] { config };
                    m_AuthenticationService = ServerUtils.LoadPlugin <IAuthenticationService>(authService, args);
                }
                m_AllowDuplicateNames     = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames);
                m_AllowHypergridMapSearch = gridConfig.GetBoolean("AllowHypergridMapSearch", m_AllowHypergridMapSearch);

                m_SuppressVarregionOverlapCheckOnRegistration = gridConfig.GetBoolean("SuppressVarregionOverlapCheckOnRegistration", m_SuppressVarregionOverlapCheckOnRegistration);

                // This service is also used locally by a simulator running in grid mode.  This switches prevents
                // inappropriate console commands from being registered
                suppressConsoleCommands = gridConfig.GetBoolean("SuppressConsoleCommands", suppressConsoleCommands);
            }

            if (m_RootInstance == null)
            {
                m_RootInstance = this;

                if (!suppressConsoleCommands && MainConsole.Instance != null)
                {
                    MainConsole.Instance.Commands.AddCommand("Regions", true,
                                                             "deregister region id",
                                                             "deregister region id <region-id>+",
                                                             "Deregister a region manually.",
                                                             String.Empty,
                                                             HandleDeregisterRegion);

                    MainConsole.Instance.Commands.AddCommand("Regions", true,
                                                             "show regions",
                                                             "show regions",
                                                             "Show details on all regions",
                                                             String.Empty,
                                                             HandleShowRegions);

                    MainConsole.Instance.Commands.AddCommand("Regions", true,
                                                             "show region name",
                                                             "show region name <Region name>",
                                                             "Show details on a region",
                                                             String.Empty,
                                                             HandleShowRegion);

                    MainConsole.Instance.Commands.AddCommand("Regions", true,
                                                             "show region at",
                                                             "show region at <x-coord> <y-coord>",
                                                             "Show details on a region at the given co-ordinate.",
                                                             "For example, show region at 1000 1000",
                                                             HandleShowRegionAt);

                    MainConsole.Instance.Commands.AddCommand("General", true,
                                                             "show grid size",
                                                             "show grid size",
                                                             "Show the current grid size (excluding hyperlink references)",
                                                             String.Empty,
                                                             HandleShowGridSize);

                    MainConsole.Instance.Commands.AddCommand("Regions", true,
                                                             "set region flags",
                                                             "set region flags <Region name> <flags>",
                                                             "Set database flags for region",
                                                             String.Empty,
                                                             HandleSetFlags);
                }

                if (!suppressConsoleCommands)
                {
                    SetExtraServiceURLs(config);
                }

                m_HypergridLinker = new HypergridLinker(m_config, this, m_Database);
            }
        }
        public HypergridLinker(IConfigSource config, GridService gridService, IRegionData db)
        {
            IConfig gridConfig = config.Configs["GridService"];

            if (gridConfig == null)
            {
                return;
            }

            if (!gridConfig.GetBoolean("HypergridLinker", false))
            {
                return;
            }

            m_Database    = db;
            m_GridService = gridService;
            m_log.DebugFormat("[HYPERGRID LINKER]: Starting with db {0}", db.GetType());

            string assetService = gridConfig.GetString("AssetService", string.Empty);

            Object[] args = new Object[] { config };

            if (assetService != string.Empty)
            {
                m_AssetService = ServerUtils.LoadPlugin <IAssetService>(assetService, args);
            }

            string scope = gridConfig.GetString("ScopeID", string.Empty);

            if (scope != string.Empty)
            {
                UUID.TryParse(scope, out m_ScopeID);
            }

//                m_Check4096 = gridConfig.GetBoolean("Check4096", true);

            m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", "maptiles");

            m_ThisGatekeeperURI = Util.GetConfigVarFromSections <string>(config, "GatekeeperURI",
                                                                         new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty);
            m_ThisGatekeeperURI = gridConfig.GetString("Gatekeeper", m_ThisGatekeeperURI);

            if (!Util.checkServiceURI(m_ThisGatekeeperURI, out m_ThisGatekeeperURI, out m_ThisGatekeeperHost, out m_ThisGateKeeperIP))
            {
                m_log.ErrorFormat("[HYPERGRID LINKER]: Malformed URL in [GridService], variable Gatekeeper = {0}", m_ThisGatekeeperURI);
                throw new Exception("Failed to resolve gatekeeper external IP, please check GatekeeperURI configuration");
            }

            string gatekeeperURIAlias = Util.GetConfigVarFromSections <string>(config, "GatekeeperURIAlias",
                                                                               new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty);

            if (!string.IsNullOrWhiteSpace(gatekeeperURIAlias))
            {
                string[] alias = gatekeeperURIAlias.Split(',');
                for (int i = 0; i < alias.Length; ++i)
                {
                    if (!string.IsNullOrWhiteSpace(alias[i]))
                    {
                        m_ThisGateKeeperAlias.Add(alias[i].Trim().ToLower());
                    }
                }
            }

            m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService);

            m_log.Debug("[HYPERGRID LINKER]: Loaded all services...");

            if (!string.IsNullOrEmpty(m_MapTileDirectory))
            {
                try
                {
                    Directory.CreateDirectory(m_MapTileDirectory);
                }
                catch (Exception e)
                {
                    m_log.WarnFormat("[HYPERGRID LINKER]: Could not create map tile storage directory {0}: {1}", m_MapTileDirectory, e);
                    m_MapTileDirectory = string.Empty;
                }
            }

            if (MainConsole.Instance != null)
            {
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region",
                                                         "link-region <Xloc> <Yloc> <ServerURI> [<RemoteRegionName>]",
                                                         "Link a HyperGrid Region. Examples for <ServerURI>: http://grid.net:8002/ or http://example.org/path/foo.php", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-region",
                                                         "link-region <Xloc> <Yloc> <RegionIP> <RegionPort> [<RemoteRegionName>]",
                                                         "Link a hypergrid region (deprecated)", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "unlink-region",
                                                         "unlink-region <local name>",
                                                         "Unlink a hypergrid region", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "link-mapping", "link-mapping [<x> <y>]",
                                                         "Set local coordinate to map HG regions to", RunCommand);
                MainConsole.Instance.Commands.AddCommand("Hypergrid", false, "show hyperlinks", "show hyperlinks",
                                                         "List the HG regions", HandleShow);
            }
        }