public SweeperUDPServer(int port, Grid gridServers, AssetCache assetCache, InventoryCache inventoryCache, RegionInfo _regionData, ConsoleBase console, AuthenticateSessionsBase authenticateClass)
     : base(port, gridServers, assetCache, inventoryCache, _regionData, true, false, console, authenticateClass)
 {
 }
예제 #2
0
 /// <summary>
 /// Create a scene and its initial base structures.
 /// </summary>
 /// <param name="regionInfo"></param>
 /// <param name="clientServer"> </param>
 /// <returns></returns>
 protected Scene SetupScene(RegionInfo regionInfo)
 {
     return(SetupScene(regionInfo, 0, null));
 }
예제 #3
0
        // see BaseOpenSimServer
        public override void HandleShow(string mod, string[] cmd)
        {
            base.HandleShow(mod, cmd);

            List <string> args = new List <string>(cmd);

            args.RemoveAt(0);
            string[] showParams = args.ToArray();

            switch (showParams[0])
            {
            case "assets":
                if (AssetCache != null)
                {
                    AssetCache.ShowState();
                }
                else
                {
                    m_log.Info("Asset cache is not configured.");
                }
                break;

            case "users":
                IList agents;
                if (showParams.Length > 1 && showParams[1] == "full")
                {
                    agents = m_sceneManager.GetCurrentScenePresences();
                }
                else
                {
                    agents = m_sceneManager.GetCurrentSceneAvatars();
                }

                m_log.Info(String.Format("\nAgents connected: {0}\n", agents.Count));

                m_log.Info(
                    String.Format("{0,-16}{1,-16}{2,-37}{3,-11}{4,-16}", "Firstname", "Lastname",
                                  "Agent ID", "Root/Child", "Region"));

                foreach (ScenePresence presence in agents)
                {
                    RegionInfo regionInfo = m_sceneManager.GetRegionInfo(presence.RegionHandle);
                    string     regionName;

                    if (regionInfo == null)
                    {
                        regionName = "Unresolvable";
                    }
                    else
                    {
                        regionName = regionInfo.RegionName;
                    }

                    m_log.Info(
                        String.Format(
                            "{0,-16}{1,-16}{2,-37}{3,-11}{4,-16}",
                            presence.Firstname,
                            presence.Lastname,
                            presence.UUID,
                            presence.IsChildAgent ? "Child" : "Root",
                            regionName));
                }

                m_log.Info("");
                break;

            case "modules":
                m_log.Info("The currently loaded shared modules are:");
                foreach (IRegionModule module in m_moduleLoader.GetLoadedSharedModules)
                {
                    m_log.Info("Shared Module: " + module.Name);
                }
                break;

            case "regions":
                m_sceneManager.ForEachScene(
                    delegate(Scene scene)
                {
                    m_log.Info("Region Name: " + scene.RegionInfo.RegionName + " , Region XLoc: " +
                               scene.RegionInfo.RegionLocX + " , Region YLoc: " +
                               scene.RegionInfo.RegionLocY + " , Region Port: " +
                               scene.RegionInfo.InternalEndPoint.Port.ToString());
                });
                break;

            case "queues":
                Notice(GetQueuesReport());
                break;

            case "ratings":
                m_sceneManager.ForEachScene(
                    delegate(Scene scene)
                {
                    string rating = "";
                    if (scene.RegionInfo.RegionSettings.Maturity == 1)
                    {
                        rating = "MATURE";
                    }
                    else if (scene.RegionInfo.RegionSettings.Maturity == 2)
                    {
                        rating = "ADULT";
                    }
                    else
                    {
                        rating = "PG";
                    }
                    m_log.Info("Region Name: " + scene.RegionInfo.RegionName + " , Region Rating: " +
                               rating);
                });
                break;
            }
        }
예제 #4
0
        /// <summary>
        /// Execute the region creation process.  This includes setting up scene infrastructure.
        /// </summary>
        /// <param name="regionInfo"></param>
        /// <param name="portadd_flag"></param>
        /// <param name="do_post_init"></param>
        /// <returns></returns>
        public void CreateRegion(RegionInfo regionInfo, bool portadd_flag, bool do_post_init, out IScene mscene)
        {
            int port = regionInfo.InternalEndPoint.Port;

            // set initial RegionID to originRegionID in RegionInfo. (it needs for loding prims)
            // Commented this out because otherwise regions can't register with
            // the grid as there is already another region with the same UUID
            // at those coordinates. This is required for the load balancer to work.
            // --Mike, 2009.02.25
            //regionInfo.originRegionID = regionInfo.RegionID;

            // set initial ServerURI
            regionInfo.HttpPort = m_httpServerPort;
            if (m_httpServerSSL)
            {
                if (!m_httpServer.CheckSSLCertHost(regionInfo.ExternalHostName))
                {
                    throw new Exception("main http cert CN doesn't match region External IP");
                }

                regionInfo.ServerURI = "https://" + regionInfo.ExternalHostName +
                                       ":" + regionInfo.HttpPort.ToString() + "/";
            }
            else
            {
                regionInfo.ServerURI = "http://" + regionInfo.ExternalHostName +
                                       ":" + regionInfo.HttpPort.ToString() + "/";
            }


            regionInfo.osSecret = m_osSecret;

            if ((proxyUrl.Length > 0) && (portadd_flag))
            {
                // set proxy url to RegionInfo
                regionInfo.proxyUrl    = proxyUrl;
                regionInfo.ProxyOffset = proxyOffset;
                Util.XmlRpcCommand(proxyUrl, "AddPort", port, port + proxyOffset, regionInfo.ExternalHostName);
            }

            Scene scene = SetupScene(regionInfo, proxyOffset, Config);

            m_log.Info("[MODULES]: Loading Region's modules (old style)");

            // Use this in the future, the line above will be deprecated soon
            m_log.Info("[REGIONMODULES]: Loading Region's modules (new style)");
            IRegionModulesController controller;

            if (ApplicationRegistry.TryGet(out controller))
            {
                controller.AddRegionToModules(scene);
            }
            else
            {
                m_log.Error("[REGIONMODULES]: The new RegionModulesController is missing...");
            }

            if (m_securePermissionsLoading)
            {
                foreach (string s in m_permsModules)
                {
                    if (!scene.RegionModules.ContainsKey(s))
                    {
                        m_log.Fatal("[MODULES]: Required module " + s + " not found.");
                        Environment.Exit(0);
                    }
                }

                m_log.InfoFormat("[SCENE]: Secure permissions loading enabled, modules loaded: {0}", String.Join(" ", m_permsModules.ToArray()));
            }

            scene.SetModuleInterfaces();
// First Step of bootreport sequence
            if (scene.SnmpService != null)
            {
                scene.SnmpService.ColdStart(1, scene);
                scene.SnmpService.LinkDown(scene);
            }

            if (scene.SnmpService != null)
            {
                scene.SnmpService.BootInfo("Loading prims", scene);
            }

            while (regionInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null)
            {
                SetUpEstateOwner(scene);
            }

            scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID);

            // Prims have to be loaded after module configuration since some modules may be invoked during the load
            scene.LoadPrimsFromStorage(regionInfo.originRegionID);

            // TODO : Try setting resource for region xstats here on scene
            MainServer.Instance.AddSimpleStreamHandler(new RegionStatsSimpleHandler(regionInfo));

            if (scene.SnmpService != null)
            {
                scene.SnmpService.BootInfo("Grid Registration in progress", scene);
            }

            try
            {
                scene.RegisterRegionWithGrid();
            }
            catch (Exception e)
            {
                m_log.ErrorFormat(
                    "[STARTUP]: Registration of region with grid failed, aborting startup due to {0} {1}",
                    e.Message, e.StackTrace);

                if (scene.SnmpService != null)
                {
                    scene.SnmpService.Critical("Grid registration failed. Startup aborted.", scene);
                }
                // Carrying on now causes a lot of confusion down the
                // line - we need to get the user's attention
                Environment.Exit(1);
            }

            if (scene.SnmpService != null)
            {
                scene.SnmpService.BootInfo("Grid Registration done", scene);
            }

            // We need to do this after we've initialized the
            // scripting engines.
            scene.CreateScriptInstances();

            if (scene.SnmpService != null)
            {
                scene.SnmpService.BootInfo("ScriptEngine started", scene);
            }

            SceneManager.Add(scene);

            //if (m_autoCreateClientStack)
            //{
            //    foreach (IClientNetworkServer clientserver in clientServers)
            //    {
            //        m_clientServers.Add(clientserver);
            //        clientserver.Start();
            //    }
            //}

            if (scene.SnmpService != null)
            {
                scene.SnmpService.BootInfo("Initializing region modules", scene);
            }
            scene.EventManager.OnShutdown += delegate() { ShutdownRegion(scene); };

            mscene = scene;

            if (scene.SnmpService != null)
            {
                scene.SnmpService.BootInfo("The region is operational", scene);
                scene.SnmpService.LinkUp(scene);
            }

            //return clientServers;
        }
예제 #5
0
        /// <summary>
        /// Try to set up the estate owner for the given scene.
        /// </summary>
        /// <remarks>
        /// The involves asking the user for information about the user on the console.  If the user does not already
        /// exist then it is created.
        /// </remarks>
        /// <param name="scene"></param>
        private void SetUpEstateOwner(Scene scene)
        {
            RegionInfo regionInfo = scene.RegionInfo;

            string estateOwnerFirstName = null;
            string estateOwnerLastName  = null;
            string estateOwnerEMail     = null;
            string estateOwnerPassword  = null;
            string rawEstateOwnerUuid   = null;

            if (Config.Configs[ESTATE_SECTION_NAME] != null)
            {
                string defaultEstateOwnerName
                    = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerName", "").Trim();
                string[] ownerNames = defaultEstateOwnerName.Split(' ');

                if (ownerNames.Length >= 2)
                {
                    estateOwnerFirstName = ownerNames[0];
                    estateOwnerLastName  = ownerNames[1];
                }

                // Info to be used only on Standalone Mode
                rawEstateOwnerUuid  = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerUUID", null);
                estateOwnerEMail    = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerEMail", null);
                estateOwnerPassword = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerPassword", null);
            }

            MainConsole.Instance.Output("Estate {0} has no owner set.", regionInfo.EstateSettings.EstateName);
            List <char> excluded = new List <char>(new char[1] {
                ' '
            });


            if (estateOwnerFirstName == null || estateOwnerLastName == null)
            {
                estateOwnerFirstName = MainConsole.Instance.Prompt("Estate owner first name", "Test", excluded);
                estateOwnerLastName  = MainConsole.Instance.Prompt("Estate owner last name", "User", excluded);
            }

            UserAccount account
                = scene.UserAccountService.GetUserAccount(regionInfo.ScopeID, estateOwnerFirstName, estateOwnerLastName);

            if (account == null)
            {
                // XXX: The LocalUserAccountServicesConnector is currently registering its inner service rather than
                // itself!
//                    if (scene.UserAccountService is LocalUserAccountServicesConnector)
//                    {
//                        IUserAccountService innerUas
//                            = ((LocalUserAccountServicesConnector)scene.UserAccountService).UserAccountService;
//
//                        m_log.DebugFormat("B {0}", innerUas.GetType());
//
//                        if (innerUas is UserAccountService)
//                        {

                if (scene.UserAccountService is UserAccountService)
                {
                    if (estateOwnerPassword == null)
                    {
                        estateOwnerPassword = MainConsole.Instance.Prompt("Password", null, null, false);
                    }

                    if (estateOwnerEMail == null)
                    {
                        estateOwnerEMail = MainConsole.Instance.Prompt("Email");
                    }

                    if (rawEstateOwnerUuid == null)
                    {
                        rawEstateOwnerUuid = MainConsole.Instance.Prompt("User ID", UUID.Random().ToString());
                    }

                    UUID estateOwnerUuid = UUID.Zero;
                    if (!UUID.TryParse(rawEstateOwnerUuid, out estateOwnerUuid))
                    {
                        m_log.ErrorFormat("[OPENSIM]: ID {0} is not a valid UUID", rawEstateOwnerUuid);
                        return;
                    }

                    // If we've been given a zero uuid then this signals that we should use a random user id
                    if (estateOwnerUuid == UUID.Zero)
                    {
                        estateOwnerUuid = UUID.Random();
                    }

                    account
                        = ((UserAccountService)scene.UserAccountService).CreateUser(
                              regionInfo.ScopeID,
                              estateOwnerUuid,
                              estateOwnerFirstName,
                              estateOwnerLastName,
                              estateOwnerPassword,
                              estateOwnerEMail);
                }
            }

            if (account == null)
            {
                m_log.ErrorFormat(
                    "[OPENSIM]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first at the grid level.");
            }
            else
            {
                regionInfo.EstateSettings.EstateOwner = account.PrincipalID;
                m_estateDataService.StoreEstateSettings(regionInfo.EstateSettings);
            }
        }
예제 #6
0
        /// <summary>
        /// Execute the region creation process.  This includes setting up scene infrastructure.
        /// </summary>
        /// <param name="regionInfo"></param>
        /// <param name="portadd_flag"></param>
        /// <param name="do_post_init"></param>
        /// <returns></returns>
        private IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag, bool do_post_init, out IScene mscene)
        {
            int port = regionInfo.InternalEndPoint.Port;

            // set initial RegionID to originRegionID in RegionInfo. (it needs for loding prims)
            // Commented this out because otherwise regions can't register with
            // the grid as there is already another region with the same UUID
            // at those coordinates. This is required for the load balancer to work.
            // --Mike, 2009.02.25
            //regionInfo.originRegionID = regionInfo.RegionID;

            // set initial ServerURI
            regionInfo.HttpPort = m_httpServerPort;

            regionInfo.osSecret = m_osSecret;

            if (!String.IsNullOrEmpty(proxyUrl) && (portadd_flag))
            {
                // set proxy url to RegionInfo
                regionInfo.proxyUrl    = proxyUrl;
                regionInfo.ProxyOffset = proxyOffset;
                Util.XmlRpcCommand(proxyUrl, "AddPort", port, port + proxyOffset, regionInfo.ExternalHostName);
            }

            IClientNetworkServer clientServer;
            Scene scene = SetupScene(regionInfo, proxyOffset, m_config.Source, out clientServer);

            m_log.Info("[MODULES]: Loading Region's modules (old style)");

            List <IRegionModule> modules = m_moduleLoader.PickupModules(scene, ".");

            // This needs to be ahead of the script engine load, so the
            // script module can pick up events exposed by a module
            m_moduleLoader.InitializeSharedModules(scene);

            // Use this in the future, the line above will be deprecated soon
            m_log.Info("[MODULES]: Loading Region's modules (new style)");
            IRegionModulesController controller;

            if (ApplicationRegistry.TryGet(out controller))
            {
                controller.AddRegionToModules(scene);
            }
            else
            {
                m_log.Error("[MODULES]: The new RegionModulesController is missing...");
            }

            // Check if a (any) permission module has been loaded.
            // This can be any permissions module, including the default PermissionsModule with m_bypassPermissions==true.
            // To disable permissions, specify [Startup] permissionmodules=DefaultPermissionsModule in the .ini file, and
            // serverside_object_permissions=false, optionally propagate_permissions=false.
            if (!scene.Permissions.IsAvailable())
            {
                m_log.Error("[MODULES]: Permissions module is not set, or set incorrectly.");
                Environment.Exit(1);
                // Note that an Exit here can trigger a PhysX exception but if that happens it is the result of this
                // permissions problem and hopefully the lot will show this error and intentional exit.
            }

            scene.SetModuleInterfaces();

            // this must be done before prims try to rez or they'll rez over no land
            scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID);

            //we need to fire up the scene here. physics may depend ont he heartbeat running
            scene.Start();

            // Prims have to be loaded after module configuration since some modules may be invoked during the load
            scene.LoadPrimsFromStorage(regionInfo.originRegionID);

            // moved these here as the terrain texture has to be created after the modules are initialized
            // and has to happen before the region is registered with the grid.
            scene.CreateTerrainTexture(false);

            try
            {
                scene.RegisterRegionWithGrid();
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[STARTUP]: Registration of region with grid failed, aborting startup - {0}", e);

                // Carrying on now causes a lot of confusion down the
                // line - we need to get the user's attention
                Environment.Exit(1);
            }

            // We need to do this after we've initialized the
            // scripting engines.
            scene.CreateScriptInstances();

            scene.EventManager.TriggerParcelPrimCountUpdate();

            m_sceneManager.Add(scene);

            if (m_autoCreateClientStack)
            {
                m_clientServers.Add(clientServer);
                clientServer.Start();
            }

            if (do_post_init)
            {
                foreach (IRegionModule module in modules)
                {
                    module.PostInitialize();
                }
            }

            scene.EventManager.OnShutdown += delegate() { ShutdownRegion(scene); };

            mscene = scene;
            return(clientServer);
        }
예제 #7
0
 /// <summary>
 /// Execute the region creation process.  This includes setting up scene infrastructure.
 /// </summary>
 /// <param name="regionInfo"></param>
 /// <returns></returns>
 public void CreateRegion(RegionInfo regionInfo, out IScene scene)
 {
     CreateRegion(regionInfo, false, true, out scene);
 }
예제 #8
0
        /// <summary>
        /// Creates a new region based on the parameters specified.   This will ask the user questions on the console
        /// </summary>
        /// <param name="module"></param>
        /// <param name="cmd">0,1,region name, region ini or XML file</param>
        private void HandleCreateRegion(string module, string[] cmd)
        {
            string regionName = string.Empty;
            string regionFile = string.Empty;

            if (cmd.Length == 3)
            {
                regionFile = cmd[2];
            }
            else if (cmd.Length > 3)
            {
                regionName = cmd[2];
                regionFile = cmd[3];
            }

            string extension = Path.GetExtension(regionFile).ToLower();
            bool   isXml     = extension.Equals(".xml");
            bool   isIni     = extension.Equals(".ini");

            if (!isXml && !isIni)
            {
                MainConsole.Instance.Output("Usage: create region [\"region name\"] <region_file.ini>");
                return;
            }

            if (!Path.IsPathRooted(regionFile))
            {
                string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim();
                regionFile = Path.Combine(regionsDir, regionFile);
            }

            RegionInfo regInfo;

            if (isXml)
            {
                regInfo = new RegionInfo(regionName, regionFile, false, ConfigSource.Source);
            }
            else
            {
                regInfo = new RegionInfo(regionName, regionFile, false, ConfigSource.Source, regionName);
            }

            Scene existingScene;

            if (SceneManager.TryGetScene(regInfo.RegionID, out existingScene))
            {
                MainConsole.Instance.OutputFormat(
                    "ERROR: Cannot create region {0} with ID {1}, this ID is already assigned to region {2}",
                    regInfo.RegionName, regInfo.RegionID, existingScene.RegionInfo.RegionName);

                return;
            }

            bool   changed = PopulateRegionEstateInfo(regInfo);
            IScene scene;

            CreateRegion(regInfo, true, out scene);

            if (changed)
            {
                regInfo.EstateSettings.Save();
            }
        }
예제 #9
0
        // see BaseOpenSimServer
        /// <summary>
        /// Many commands list objects for debugging.  Some of the types are listed  here
        /// </summary>
        /// <param name="mod"></param>
        /// <param name="cmd"></param>
        public override void HandleShow(string mod, string[] cmd)
        {
            base.HandleShow(mod, cmd);

            List <string> args = new List <string>(cmd);

            args.RemoveAt(0);
            string[] showParams = args.ToArray();

            switch (showParams[0])
            {
            case "users":
                IList agents;
                if (showParams.Length > 1 && showParams[1] == "full")
                {
                    agents = SceneManager.GetCurrentScenePresences();
                }
                else
                {
                    agents = SceneManager.GetCurrentSceneAvatars();
                }

                MainConsole.Instance.Output(String.Format("\nAgents connected: {0}\n", agents.Count));

                MainConsole.Instance.Output(
                    String.Format("{0,-16} {1,-16} {2,-37} {3,-11} {4,-16} {5,-30}", "Firstname", "Lastname",
                                  "Agent ID", "Root/Child", "Region", "Position")
                    );

                foreach (ScenePresence presence in agents)
                {
                    RegionInfo regionInfo = presence.Scene.RegionInfo;
                    string     regionName;

                    if (regionInfo == null)
                    {
                        regionName = "Unresolvable";
                    }
                    else
                    {
                        regionName = regionInfo.RegionName;
                    }

                    MainConsole.Instance.Output(
                        String.Format(
                            "{0,-16} {1,-16} {2,-37} {3,-11} {4,-16} {5,-30}",
                            presence.Firstname,
                            presence.Lastname,
                            presence.UUID,
                            presence.IsChildAgent ? "Child" : "Root",
                            regionName,
                            presence.AbsolutePosition.ToString())
                        );
                }

                MainConsole.Instance.Output(String.Empty);
                break;

            case "connections":
                HandleShowConnections();
                break;

            case "circuits":
                HandleShowCircuits();
                break;

            case "modules":
                SceneManager.ForEachScene(
                    delegate(Scene scene) {
                    MainConsole.Instance.Output("Loaded region modules in" + scene.RegionInfo.RegionName + " are:");
                    foreach (IRegionModuleBase module in scene.RegionModules.Values)
                    {
                        Type type          = module.GetType().GetInterface("ISharedRegionModule");
                        string module_type = type != null ? "Shared" : "Non-Shared";
                        MainConsole.Instance.OutputFormat("New Region Module ({0}): {1}", module_type, module.Name);
                    }
                }
                    );

                MainConsole.Instance.Output("");
                break;

            case "regions":
                SceneManager.ForEachScene(
                    delegate(Scene scene)
                {
                    MainConsole.Instance.Output(String.Format(
                                                    "Region Name: {0}, Region XLoc: {1}, Region YLoc: {2}, Region Port: {3}, Estate Name: {4}",
                                                    scene.RegionInfo.RegionName,
                                                    scene.RegionInfo.RegionLocX,
                                                    scene.RegionInfo.RegionLocY,
                                                    scene.RegionInfo.InternalEndPoint.Port,
                                                    scene.RegionInfo.EstateSettings.EstateName));
                });
                break;

            case "ratings":
                SceneManager.ForEachScene(
                    delegate(Scene scene)
                {
                    string rating = "";
                    if (scene.RegionInfo.RegionSettings.Maturity == 1)
                    {
                        rating = "MATURE";
                    }
                    else if (scene.RegionInfo.RegionSettings.Maturity == 2)
                    {
                        rating = "ADULT";
                    }
                    else
                    {
                        rating = "PG";
                    }
                    MainConsole.Instance.Output(String.Format(
                                                    "Region Name: {0}, Region Rating {1}",
                                                    scene.RegionInfo.RegionName,
                                                    rating));
                });
                break;
            }
        }
예제 #10
0
        /// <summary>
        /// Execute the region creation process.  This includes setting up scene infrastructure.
        /// </summary>
        /// <param name="regionInfo"></param>
        /// <param name="portadd_flag"></param>
        /// <param name="do_post_init"></param>
        /// <returns></returns>
        public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag, bool do_post_init, out IScene mscene)
        {
            int port = regionInfo.InternalEndPoint.Port;

            // set initial RegionID to originRegionID in RegionInfo. (it needs for loding prims)
            // Commented this out because otherwise regions can't register with
            // the grid as there is already another region with the same UUID
            // at those coordinates. This is required for the load balancer to work.
            // --Mike, 2009.02.25
            //regionInfo.originRegionID = regionInfo.RegionID;

            // set initial ServerURI
            regionInfo.HttpPort  = m_httpServerPort;
            regionInfo.ServerURI = "http://" + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort.ToString() + "/";

            regionInfo.osSecret = m_osSecret;

            if ((proxyUrl.Length > 0) && (portadd_flag))
            {
                // set proxy url to RegionInfo
                regionInfo.proxyUrl    = proxyUrl;
                regionInfo.ProxyOffset = proxyOffset;
                Util.XmlRpcCommand(proxyUrl, "AddPort", port, port + proxyOffset, regionInfo.ExternalHostName);
            }

            IClientNetworkServer clientServer;
            Scene scene = SetupScene(regionInfo, proxyOffset, m_config.Source, out clientServer);

            m_log.Info("[MODULES]: Loading Region's modules (old style)");

            List <IRegionModule> modules = m_moduleLoader.PickupModules(scene, ".");

            // This needs to be ahead of the script engine load, so the
            // script module can pick up events exposed by a module
            m_moduleLoader.InitialiseSharedModules(scene);

            // Use this in the future, the line above will be deprecated soon
            m_log.Info("[REGIONMODULES]: Loading Region's modules (new style)");
            IRegionModulesController controller;

            if (ApplicationRegistry.TryGet(out controller))
            {
                controller.AddRegionToModules(scene);
            }
            else
            {
                m_log.Error("[REGIONMODULES]: The new RegionModulesController is missing...");
            }

            scene.SetModuleInterfaces();

            while (regionInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null)
            {
                SetUpEstateOwner(scene);
            }

            // Prims have to be loaded after module configuration since some modules may be invoked during the load
            scene.LoadPrimsFromStorage(regionInfo.originRegionID);

            // TODO : Try setting resource for region xstats here on scene
            MainServer.Instance.AddStreamHandler(new Region.Framework.Scenes.RegionStatsHandler(regionInfo));

            try
            {
                scene.RegisterRegionWithGrid();
            }
            catch (Exception e)
            {
                m_log.ErrorFormat(
                    "[STARTUP]: Registration of region with grid failed, aborting startup due to {0} {1}",
                    e.Message, e.StackTrace);

                // Carrying on now causes a lot of confusion down the
                // line - we need to get the user's attention
                Environment.Exit(1);
            }

            scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID);
            scene.EventManager.TriggerParcelPrimCountUpdate();

            // We need to do this after we've initialized the
            // scripting engines.
            scene.CreateScriptInstances();

            m_sceneManager.Add(scene);

            if (m_autoCreateClientStack)
            {
                m_clientServers.Add(clientServer);
                clientServer.Start();
            }

            if (do_post_init)
            {
                foreach (IRegionModule module in modules)
                {
                    module.PostInitialise();
                }
            }
            scene.EventManager.OnShutdown += delegate() { ShutdownRegion(scene); };

            mscene = scene;

            scene.StartTimer();

            scene.StartScripts();

            return(clientServer);
        }
예제 #11
0
 /// <summary>
 /// Create a scene and its initial base structures.
 /// </summary>
 /// <param name="regionInfo"></param>
 /// <param name="clientServer"> </param>
 /// <returns></returns>
 protected Scene SetupScene(RegionInfo regionInfo, out IClientNetworkServer clientServer)
 {
     return(SetupScene(regionInfo, 0, null, out clientServer));
 }
예제 #12
0
 /// <summary>
 /// Execute the region creation process.  This includes setting up scene infrastructure.
 /// </summary>
 /// <param name="regionInfo"></param>
 /// <returns></returns>
 public IClientNetworkServer CreateRegion(RegionInfo regionInfo, out IScene scene)
 {
     return(CreateRegion(regionInfo, false, true, out scene));
 }
예제 #13
0
 /// <summary>
 /// Execute the region creation process.  This includes setting up scene infrastructure.
 /// </summary>
 /// <param name="regionInfo"></param>
 /// <param name="portadd_flag"></param>
 /// <returns></returns>
 public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag, out IScene scene)
 {
     return(CreateRegion(regionInfo, portadd_flag, false, out scene));
 }
예제 #14
0
        /// <summary>
        /// Create a scene and its initial base structures.
        /// </summary>
        /// <param name="regionInfo"></param>
        /// <param name="proxyOffset"></param>
        /// <param name="configSource"></param>
        /// <param name="clientServer"> </param>
        /// <returns></returns>
        protected Scene SetupScene(
            RegionInfo regionInfo, int proxyOffset, IConfigSource configSource, out IClientNetworkServer clientServer)
        {
            IPAddress listenIP = regionInfo.InternalEndPoint.Address;
            //if (!IPAddress.TryParse(regionInfo.InternalEndPoint, out listenIP))
            //    listenIP = IPAddress.Parse("0.0.0.0");

            uint port = (uint)regionInfo.InternalEndPoint.Port;

            if (m_autoCreateClientStack)
            {
                clientServer
                    = m_clientStackManager.CreateServer(
                          listenIP, ref port, proxyOffset, regionInfo.m_allow_alternate_ports, configSource,
                          m_assetCache);
            }
            else
            {
                clientServer = null;
            }

            regionInfo.InternalEndPoint.Port = (int)port;

            // TODO: Remove this cruft once MasterAvatar is fully deprecated
            //Master Avatar Setup
            UserProfileData masterAvatar;

            if (regionInfo.MasterAvatarAssignedUUID == UUID.Zero)
            {
                masterAvatar =
                    m_commsManager.UserService.SetupMasterUser(regionInfo.MasterAvatarFirstName,
                                                               regionInfo.MasterAvatarLastName,
                                                               regionInfo.MasterAvatarSandboxPassword);
            }
            else
            {
                masterAvatar = m_commsManager.UserService.SetupMasterUser(regionInfo.MasterAvatarAssignedUUID);
            }

            if (masterAvatar == null)
            {
                regionInfo.MasterAvatarAssignedUUID = UUID.Zero;
                m_log.Error("[PARCEL]: No master avatar found, using null UUID for master avatar.");
                // Should be a fatal error?
            }
            else
            {
                regionInfo.MasterAvatarAssignedUUID = masterAvatar.ID;
                regionInfo.MasterAvatarFirstName    = masterAvatar.FirstName;
                regionInfo.MasterAvatarLastName     = masterAvatar.SurName;
                m_log.InfoFormat("[PARCEL]: Found master avatar {0} {1} [{2}]",
                                 regionInfo.MasterAvatarFirstName,
                                 regionInfo.MasterAvatarLastName,
                                 regionInfo.MasterAvatarAssignedUUID.ToString()
                                 );
            }

            Scene scene = CreateScene(regionInfo, m_storageManager);

            if (m_autoCreateClientStack)
            {
                clientServer.AddScene(scene);
            }

            scene.LoadWorldMap();

            scene.PhysicsScene = GetPhysicsScene(scene.RegionInfo.RegionName, scene.RegionInfo.RegionID);
            scene.PhysicsScene.TerrainChannel = scene.Heightmap;
            scene.PhysicsScene.RegionSettings = scene.RegionInfo.RegionSettings;
            scene.PhysicsScene.SetStartupTerrain(scene.Heightmap.GetFloatsSerialized(), scene.Heightmap.RevisionNumber);
            scene.PhysicsScene.SetWaterLevel((float)regionInfo.RegionSettings.WaterHeight);

            return(scene);
        }
예제 #15
0
        public SimClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, World world, Dictionary<uint, SimClient> clientThreads, AssetCache assetCache, IGridServer gridServer, OpenSimNetworkHandler application, InventoryCache inventoryCache, bool sandboxMode, bool child, RegionInfo regionDat)
        {
            m_world = world;
            m_clientThreads = clientThreads;
            m_assetCache = assetCache;
            m_gridServer = gridServer;
            m_application = application;
            m_inventoryCache = inventoryCache;
            m_sandboxMode = sandboxMode;
            m_child = child;
            m_regionData = regionDat;

            OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs - Started up new client thread to handle incoming request");
            cirpack = initialcirpack;
            userEP = remoteEP;
            if (m_gridServer.GetName() == "Remote")
            {
                this.startpos = ((RemoteGridBase)m_gridServer).agentcircuits[initialcirpack.CircuitCode.Code].startpos;
            }
            else
            {
                this.startpos = new LLVector3(128, 128, m_world.Terrain[(int)128, (int)128] + 15.0f); // new LLVector3(128.0f, 128.0f, 60f);
            }
            PacketQueue = new BlockingQueue<QueItem>();

            this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache);
            AckTimer = new System.Timers.Timer(500);
            AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed);
            AckTimer.Start();

            this.RegisterLocalPacketHandlers();

            ClientThread = new Thread(new ThreadStart(AuthUser));
            ClientThread.IsBackground = true;
            ClientThread.Start();
        }
예제 #16
0
 /// <summary>
 /// Execute the region creation process.  This includes setting up scene infrastructure.
 /// </summary>
 /// <param name="regionInfo"></param>
 /// <param name="portadd_flag"></param>
 /// <returns></returns>
 public void CreateRegion(RegionInfo regionInfo, bool portadd_flag, out IScene scene)
 {
     CreateRegion(regionInfo, portadd_flag, false, out scene);
 }
예제 #17
0
        /// <summary>
        /// Performs initialisation of the world, such as loading configuration from disk.
        /// </summary>
        public virtual void StartUp()
        {
            this.regionData = new RegionInfo();
            try
            {
                this.localConfig = new XmlConfig(m_config);
                this.localConfig.LoadData();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            m_console.WriteLine("Main.cs:Startup() - Loading configuration");
            this.regionData.InitConfig(this.m_sandbox, this.localConfig);
            this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change

            GridServers = new Grid();
            if (m_sandbox)
            {
                GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
                GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll";

                m_console.WriteLine("Starting in Sandbox mode");
            }
            else
            {
                if (this.gridLocalAsset)
                {
                    GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
                }
                else
                {
                    GridServers.AssetDll = "OpenSim.GridInterfaces.Remote.dll";
                }
                GridServers.GridDll = "OpenSim.GridInterfaces.Remote.dll";

                m_console.WriteLine("Starting in Grid mode");
            }

            try
            {
                GridServers.Initialise();
            }
            catch (Exception e)
            {
                m_console.WriteLine(e.Message + "\nSorry, could not setup the grid interface");
                Environment.Exit(1);
            }

            startuptime = DateTime.Now;

            try
            {
                AssetCache = new AssetCache(GridServers.AssetServer);
                InventoryCache = new InventoryCache();
            }
            catch (Exception e)
            {
                m_console.WriteLine(e.Message + "\nSorry, could not setup local cache");
                Environment.Exit(1);
            }

            //should be passing a IGenericConfig object to these so they can read the config data they want from it
            GridServers.AssetServer.SetServerInfo(regionData.AssetURL, regionData.AssetSendKey);
            IGridServer gridServer = GridServers.GridServer;
            gridServer.SetServerInfo(regionData.GridURL, regionData.GridSendKey, regionData.GridRecvKey);

            this.physManager = new OpenSim.Physics.Manager.PhysicsManager();
            this.physManager.LoadPlugins();

            this.CustomiseStartup();

            m_console.WriteLine("Main.cs:Startup() - Initialising HTTP server");
            // HttpServer = new SimCAPSHTTPServer(GridServers.GridServer, Cfg.IPListenPort);

            BaseHttpServer httpServer = new BaseHttpServer(regionData.IPListenPort);
            LoginServer loginServer = null;
            LoginServer adminLoginServer = null;

            bool sandBoxWithLoginServer = m_loginserver && m_sandbox;
            if (sandBoxWithLoginServer)
            {
                loginServer = new LoginServer(gridServer, regionData.IPListenAddr, regionData.IPListenPort,regionData.RegionLocX, regionData.RegionLocY, this.user_accounts);
                loginServer.Startup();

                if (user_accounts)
                {
                    //sandbox mode with loginserver using accounts
                    this.GridServers.UserServer = loginServer;
                    adminLoginServer = loginServer;

                    httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod);
                }
                else
                {
                    //sandbox mode with loginserver not using accounts
                    httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod);
                }
            }

            AdminWebFront adminWebFront = new AdminWebFront("Admin", LocalWorld, InventoryCache, adminLoginServer);
            adminWebFront.LoadMethods(httpServer);

            m_console.WriteLine("Main.cs:Startup() - Starting HTTP server");
            httpServer.Start();

            MainServerListener();

            m_heartbeatTimer.Enabled = true;
            m_heartbeatTimer.Interval = 100;
            m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
        }
 protected abstract Scene CreateScene(RegionInfo regionInfo, ISimulationDataService simDataService, IEstateDataService estateDataService, AgentCircuitManager circuitManager);