Exemplo n.º 1
0
        //creates a config file in the specified base path
        public Config(string base_path)
        {
            if (!Directory.Exists (base_path))
                Directory.CreateDirectory (base_path);

            string path = System.IO.Path.Combine (base_path, "fuse_settings.ini");

            if (!File.Exists (path))
                File.WriteAllText (path, "");

            source =  new IniConfigSource (path);

            bool addWindow = true;
            bool addMediaControls = true;

            foreach (IConfig config in source.Configs)
            {
                if (config.Name == "Window")
                    addWindow = false;
                else if (config.Name == "Media Controls")
                    addMediaControls = false;
            }

            if (addWindow)
                source.AddConfig ("Window");
            if (addMediaControls)
                source.AddConfig ("Media Controls");
        }
Exemplo n.º 2
0
        public IniWrapper(string xrnsFile, bool forceCreateIni)
        {
            Assembly assembly = Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly();
            string   iniPath  = Path.Combine(Path.GetDirectoryName(assembly.Location), "ini", Path.GetFileNameWithoutExtension(xrnsFile) + ".ini");

            this.IniPath = iniPath;
            bool iniExists = File.Exists(iniPath);

            if (forceCreateIni || iniExists)
            {
                if (iniExists == false)
                {
                    File.Create(iniPath).Dispose();
                }

                configSource = new IniConfigSource(iniPath);
                if (iniExists == false)
                {
                    configSource.AddConfig("volume");
                    configSource.AddConfig("frequency");
                    configSource.AddConfig("sinc");
                }
                configSource.AutoSave = true;

                this.IsIniLoad = true;
            }
        }
Exemplo n.º 3
0
        private bool SaveValues()
        {
            if (!VerifyInput())
            {
                return(false);
            }

            IConfig cfg = config.Configs["PeerInfo"];

            if (cfg == null)
            {
                cfg = config.AddConfig("PeerInfo");
            }

            cfg.Set("PeerName", PeerName.Text);
            cfg.Set("PeerDescription", PeerDescription.Text);

            cfg = config.Configs["Channels"];
            if (cfg == null)
            {
                cfg = config.AddConfig("Channels");
            }
            cfg.Set("DefaultAddr", TcpInterfaceAddress.SelectedItem);
            cfg.Set("TcpPort", TcpInterfacePort.Text);
            cfg.Set("UdpPort", UDPInterfacePort.Text);
            cfg.Set("TcpEnable", TCPEnable.Checked);
            cfg.Set("UdpEnable", UDPEnable.Checked);

            cfg = config.Configs["RendezVous"];
            if (cfg == null)
            {
                cfg = config.AddConfig("RendezVous");
            }
            string addressStr = "";

            for (int i = 0; i < TCPConnectionsList.Items.Count; i++)
            {
                string addrs = (string)TCPConnectionsList.Items[i];
                addressStr += addrs;
                if (i != TCPConnectionsList.Items.Count - 1)
                {
                    addressStr += "|";
                }
            }
            cfg.Set("ReliableAddrs", addressStr);
            addressStr = "";
            for (int i = 0; i < UDPConnectionsList.Items.Count; i++)
            {
                string addrs = (string)UDPConnectionsList.Items[i];
                addressStr += addrs;
                if (i != UDPConnectionsList.Items.Count - 1)
                {
                    addressStr += "|";
                }
            }
            cfg.Set("BestEffortAddrs", addressStr);

            return(true);
        }
        private void AddScriptingConfig(IConfigSource config, XEngine.XEngine xEngine, List<object> modules)
        {
            IConfig startupConfig = config.AddConfig("Startup");
            startupConfig.Set("DefaultScriptEngine", "XEngine");

            IConfig xEngineConfig = config.AddConfig("XEngine");
            xEngineConfig.Set("Enabled", "true");
            xEngineConfig.Set("StartDelay", "0");

            // These tests will not run with AppDomainLoading = true, at least on mono.  For unknown reasons, the call
            // to AssemblyResolver.OnAssemblyResolve fails.
            xEngineConfig.Set("AppDomainLoading", "false");

            modules.Add(xEngine);
        }
Exemplo n.º 5
0
 static void CreateConfigSections()
 {
     if (source.Configs[ConfigName] == null)
     {
         source.AddConfig(ConfigName);
     }
 }
Exemplo n.º 6
0
        public EditorSettings()
        {
            StringBuilder _dirPath = new StringBuilder(260);

            SHGetSpecialFolderPath(IntPtr.Zero, _dirPath, 0x001A, false);
            string dirPath = _dirPath.ToString();

            dirPath += "\\editor";
            string path = dirPath + "\\settings.ini";

            if (File.Exists(path) == false)
            {
                System.IO.Directory.CreateDirectory(dirPath);
                System.IO.FileStream fs = System.IO.File.Create(path);
                string section          = "[settings]\n";
                for (int i = 0; i < section.Length; i++)
                {
                    fs.WriteByte((byte)section[i]);
                }
                fs.Close();
            }

            try
            {
                m_settingsIni = new IniConfigSource(path);
                if (m_settingsIni.Configs["settings"] == null)
                {
                    m_settingsIni.AddConfig("settings");
                }
            }
            catch (Exception /*e*/)
            {
                MessageBox.Show("Не могу открыть файл " + path, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public void Initialise(Scene scene, IConfigSource source)
        {
            // New region is being created
            // Create a new script engine
            // Make sure we have config
            try
            {
                if (ConfigSource.Configs["SECS"] == null)
                {
                    ConfigSource.AddConfig("SECS");
                }
                ScriptConfigSource = ConfigSource.Configs["SECS"];

                // Is SECS enabled?
                if (ScriptConfigSource.GetBoolean("Enabled", false))
                {
                    LoadEngine();
                    if (scriptEngine != null)
                    {
                        scriptEngine.Initialise(scene, source);
                    }
                }
            }
            catch (NullReferenceException)
            {
            }
        }
Exemplo n.º 8
0
        private void AddCommonConfig(IConfigSource config, List <object> modules)
        {
            config.AddConfig("Modules");
            config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");

            modules.Add(new AttachmentsModule());
            modules.Add(new BasicInventoryAccessModule());
        }
        private void AddScriptingConfig(IConfigSource config, XEngine.XEngine xEngine, List <object> modules)
        {
            IConfig startupConfig = config.AddConfig("Startup");

            startupConfig.Set("DefaultScriptEngine", "XEngine");

            IConfig xEngineConfig = config.AddConfig("XEngine");

            xEngineConfig.Set("Enabled", "true");
            xEngineConfig.Set("StartDelay", "0");

            // These tests will not run with AppDomainLoading = true, at least on mono.  For unknown reasons, the call
            // to AssemblyResolver.OnAssemblyResolve fails.
            xEngineConfig.Set("AppDomainLoading", "false");

            modules.Add(xEngine);
        }
Exemplo n.º 10
0
        public NiniTable GetStorageGroup(string name)
        {
            if (_storage.Configs[name] == null)
            {
                _storage.AddConfig(name);
            }

            return(new NiniTable(this, name));
        }
Exemplo n.º 11
0
        private void WriteNiniConfig(IConfigSource source)
        {
            IConfig config = source.Configs[RegionName];

            if (config != null)
            {
                source.Configs.Remove(config);
            }

            config = source.AddConfig(RegionName);

            config.Set("RegionUUID", RegionID.ToString());

            string location = String.Format("{0},{1}", m_regionLocX, m_regionLocY);

            config.Set("Location", location);

            if (DataStore != String.Empty)
            {
                config.Set("Datastore", DataStore);
            }

            config.Set("InternalAddress", m_internalEndPoint.Address.ToString());
            config.Set("InternalPort", m_internalEndPoint.Port);

            config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());

            config.Set("ExternalHostName", m_externalHostName);

            if (m_nonphysPrimMax != 0)
            {
                config.Set("NonphysicalPrimMax", m_nonphysPrimMax);
            }

            if (m_physPrimMax != 0)
            {
                config.Set("PhysicalPrimMax", m_physPrimMax);
            }

            config.Set("ClampPrimSize", m_clampPrimSize.ToString());

            if (m_objectCapacity != 0)
            {
                config.Set("MaxPrims", m_objectCapacity);
            }

            if (ScopeID != UUID.Zero)
            {
                config.Set("ScopeID", ScopeID.ToString());
            }

            if (RegionType != String.Empty)
            {
                config.Set("RegionType", RegionType);
            }
        }
Exemplo n.º 12
0
        private void AddCommonConfig(IConfigSource config, List<object> modules)
        {
            config.AddConfig("Modules");
            config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");

            AttachmentsModule attMod = new AttachmentsModule();
            attMod.DebugLevel = 1;
            modules.Add(attMod);
            modules.Add(new BasicInventoryAccessModule());
        }
Exemplo n.º 13
0
 /// <summary>
 /// update the node
 /// </summary>
 /// <param name="node">name of node</param>
 public void Update(string node, string filename)
 {
     config = source.Configs[node];
     if (config == null)
     {
         source.AddConfig(node);
         config = source.Configs[node];
     }
     RemoveKeys();
 }
Exemplo n.º 14
0
        //creates a config file in the specified base path
        public Config(string base_path)
        {
            if (!Directory.Exists (base_path))
                Directory.CreateDirectory (base_path);

            string path = System.IO.Path.Combine (base_path, "library_settings.ini");

            if (!File.Exists (path))
                File.WriteAllText (path, "");

            source =  new IniConfigSource (path);

            bool addWindow = true;
            bool addOptions = true;
            bool addColumns = true;
            bool addSorting = true;
            bool addScrobbler = true;

            foreach (IConfig config in source.Configs)
            {
                if (config.Name == "Window")
                    addWindow = false;
                else if (config.Name == "Options")
                    addOptions = false;
                else if (config.Name == "Tree Columns")
                    addColumns = false;
                else if (config.Name == "Sorting")
                    addSorting = false;
                else if (config.Name == "AudioScrobbler")
                    addScrobbler = false;
            }

            if (addWindow)
                source.AddConfig ("Window");
            if (addOptions)
                source.AddConfig ("Options");
            if (addColumns)
                source.AddConfig ("Tree Columns");
            if (addSorting)
                source.AddConfig ("Sorting");
            if (addScrobbler)
                source.AddConfig ("AudioScrobbler");
        }
Exemplo n.º 15
0
 /// <summary>
 /// update the node
 /// </summary>
 /// <param name="node">name of node</param>
 public void Update(string node)
 {
     source = new IniConfigSource(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "user.ini"));
     config = source.Configs[node];
     if (config == null)
     {
         source.AddConfig(node);
         config = source.Configs[node];
     }
     RemoveKeys();
 }
Exemplo n.º 16
0
 /// <summary>
 /// update the node
 /// </summary>
 /// <param name="node">name of node</param>
 public void Update(string node)
 {
     source = new IniConfigSource(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"user.ini"));
     config = source.Configs[node];
     if (config == null)
     {
         source.AddConfig(node);
         config = source.Configs[node];
     }
     RemoveKeys();
 }
Exemplo n.º 17
0
        private void AddScriptingConfig(IConfigSource config, List <object> modules)
        {
            IConfig startupConfig = config.AddConfig("Startup");

            startupConfig.Set("DefaultScriptEngine", "XEngine");

            IConfig xEngineConfig = config.AddConfig("XEngine");

            xEngineConfig.Set("Enabled", "true");
            xEngineConfig.Set("StartDelay", "0");

            // These tests will not run with AppDomainLoading = true, at least on mono.  For unknown reasons, the call
            // to AssemblyResolver.OnAssemblyResolve fails.
            xEngineConfig.Set("AppDomainLoading", "false");

            modules.Add(new XEngine());

            // Necessary to stop serialization complaining
            // FIXME: Stop this being necessary if at all possible
//            modules.Add(new WorldCommModule());
        }
Exemplo n.º 18
0
Arquivo: Editor.cs Projeto: psla/nini
        /// <summary>
        /// Adds a new config.
        /// </summary>
        private void AddConfig()
        {
            IConfigSource source = LoadSource(configPath);

            source.AddConfig(GetArg("add"));

            source.Save();

            if (verbose)
            {
                PrintLine("Config was added: " + GetArg("add"));
            }
        }
Exemplo n.º 19
0
        public void CreateIConfig(IConfigSource source)
        {
            IConfig config = source.Configs[RegionName];

            if (config != null)
            {
                source.Configs.Remove(config);
            }

            config = source.AddConfig(RegionName);

            config.Set("RegionUUID", RegionID.ToString());

            string location = String.Format("{0},{1}", m_regionLocX / 256, m_regionLocY / 256);

            config.Set("Location", location);

            config.Set("InternalAddress", m_internalEndPoint.Address.ToString());
            config.Set("InternalPort", m_internalEndPoint.Port);

            config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());

            config.Set("ExternalHostName", m_externalHostName);

            if (m_objectCapacity != 0)
            {
                config.Set("MaxPrims", m_objectCapacity);
            }

            if (ScopeID != UUID.Zero)
            {
                config.Set("ScopeID", ScopeID.ToString());
            }

            if (RegionType != String.Empty)
            {
                config.Set("RegionType", RegionType);
            }

            config.Set("AllowPhysicalPrims", AllowPhysicalPrims);
            config.Set("AllowScriptCrossing", AllowScriptCrossing);
            config.Set("TrustBinariesFromForeignSims", TrustBinariesFromForeignSims);
            config.Set("SeeIntoThisSimFromNeighbor", SeeIntoThisSimFromNeighbor);
            config.Set("RegionSizeX", RegionSizeX);
            config.Set("RegionSizeY", RegionSizeY);
            config.Set("RegionSizeZ", RegionSizeZ);

            config.Set("StartupType", Startup.ToString());

            config.Set("NeighborPassword", Password.ToString());
        }
Exemplo n.º 20
0
        public void Save(Irc irc)
        {
            IConfig             server  = null;;
            string              host    = irc.Host;
            string              nick    = irc.Nick;
            string              user    = irc.Username;
            string              real    = irc.Realname;
            int                 port    = irc.Port;
            string              owner   = irc.Owner;
            string              nspass  = irc.NickPass;
            string              srvpass = irc.ServerPass;
            Stack <ChannelData> buffer  = irc.ChannelBuffer;

            if (!string.IsNullOrEmpty(nspass))
            {
                nspass = new SymCryptography(SymCryptography.ServiceProviderEnum.Rijndael).Encrypt(nspass);
            }

            // Last known code
            RFC1459.ReplyCode lkc    = irc.Code;
            ConsoleColor      colour = irc.Colour;

            if (config.Configs[irc.Server] == null)
            {
                server = config.AddConfig(irc.Server);
            }
            else
            {
                server = config.Configs[irc.Server];
            }

            server.Set("Host", host);
            server.Set("Port", port);
            server.Set("Nick", nick);
            server.Set("Server_Password", srvpass);
            server.Set("Username", user);
            server.Set("Realname", real);
            server.Set("NickPassword", nspass);
            server.Set("Owner", owner);
            server.Set("LastKnownCode", ( int )lkc);
            server.Set("Colour", ( int )colour);
            server.Set("MainChannel", "{nokey}");
            server.Set("MainKey", "{nokey}");

            if (buffer.Count > 0)
            {
                server.Set("Channels", string.Join(",", buffer.ToArray( )));
            }

            config.Save( );
        }
Exemplo n.º 21
0
        public void AddRegion(Scene Sceneworld)
        {
            m_log.Info("[" + ScriptEngineName + "]: ScriptEngine initializing");

            m_Scene = Sceneworld;

            // Make sure we have config
            if (ConfigSource.Configs[ScriptEngineName] == null)
            {
                ConfigSource.AddConfig(ScriptEngineName);
            }

            ScriptConfigSource = ConfigSource.Configs[ScriptEngineName];

            m_enabled = ScriptConfigSource.GetBoolean("Enabled", true);
            if (!m_enabled)
            {
                return;
            }

            // Create all objects we'll be using
            m_EventQueueManager = new EventQueueManager(this);
            m_EventManager      = new EventManager(this, true);

            // We need to start it
            m_ScriptManager = new ScriptManager(this);
            m_ScriptManager.Setup();
            m_AppDomainManager = new AppDomainManager(this);
            if (m_MaintenanceThread == null)
            {
                m_MaintenanceThread = new MaintenanceThread();
            }

            m_log.Info("[" + ScriptEngineName + "]: Reading configuration " +
                       "from config section \"" + ScriptEngineName + "\"");

            ReadConfig();

            m_Scene.StackModuleInterface <IScriptModule>(this);
        }
Exemplo n.º 22
0
        private void ReadNiniConfig(IConfigSource source, string name)
        {
//            bool creatingNew = false;

            if (source.Configs.Count == 0)
            {
                MainConsole.Instance.Output("=====================================\n");
                MainConsole.Instance.Output("We are now going to ask a couple of questions about your region.\n");
                MainConsole.Instance.Output("You can press 'enter' without typing anything to use the default\n");
                MainConsole.Instance.Output("the default is displayed between [ ] brackets.\n");
                MainConsole.Instance.Output("=====================================\n");

                if (name == String.Empty)
                    name = MainConsole.Instance.CmdPrompt("New region name", name);
                if (name == String.Empty)
                    throw new Exception("Cannot interactively create region with no name");

                source.AddConfig(name);

//                creatingNew = true;
            }

            if (name == String.Empty)
                name = source.Configs[0].Name;

            if (source.Configs[name] == null)
            {
                source.AddConfig(name);

//                creatingNew = true;
            }

            IConfig config = source.Configs[name];

            // UUID
            //
            string regionUUID = config.GetString("RegionUUID", string.Empty);

            if (regionUUID == String.Empty)
            {
                UUID newID = UUID.Random();

                regionUUID = MainConsole.Instance.CmdPrompt("Region UUID", newID.ToString());
                config.Set("RegionUUID", regionUUID);
            }

            RegionID = new UUID(regionUUID);
            originRegionID = RegionID; // What IS this?!

            RegionName = name;
            string location = config.GetString("Location", String.Empty);

            if (location == String.Empty)
            {
                location = MainConsole.Instance.CmdPrompt("Region Location", "1000,1000");
                config.Set("Location", location);
            }

            string[] locationElements = location.Split(new char[] {','});

            m_regionLocX = Convert.ToUInt32(locationElements[0]);
            m_regionLocY = Convert.ToUInt32(locationElements[1]);

            // Internal IP
            IPAddress address;

            if (config.Contains("InternalAddress"))
            {
                address = IPAddress.Parse(config.GetString("InternalAddress", String.Empty));
            }
            else
            {
                address = IPAddress.Parse(MainConsole.Instance.CmdPrompt("Internal IP address", "0.0.0.0"));
                config.Set("InternalAddress", address.ToString());
            }

            int port;

            if (config.Contains("InternalPort"))
            {
                port = config.GetInt("InternalPort", 9000);
            }
            else
            {
                port = Convert.ToInt32(MainConsole.Instance.CmdPrompt("Internal port", "9000"));
                config.Set("InternalPort", port);
            }

            m_internalEndPoint = new IPEndPoint(address, port);

            if (config.Contains("AllowAlternatePorts"))
            {
                m_allow_alternate_ports = config.GetBoolean("AllowAlternatePorts", true);
            }
            else
            {
                m_allow_alternate_ports = Convert.ToBoolean(MainConsole.Instance.CmdPrompt("Allow alternate ports", "False"));

                config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());
            }

            // External IP
            //
            string externalName;

            if (config.Contains("ExternalHostName"))
            {
                externalName = config.GetString("ExternalHostName", "SYSTEMIP");
            }
            else
            {
                externalName = MainConsole.Instance.CmdPrompt("External host name", "SYSTEMIP");
                config.Set("ExternalHostName", externalName);
            }

            if (externalName == "SYSTEMIP")
            {
                m_externalHostName = Util.GetLocalHost().ToString();
                m_log.InfoFormat(
                    "[REGIONINFO]: Resolving SYSTEMIP to {0} for external hostname of region {1}",
                    m_externalHostName, name);
            }
            else
            {
                m_externalHostName = externalName;
            }

            m_regionType = config.GetString("RegionType", String.Empty);

            // Prim stuff
            //
            m_nonphysPrimMax = config.GetInt("NonphysicalPrimMax", 256);

            m_physPrimMax = config.GetInt("PhysicalPrimMax", 10);

            m_clampPrimSize = config.GetBoolean("ClampPrimSize", false);

            m_objectCapacity = config.GetInt("MaxPrims", 15000);

            m_agentCapacity = config.GetInt("MaxAgents", 100);


            // Multi-tenancy
            //
            ScopeID = new UUID(config.GetString("ScopeID", UUID.Zero.ToString()));
        }
        //Returns true if the source should be updated. Returns false if it does not.
        public bool ReadNiniConfig(RegionInfo region, IConfigSource source, string name)
        {
            //            bool creatingNew = false;

            if (name == String.Empty || source.Configs.Count == 0)
            {
                MainConsole.Instance.Output("=====================================\n");
                MainConsole.Instance.Output("We are now going to ask a couple of questions about your region.\n");
                MainConsole.Instance.Output("You can press 'enter' without typing anything to use the default\n");
                MainConsole.Instance.Output("the default is displayed between [ ] brackets.\n");
                MainConsole.Instance.Output("=====================================\n");
            }

            bool NeedsUpdate = false;
            if (name == String.Empty)
                name = MainConsole.Instance.CmdPrompt("New region name", name);
            if (name == String.Empty)
                throw new Exception("Cannot interactively create region with no name");

            if (source.Configs.Count == 0)
            {
                source.AddConfig(name);

                //                creatingNew = true;
                NeedsUpdate = true;
            }

            if (source.Configs[name] == null)
            {
                source.AddConfig(name);
                NeedsUpdate = true;
                //                creatingNew = true;
            }

            IConfig config = source.Configs[name];

            // UUID
            //
            string regionUUID = config.GetString("RegionUUID", string.Empty);

            if (regionUUID == String.Empty)
            {
                NeedsUpdate = true;
                UUID newID = UUID.Random();

                regionUUID = MainConsole.Instance.CmdPrompt("Region UUID for region " + name, newID.ToString());
                config.Set("RegionUUID", regionUUID);
            }

            region.RegionID = new UUID(regionUUID);

            region.RegionName = name;
            string location = config.GetString("Location", String.Empty);

            if (location == String.Empty)
            {
                NeedsUpdate = true;
                location = MainConsole.Instance.CmdPrompt("Region Location for region " + name, "1000,1000");
                config.Set("Location", location);
            }

            string[] locationElements = location.Split(new char[] { ',' });

            region.RegionLocX = Convert.ToInt32(locationElements[0]) * Constants.RegionSize;
            region.RegionLocY = Convert.ToInt32(locationElements[1]) * Constants.RegionSize;

            int regionSizeX = config.GetInt("RegionSizeX", 0);
            if (regionSizeX == 0 || ((region.RegionSizeX % Constants.MinRegionSize) != 0))
            {
                NeedsUpdate = true;
                while (true)
                {
                    if (int.TryParse(MainConsole.Instance.CmdPrompt("Region X Size for region " + name, "256"), out regionSizeX))
                        break;
                }
                config.Set("RegionSizeX", regionSizeX);
            }
            region.RegionSizeX = Convert.ToInt32(regionSizeX);

            int regionSizeY = config.GetInt("RegionSizeY", 0);
            if (regionSizeY == 0 || ((region.RegionSizeY % Constants.MinRegionSize) != 0))
            {
                NeedsUpdate = true;
                while(true)
                {
                    if(int.TryParse(MainConsole.Instance.CmdPrompt("Region Y Size for region " + name, "256"), out regionSizeY))
                        break;
                }
                config.Set("RegionSizeY", regionSizeY);
            }
            region.RegionSizeY = regionSizeY;

            int regionSizeZ = config.GetInt("RegionSizeZ", 1024);
            //if (regionSizeZ == String.Empty)
            //{
            //    NeedsUpdate = true;
            //    regionSizeZ = MainConsole.Instance.CmdPrompt("Region Z Size for region " + name, "1024");
            //    config.Set("RegionSizeZ", regionSizeZ);
            //}
            region.RegionSizeZ = regionSizeZ;

            // Internal IP
            IPAddress address;

            if (config.Contains("InternalAddress"))
            {
                address = IPAddress.Parse(config.GetString("InternalAddress", String.Empty));
            }
            else
            {
                NeedsUpdate = true;
                address = IPAddress.Parse(MainConsole.Instance.CmdPrompt("Internal IP address for region " + name, "0.0.0.0"));
                config.Set("InternalAddress", address.ToString());
            }

            int port;

            if (config.Contains("InternalPort"))
            {
                port = config.GetInt("InternalPort", 9000);
            }
            else
            {
                NeedsUpdate = true;
                port = Convert.ToInt32(MainConsole.Instance.CmdPrompt("Internal port for region " + name, "9000"));
                config.Set("InternalPort", port);
            }

            region.InternalEndPoint = new IPEndPoint(address, port);

            if (config.Contains("AllowAlternatePorts"))
            {
                region.m_allow_alternate_ports = config.GetBoolean("AllowAlternatePorts", true);
            }
            else
            {
                NeedsUpdate = true;
                region.m_allow_alternate_ports = Convert.ToBoolean(MainConsole.Instance.CmdPrompt("Allow alternate ports", "False"));

                config.Set("AllowAlternatePorts", region.m_allow_alternate_ports.ToString());
            }

            // External IP
            //
            string externalName;
            //Let's know our external IP (by Enrico Nirvana)
            WebClient client = new WebClient();
            string myIP = client.DownloadString("http://www.whatismyip.com/automation/n09230945.asp");
            MainConsole.Instance.Output("Your External ip is:" + myIP);
            //ended here (by Enrico Nirvana)
            if (config.Contains("ExternalHostName"))
            {
                externalName = config.GetString("ExternalHostName", "SYSTEMIP");
            }
            else
            {
                NeedsUpdate = true;
                externalName = MainConsole.Instance.CmdPrompt("External host name for region " + name, "SYSTEMIP");
                config.Set("ExternalHostName", externalName);
            }

            if (externalName == "SYSTEMIP")
            {
                region.ExternalHostName = Util.GetLocalHost().ToString();
                m_log.InfoFormat(
                    "[REGIONINFO]: Resolving SYSTEMIP to {0} for external hostname of region {1}",
                    region.ExternalHostName, name);
            }
            else
            {
                region.ExternalHostName = Util.ResolveEndPoint(externalName, port).Address.ToString();
            }

            region.RegionType = config.GetString("RegionType", region.RegionType);

            if (region.RegionType == String.Empty)
            {
                NeedsUpdate = true;
                region.RegionType = MainConsole.Instance.CmdPrompt("Region Type for region " + name, "Mainland");
                config.Set("RegionType", region.RegionType);
            }

            region.AllowPhysicalPrims = config.GetBoolean("AllowPhysicalPrims", region.AllowPhysicalPrims);

            region.AllowScriptCrossing = config.GetBoolean("AllowScriptCrossing", region.AllowScriptCrossing);

            region.TrustBinariesFromForeignSims = config.GetBoolean("TrustBinariesFromForeignSims", region.TrustBinariesFromForeignSims);

            region.SeeIntoThisSimFromNeighbor = config.GetBoolean("SeeIntoThisSimFromNeighbor", region.SeeIntoThisSimFromNeighbor);

            region.ObjectCapacity = config.GetInt("MaxPrims", region.ObjectCapacity);


            // Multi-tenancy
            //
            region.ScopeID = new UUID(config.GetString("ScopeID", region.ScopeID.ToString()));

            //Do this last so that we can save the password immediately if it doesn't exist
            UUID password = region.Password; //Save the pass as this TryParse will wipe it out
            if (!UUID.TryParse(config.GetString("NeighborPassword", ""), out region.Password))
            {
                region.Password = password;
                config.Set("NeighborPassword", password);
                region.WriteNiniConfig(source);
            }

            return NeedsUpdate;
        }
Exemplo n.º 24
0
        private void WriteNiniConfig(IConfigSource source)
        {
            IConfig config = source.Configs[RegionName];

            if (config != null)
            {
                source.Configs.Remove(config);
            }

            config = source.AddConfig(RegionName);

            config.Set("RegionUUID", RegionID.ToString());

            string location = String.Format("{0},{1}", RegionLocX, RegionLocY);

            config.Set("Location", location);

            if (RegionSizeX != Constants.RegionSize || RegionSizeY != Constants.RegionSize)
            {
                config.Set("SizeX", RegionSizeX);
                config.Set("SizeY", RegionSizeY);
//                config.Set("SizeZ", RegionSizeZ);
            }

            config.Set("InternalAddress", m_internalEndPoint.Address.ToString());
            config.Set("InternalPort", m_internalEndPoint.Port);

            config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());

            config.Set("ExternalHostName", m_externalHostName);

            if (m_nonphysPrimMin > 0)
            {
                config.Set("NonphysicalPrimMax", m_nonphysPrimMin);
            }

            if (m_nonphysPrimMax > 0)
            {
                config.Set("NonphysicalPrimMax", m_nonphysPrimMax);
            }

            if (m_physPrimMin > 0)
            {
                config.Set("PhysicalPrimMax", m_physPrimMin);
            }

            if (m_physPrimMax > 0)
            {
                config.Set("PhysicalPrimMax", m_physPrimMax);
            }

            config.Set("ClampPrimSize", m_clampPrimSize.ToString());

            if (m_objectCapacity > 0)
            {
                config.Set("MaxPrims", m_objectCapacity);
            }

            if (m_maxPrimsPerUser > -1)
            {
                config.Set("MaxPrimsPerUser", m_maxPrimsPerUser);
            }

            if (m_linksetCapacity > 0)
            {
                config.Set("LinksetPrims", m_linksetCapacity);
            }

            if (AgentCapacity > 0)
            {
                config.Set("MaxAgents", AgentCapacity);
            }

            if (ScopeID != UUID.Zero)
            {
                config.Set("ScopeID", ScopeID.ToString());
            }

            if (RegionType != String.Empty)
            {
                config.Set("RegionType", RegionType);
            }

            if (m_maptileStaticUUID != UUID.Zero)
            {
                config.Set("MaptileStaticUUID", m_maptileStaticUUID.ToString());
            }

            if (MaptileStaticFile != String.Empty)
            {
                config.Set("MaptileStaticFile", MaptileStaticFile);
            }
        }
Exemplo n.º 25
0
        private void ReadNiniConfig(IConfigSource source, string name)
        {
//            bool creatingNew = false;

            if (source.Configs.Count == 0)
            {
                MainConsole.Instance.Output("=====================================\n");
                MainConsole.Instance.Output("We are now going to ask a couple of questions about your region.\n");
                MainConsole.Instance.Output("You can press 'enter' without typing anything to use the default\n");
                MainConsole.Instance.Output("the default is displayed between [ ] brackets.\n");
                MainConsole.Instance.Output("=====================================\n");

                if (name == String.Empty)
                {
                    while (name.Trim() == string.Empty)
                    {
                        name = MainConsole.Instance.CmdPrompt("New region name", name);
                        if (name.Trim() == string.Empty)
                        {
                            MainConsole.Instance.Output("Cannot interactively create region with no name");
                        }
                    }
                }

                source.AddConfig(name);

//                creatingNew = true;
            }

            if (name == String.Empty)
            {
                name = source.Configs[0].Name;
            }

            if (source.Configs[name] == null)
            {
                source.AddConfig(name);
            }

            RegionName = name;
            IConfig config = source.Configs[name];

            // Track all of the keys in this config and remove as they are processed
            // The remaining keys will be added to generic key-value storage for
            // whoever might need it
            HashSet <String> allKeys = new HashSet <String>();

            foreach (string s in config.GetKeys())
            {
                allKeys.Add(s);
            }

            // RegionUUID
            //
            allKeys.Remove("RegionUUID");
            string regionUUID = config.GetString("RegionUUID", string.Empty);

            if (!UUID.TryParse(regionUUID.Trim(), out RegionID))
            {
                UUID newID = UUID.Random();
                while (RegionID == UUID.Zero)
                {
                    regionUUID = MainConsole.Instance.CmdPrompt("RegionUUID", newID.ToString());
                    if (!UUID.TryParse(regionUUID.Trim(), out RegionID))
                    {
                        MainConsole.Instance.Output("RegionUUID must be a valid UUID");
                    }
                }
                config.Set("RegionUUID", regionUUID);
            }

            originRegionID = RegionID; // What IS this?! (Needed for RegionCombinerModule?)

            // Location
            //
            allKeys.Remove("Location");
            string location = config.GetString("Location", String.Empty);

            if (location == String.Empty)
            {
                location = MainConsole.Instance.CmdPrompt("Region Location", "1000,1000");
                config.Set("Location", location);
            }

            string[] locationElements = location.Split(new char[] { ',' });

            RegionLocX = Convert.ToUInt32(locationElements[0]);
            RegionLocY = Convert.ToUInt32(locationElements[1]);

            // Region size
            // Default to legacy region size if not specified.
            allKeys.Remove("SizeX");
            string configSizeX = config.GetString("SizeX", Constants.RegionSize.ToString());

            config.Set("SizeX", configSizeX);
            RegionSizeX = Convert.ToUInt32(configSizeX);
            allKeys.Remove("SizeY");
            string configSizeY = config.GetString("SizeY", Constants.RegionSize.ToString());

            config.Set("SizeY", configSizeX);
            RegionSizeY = Convert.ToUInt32(configSizeY);
            allKeys.Remove("SizeZ");
            string configSizeZ = config.GetString("SizeZ", Constants.RegionHeight.ToString());

            config.Set("SizeZ", configSizeX);
            RegionSizeZ = Convert.ToUInt32(configSizeZ);

            DoRegionSizeSanityChecks();

            // InternalAddress
            //
            IPAddress address;

            allKeys.Remove("InternalAddress");
            if (config.Contains("InternalAddress"))
            {
                address = IPAddress.Parse(config.GetString("InternalAddress", String.Empty));
            }
            else
            {
                address = IPAddress.Parse(MainConsole.Instance.CmdPrompt("Internal IP address", "0.0.0.0"));
                config.Set("InternalAddress", address.ToString());
            }

            // InternalPort
            //
            int port;

            allKeys.Remove("InternalPort");
            if (config.Contains("InternalPort"))
            {
                port = config.GetInt("InternalPort", 9000);
            }
            else
            {
                port = Convert.ToInt32(MainConsole.Instance.CmdPrompt("Internal port", "9000"));
                config.Set("InternalPort", port);
            }
            m_internalEndPoint = new IPEndPoint(address, port);

            // AllowAlternatePorts
            //
            allKeys.Remove("AllowAlternatePorts");
            if (config.Contains("AllowAlternatePorts"))
            {
                m_allow_alternate_ports = config.GetBoolean("AllowAlternatePorts", true);
            }
            else
            {
                m_allow_alternate_ports = Convert.ToBoolean(MainConsole.Instance.CmdPrompt("Allow alternate ports", "False"));

                config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());
            }

            // ExternalHostName
            //
            allKeys.Remove("ExternalHostName");
            string externalName;

            if (config.Contains("ExternalHostName"))
            {
                externalName = config.GetString("ExternalHostName", "SYSTEMIP");
            }
            else
            {
                externalName = MainConsole.Instance.CmdPrompt("External host name", "SYSTEMIP");
                config.Set("ExternalHostName", externalName);
            }
            if (externalName == "SYSTEMIP")
            {
                m_externalHostName = Util.GetLocalHost().ToString();
                m_log.InfoFormat(
                    "[REGIONINFO]: Resolving SYSTEMIP to {0} for external hostname of region {1}",
                    m_externalHostName, name);
            }
            else
            {
                m_externalHostName = externalName;
            }

            // RegionType
            m_regionType = config.GetString("RegionType", String.Empty);
            allKeys.Remove("RegionType");

            #region Prim and map stuff

            m_nonphysPrimMin = config.GetFloat("NonPhysicalPrimMin", 0);
            allKeys.Remove("NonPhysicalPrimMin");

            m_nonphysPrimMax = config.GetInt("NonPhysicalPrimMax", 0);
            allKeys.Remove("NonPhysicalPrimMax");

            m_physPrimMin = config.GetFloat("PhysicalPrimMin", 0);
            allKeys.Remove("PhysicalPrimMin");

            m_physPrimMax = config.GetInt("PhysicalPrimMax", 0);
            allKeys.Remove("PhysicalPrimMax");

            m_clampPrimSize = config.GetBoolean("ClampPrimSize", false);
            allKeys.Remove("ClampPrimSize");

            m_objectCapacity = config.GetInt("MaxPrims", 15000);
            allKeys.Remove("MaxPrims");

            m_maxPrimsPerUser = config.GetInt("MaxPrimsPerUser", -1);
            allKeys.Remove("MaxPrimsPerUser");

            m_linksetCapacity = config.GetInt("LinksetPrims", 0);
            allKeys.Remove("LinksetPrims");

            allKeys.Remove("MaptileStaticUUID");
            string mapTileStaticUUID = config.GetString("MaptileStaticUUID", UUID.Zero.ToString());
            if (UUID.TryParse(mapTileStaticUUID.Trim(), out m_maptileStaticUUID))
            {
                config.Set("MaptileStaticUUID", m_maptileStaticUUID.ToString());
            }

            MaptileStaticFile = config.GetString("MaptileStaticFile", String.Empty);
            allKeys.Remove("MaptileStaticFile");

            #endregion

            AgentCapacity = config.GetInt("MaxAgents", 100);
            allKeys.Remove("MaxAgents");

            // Multi-tenancy
            //
            ScopeID = new UUID(config.GetString("ScopeID", UUID.Zero.ToString()));
            allKeys.Remove("ScopeID");

            foreach (String s in allKeys)
            {
                SetExtraSetting(s, config.GetString(s));
            }
        }
Exemplo n.º 26
0
        private void ReadNiniConfig(IConfigSource source, string name)
        {
//            bool creatingNew = false;

            if (source.Configs.Count == 0)
            {
                MainConsole.Instance.Output("=====================================\n");
                MainConsole.Instance.Output("We are now going to ask a couple of questions about your region.\n");
                MainConsole.Instance.Output("You can press 'enter' without typing anything to use the default\n");
                MainConsole.Instance.Output("the default is displayed between [ ] brackets.\n");
                MainConsole.Instance.Output("=====================================\n");

                if (name == String.Empty)
                {
                    while (name.Trim() == string.Empty)
                    {
                        name = MainConsole.Instance.CmdPrompt("New region name", name);
                        if (name.Trim() == string.Empty)
                        {
                            MainConsole.Instance.Output("Cannot interactively create region with no name");
                        }
                    }
                }

                source.AddConfig(name);

//                creatingNew = true;
            }

            if (name == String.Empty)
                name = source.Configs[0].Name;

            if (source.Configs[name] == null)
            {
                source.AddConfig(name);
            }

            RegionName = name;
            IConfig config = source.Configs[name];

            // Track all of the keys in this config and remove as they are processed
            // The remaining keys will be added to generic key-value storage for
            // whoever might need it
            HashSet<String> allKeys = new HashSet<String>();
            foreach (string s in config.GetKeys())
            {
                allKeys.Add(s);
            }

            // RegionUUID
            //
            allKeys.Remove("RegionUUID");
            string regionUUID = config.GetString("RegionUUID", string.Empty);
            if (!UUID.TryParse(regionUUID.Trim(), out RegionID))
            {
                UUID newID = UUID.Random();
                while (RegionID == UUID.Zero)
                {
                    regionUUID = MainConsole.Instance.CmdPrompt("RegionUUID", newID.ToString());
                    if (!UUID.TryParse(regionUUID.Trim(), out RegionID))
                    {
                        MainConsole.Instance.Output("RegionUUID must be a valid UUID");
                    }
                }
                config.Set("RegionUUID", regionUUID);
            }

            originRegionID = RegionID; // What IS this?! (Needed for RegionCombinerModule?)

            // Location
            //
            allKeys.Remove("Location");
            string location = config.GetString("Location", String.Empty);
            if (location == String.Empty)
            {
                location = MainConsole.Instance.CmdPrompt("Region Location", "1000,1000");
                config.Set("Location", location);
            }

            string[] locationElements = location.Split(new char[] {','});

            RegionLocX = Convert.ToUInt32(locationElements[0]);
            RegionLocY = Convert.ToUInt32(locationElements[1]);

            // Region size
            // Default to legacy region size if not specified.
            allKeys.Remove("SizeX");
            string configSizeX = config.GetString("SizeX", Constants.RegionSize.ToString());
            config.Set("SizeX", configSizeX);
            RegionSizeX = Convert.ToUInt32(configSizeX);
            allKeys.Remove("SizeY");
            string configSizeY = config.GetString("SizeY", Constants.RegionSize.ToString());
            config.Set("SizeY", configSizeX);
            RegionSizeY = Convert.ToUInt32(configSizeY);
            allKeys.Remove("SizeZ");
            string configSizeZ = config.GetString("SizeZ", Constants.RegionHeight.ToString());
            config.Set("SizeZ", configSizeX);
            RegionSizeZ = Convert.ToUInt32(configSizeZ);

            DoRegionSizeSanityChecks();

            // InternalAddress
            //
            IPAddress address;
            allKeys.Remove("InternalAddress");
            if (config.Contains("InternalAddress"))
            {
                address = IPAddress.Parse(config.GetString("InternalAddress", String.Empty));
            }
            else
            {
                address = IPAddress.Parse(MainConsole.Instance.CmdPrompt("Internal IP address", "0.0.0.0"));
                config.Set("InternalAddress", address.ToString());
            }

            // InternalPort
            //
            int port;
            allKeys.Remove("InternalPort");
            if (config.Contains("InternalPort"))
            {
                port = config.GetInt("InternalPort", 9000);
            }
            else
            {
                port = Convert.ToInt32(MainConsole.Instance.CmdPrompt("Internal port", "9000"));
                config.Set("InternalPort", port);
            }
            m_internalEndPoint = new IPEndPoint(address, port);

            // AllowAlternatePorts
            //
            allKeys.Remove("AllowAlternatePorts");
            if (config.Contains("AllowAlternatePorts"))
            {
                m_allow_alternate_ports = config.GetBoolean("AllowAlternatePorts", true);
            }
            else
            {
                m_allow_alternate_ports = Convert.ToBoolean(MainConsole.Instance.CmdPrompt("Allow alternate ports", "False"));

                config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());
            }

            // ExternalHostName
            //
            allKeys.Remove("ExternalHostName");
            string externalName;
            if (config.Contains("ExternalHostName"))
            {
                externalName = config.GetString("ExternalHostName", "SYSTEMIP");
            }
            else
            {
                externalName = MainConsole.Instance.CmdPrompt("External host name", "SYSTEMIP");
                config.Set("ExternalHostName", externalName);
            }
            if (externalName == "SYSTEMIP")
            {
                m_externalHostName = Util.GetLocalHost().ToString();
                m_log.InfoFormat(
                    "[REGIONINFO]: Resolving SYSTEMIP to {0} for external hostname of region {1}",
                    m_externalHostName, name);
            }
            else
            {
                m_externalHostName = externalName;
            }

            // RegionType
            m_regionType = config.GetString("RegionType", String.Empty);
            allKeys.Remove("RegionType");

            #region Prim and map stuff

            m_nonphysPrimMin = config.GetFloat("NonPhysicalPrimMin", 0);
            allKeys.Remove("NonPhysicalPrimMin");

            m_nonphysPrimMax = config.GetInt("NonPhysicalPrimMax", 0);
            allKeys.Remove("NonPhysicalPrimMax");

            m_physPrimMin = config.GetFloat("PhysicalPrimMin", 0);
            allKeys.Remove("PhysicalPrimMin");

            m_physPrimMax = config.GetInt("PhysicalPrimMax", 0);
            allKeys.Remove("PhysicalPrimMax");
            
            m_clampPrimSize = config.GetBoolean("ClampPrimSize", false);
            allKeys.Remove("ClampPrimSize");
            
            m_objectCapacity = config.GetInt("MaxPrims", 15000);
            allKeys.Remove("MaxPrims");

            m_linksetCapacity = config.GetInt("LinksetPrims", 0);
            allKeys.Remove("LinksetPrims");

            allKeys.Remove("MaptileStaticUUID");
            string mapTileStaticUUID = config.GetString("MaptileStaticUUID", UUID.Zero.ToString());
            if (UUID.TryParse(mapTileStaticUUID.Trim(), out m_maptileStaticUUID))
            {
                config.Set("MaptileStaticUUID", m_maptileStaticUUID.ToString()); 
            }
            
            #endregion

            m_agentCapacity = config.GetInt("MaxAgents", 100);
            allKeys.Remove("MaxAgents");

            // Multi-tenancy
            //
            ScopeID = new UUID(config.GetString("ScopeID", UUID.Zero.ToString()));
            allKeys.Remove("ScopeID");

            foreach (String s in allKeys)
            {
                SetOtherSetting(s, config.GetString(s));
            }
        }
Exemplo n.º 27
0
        private void ReadNiniConfig(IConfigSource source, string name)
        {
            bool creatingNew = false;

            if (source.Configs.Count == 0)
            {
                if (name == String.Empty)
                {
                    name = MainConsole.Instance.CmdPrompt("New region name", name);
                }
                if (name == String.Empty)
                {
                    throw new Exception("Cannot interactively create region with no name");
                }

                IConfig newRegion = source.AddConfig(name);

                creatingNew = true;
            }

            if (name == String.Empty)
            {
                name = source.Configs[0].Name;
            }

            if (source.Configs[name] == null)
            {
                IConfig newRegion = source.AddConfig(name);

                creatingNew = true;
            }

            IConfig config = source.Configs[name];

            // UUID
            //
            string regionUUID = config.GetString("RegionUUID", string.Empty);

            if (regionUUID == String.Empty)
            {
                UUID newID = UUID.Random();

                regionUUID = MainConsole.Instance.CmdPrompt("Region UUID", newID.ToString());
                config.Set("RegionUUID", regionUUID);
            }

            RegionID       = new UUID(regionUUID);
            originRegionID = RegionID; // What IS this?!


            // Region name
            //
            RegionName = name;


            // Region location
            //
            string location = config.GetString("Location", String.Empty);

            if (location == String.Empty)
            {
                location = MainConsole.Instance.CmdPrompt("Region Location", "1000,1000");
                config.Set("Location", location);
            }

            string[] locationElements = location.Split(new char[] { ',' });

            m_regionLocX = Convert.ToUInt32(locationElements[0]);
            m_regionLocY = Convert.ToUInt32(locationElements[1]);


            // Datastore (is this implemented? Omitted from example!)
            //
            DataStore = config.GetString("Datastore", String.Empty);


            // Internal IP
            //
            IPAddress address;

            if (config.Contains("InternalAddress"))
            {
                address = IPAddress.Parse(config.GetString("InternalAddress", String.Empty));
            }
            else
            {
                address = IPAddress.Parse(MainConsole.Instance.CmdPrompt("Internal IP address", "127.0.0.1"));
                config.Set("InternalAddress", address.ToString());
            }

            int port;

            if (config.Contains("InternalPort"))
            {
                port = config.GetInt("InternalPort", 9000);
            }
            else
            {
                port = Convert.ToInt32(MainConsole.Instance.CmdPrompt("Internal port", "9000"));
                config.Set("InternalPort", port);
            }

            m_internalEndPoint = new IPEndPoint(address, port);

            if (config.Contains("AllowAlternatePorts"))
            {
                m_allow_alternate_ports = config.GetBoolean("AllowAlternatePorts", true);
            }
            else
            {
                m_allow_alternate_ports = Convert.ToBoolean(MainConsole.Instance.CmdPrompt("Allow alternate ports", "False"));

                config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());
            }

            // External IP
            //
            string externalName;

            if (config.Contains("ExternalHostName"))
            {
                externalName = config.GetString("ExternalHostName", "SYSTEMIP");
            }
            else
            {
                externalName = MainConsole.Instance.CmdPrompt("External host name", "SYSTEMIP");
                config.Set("ExternalHostName", externalName);
            }

            if (externalName == "SYSTEMIP")
            {
                m_externalHostName = Util.GetLocalHost().ToString();
            }
            else
            {
                m_externalHostName = externalName;
            }


            // Master avatar cruft
            //
            string masterAvatarUUID;

            if (!creatingNew)
            {
                masterAvatarUUID            = config.GetString("MasterAvatarUUID", UUID.Zero.ToString());
                MasterAvatarFirstName       = config.GetString("MasterAvatarFirstName", String.Empty);
                MasterAvatarLastName        = config.GetString("MasterAvatarLastName", String.Empty);
                MasterAvatarSandboxPassword = config.GetString("MasterAvatarSandboxPassword", String.Empty);
            }
            else
            {
                masterAvatarUUID = MainConsole.Instance.CmdPrompt("Master Avatar UUID", UUID.Zero.ToString());
                if (masterAvatarUUID != UUID.Zero.ToString())
                {
                    config.Set("MasterAvatarUUID", masterAvatarUUID);
                }
                else
                {
                    MasterAvatarFirstName = MainConsole.Instance.CmdPrompt("Master Avatar first name (enter for no master avatar)", String.Empty);
                    if (MasterAvatarFirstName != String.Empty)
                    {
                        MasterAvatarLastName        = MainConsole.Instance.CmdPrompt("Master Avatar last name", String.Empty);
                        MasterAvatarSandboxPassword = MainConsole.Instance.CmdPrompt("Master Avatar sandbox password", String.Empty);

                        config.Set("MasterAvatarFirstName", MasterAvatarFirstName);
                        config.Set("MasterAvatarLastName", MasterAvatarLastName);
                        config.Set("MasterAvatarSandboxPassword", MasterAvatarSandboxPassword);
                    }
                }
            }

            MasterAvatarAssignedUUID = new UUID(masterAvatarUUID);



            // Prim stuff
            //
            m_nonphysPrimMax = config.GetInt("NonphysicalPrimMax", 256);

            m_physPrimMax = config.GetInt("PhysicalPrimMax", 10);

            m_clampPrimSize = config.GetBoolean("ClampPrimSize", false);

            m_objectCapacity = config.GetInt("MaxPrims", 15000);


            // Multi-tenancy
            //
            ScopeID = new UUID(config.GetString("ScopeID", UUID.Zero.ToString()));
        }
Exemplo n.º 28
0
        public frmMain()
        {
            #if (DEBUG_1||DEBUG_2||DEBUG_3)
            debugLogger = new DebugLogger("frmMain.log");
            #endif
            debugLogger.WriteDebug_3("Begin Method: frmMain.frmMain()");

            InitializeComponent();

            Directory.SetCurrentDirectory(Directory.GetParent(Application.ExecutablePath).FullName);
            debugLogger.WriteDebug_2("Set Current Directory to " + Directory.GetParent(Application.ExecutablePath).FullName);

            // TODO: Determine why this is a double nested try/catch to load some INI settings
            try
            {
                inifile = new IniConfigSource(Directory.GetCurrentDirectory() + "\\settings.ini");
                DBString = inifile.Configs["Files"].GetString("dbfile","");
                LogFile = inifile.Configs["Files"].GetString("logfile","");
                OutputDirectory = inifile.Configs["Files"].GetString("outdir","");
                DKPTax = inifile.Configs["Other"].GetDouble("tax",0.0);
                MinDKP = inifile.Configs["Other"].GetDouble("mindkp", 0);
                TierAPct = inifile.Configs["Other"].GetDouble("tierapct", 0.6);
                TierBPct = inifile.Configs["Other"].GetDouble("tierbpct", 0.3);
                TierCPct = inifile.Configs["Other"].GetDouble("tiercpct", 0.0);
                GuildNames = inifile.Configs["Other"].GetString("GuildNames", "Eternal Sovereign");
                debugLogger.WriteDebug_1("Read settings from INI: DBFile=" + DBString + ", LogFile=" + LogFile + ", OutputDirectory="
                    + OutputDirectory + ", DKPTax=" + DKPTax + ", GuildNames=" + GuildNames);

                StatusMessage ="Read settings from INI...";
                try
                {
                    parser = new LogParser(this,LogFile);
                    debugLogger.WriteDebug_3("Created log parser");
                }
                catch (Exception ex) {
                    debugLogger.WriteDebug_1("Failed to create log parser: " + ex.Message);
                }
            }
            catch (FileNotFoundException ex)
            {
                debugLogger.WriteDebug_3("settings.ini not found, creating");

                FileStream a = File.Create(Directory.GetCurrentDirectory() + "\\settings.ini");
                a.Close();
                sbpMessage.Text = "settings.ini not found... Loading defaults";
                try
                {
                    inifile = new IniConfigSource(Directory.GetCurrentDirectory() + "\\settings.ini");
                    inifile.AddConfig("Files");
                    inifile.AddConfig("Other");
                    LogFile = inifile.Configs["Files"].GetString("logfile","");
                    DBString = inifile.Configs["Files"].GetString("dbfile","");
                    OutputDirectory = inifile.Configs["Files"].GetString("outdir","");
                    DKPTax = inifile.Configs["Other"].GetDouble("tax",0.0);
                    MinDKP = inifile.Configs["Other"].GetDouble("mindkp", 0);
                    TierAPct = inifile.Configs["Other"].GetDouble("tierapct", 0.6);
                    TierBPct = inifile.Configs["Other"].GetDouble("tierbpct", 0.3);
                    TierCPct = inifile.Configs["Other"].GetDouble("tiercpct", 0.0);
                    GuildNames = inifile.Configs["Other"].GetString("GuildNames", "Eternal Sovereign");
                    inifile.Save();
                    debugLogger.WriteDebug_1("Read settings from INI: dbFile=" + DBString + ", logFile=" + LogFile
                        + ", outDir=" + OutputDirectory + ", tax=" + DKPTax + ", mindkp=" + MinDKP + ", GuildNames=" + GuildNames);
                }
                catch (Exception exc)
                {
                    debugLogger.WriteDebug_1("Failed to create new settings.ini: " + exc.Message);
                    MessageBox.Show("Error opening settings.ini","Error");
                    Environment.Exit(1);
                }
            }
            catch (Exception ex)
            {
                debugLogger.WriteDebug_1("Failed to load settings.ini: " + ex.Message);
                MessageBox.Show("Error opening settings.ini","Error");
                Environment.Exit(1);
            }
            UITimer = new Timer();
            UITimer.Interval = 100;
            UITimer.Tick += new EventHandler(UITimer_Tick);
            UITimer.Start();

            debugLogger.WriteDebug_3("End Method: frmMain.frmMain()");
        }
Exemplo n.º 29
0
        private void WriteNiniConfig(IConfigSource source)
        {
            IConfig config = source.Configs[RegionName];

            if (config != null)
                source.Configs.Remove(RegionName);

            config = source.AddConfig(RegionName);

            config.Set("RegionUUID", RegionID.ToString());

            string location = String.Format("{0},{1}", m_regionLocX, m_regionLocY);
            config.Set("Location", location);

            if (DataStore != String.Empty)
                config.Set("Datastore", DataStore);

            config.Set("InternalAddress", m_internalEndPoint.Address.ToString());
            config.Set("InternalPort", m_internalEndPoint.Port);

            config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());

            config.Set("ExternalHostName", m_externalHostName);

            if (MasterAvatarAssignedUUID != UUID.Zero)
            {
                config.Set("MasterAvatarUUID", MasterAvatarAssignedUUID.ToString());
            }
            else if (MasterAvatarFirstName != String.Empty && MasterAvatarLastName != String.Empty)
            {
                config.Set("MasterAvatarFirstName", MasterAvatarFirstName);
                config.Set("MasterAvatarLastName", MasterAvatarLastName);
            }
            if (MasterAvatarSandboxPassword != String.Empty)
            {
                config.Set("MasterAvatarSandboxPassword", MasterAvatarSandboxPassword);
            }

            if (m_nonphysPrimMax != 0)
                config.Set("NonphysicalPrimMax", m_nonphysPrimMax);
            if (m_physPrimMax != 0)
                config.Set("PhysicalPrimMax", m_physPrimMax);
            config.Set("ClampPrimSize", m_clampPrimSize.ToString());

            if (m_objectCapacity != 0)
                config.Set("MaxPrims", m_objectCapacity);

            if (ScopeID != UUID.Zero)
                config.Set("ScopeID", ScopeID.ToString());

            if (RegionType != String.Empty)
                config.Set("RegionType", RegionType);
        }
Exemplo n.º 30
0
        private void ReadNiniConfig(IConfigSource source, string name)
        {
//            bool creatingNew = false;

            if (source.Configs.Count == 0)
            {
                MainConsole.Instance.Output("=====================================\n");
                MainConsole.Instance.Output("We are now going to ask a couple of questions about your region.\n");
                MainConsole.Instance.Output("You can press 'enter' without typing anything to use the default\n");
                MainConsole.Instance.Output("the default is displayed between [ ] brackets.\n");
                MainConsole.Instance.Output("=====================================\n");

                if (name == String.Empty)
                {
                    name = MainConsole.Instance.CmdPrompt("New region name", name);
                }
                if (name == String.Empty)
                {
                    throw new Exception("Cannot interactively create region with no name");
                }

                source.AddConfig(name);

//                creatingNew = true;
            }

            if (name == String.Empty)
            {
                name = source.Configs[0].Name;
            }

            if (source.Configs[name] == null)
            {
                source.AddConfig(name);

//                creatingNew = true;
            }

            IConfig config = source.Configs[name];

            // UUID
            //
            string regionUUID = config.GetString("RegionUUID", string.Empty);

            if (regionUUID == String.Empty)
            {
                UUID newID = UUID.Random();

                regionUUID = MainConsole.Instance.CmdPrompt("Region UUID", newID.ToString());
                config.Set("RegionUUID", regionUUID);
            }

            RegionID       = new UUID(regionUUID);
            originRegionID = RegionID; // What IS this?!

            RegionName = name;
            string location = config.GetString("Location", String.Empty);

            if (location == String.Empty)
            {
                location = MainConsole.Instance.CmdPrompt("Region Location", "1000,1000");
                config.Set("Location", location);
            }

            string[] locationElements = location.Split(new char[] { ',' });

            m_regionLocX = Convert.ToUInt32(locationElements[0]);
            m_regionLocY = Convert.ToUInt32(locationElements[1]);


            // Datastore (is this implemented? Omitted from example!)
            DataStore = config.GetString("Datastore", String.Empty);

            // Internal IP
            IPAddress address;

            if (config.Contains("InternalAddress"))
            {
                address = IPAddress.Parse(config.GetString("InternalAddress", String.Empty));
            }
            else
            {
                address = IPAddress.Parse(MainConsole.Instance.CmdPrompt("Internal IP address", "0.0.0.0"));
                config.Set("InternalAddress", address.ToString());
            }

            int port;

            if (config.Contains("InternalPort"))
            {
                port = config.GetInt("InternalPort", 9000);
            }
            else
            {
                port = Convert.ToInt32(MainConsole.Instance.CmdPrompt("Internal port", "9000"));
                config.Set("InternalPort", port);
            }

            m_internalEndPoint = new IPEndPoint(address, port);

            if (config.Contains("AllowAlternatePorts"))
            {
                m_allow_alternate_ports = config.GetBoolean("AllowAlternatePorts", true);
            }
            else
            {
                m_allow_alternate_ports = Convert.ToBoolean(MainConsole.Instance.CmdPrompt("Allow alternate ports", "False"));

                config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());
            }

            // External IP
            //
            string externalName;

            if (config.Contains("ExternalHostName"))
            {
                externalName = config.GetString("ExternalHostName", "SYSTEMIP");
            }
            else
            {
                externalName = MainConsole.Instance.CmdPrompt("External host name", "SYSTEMIP");
                config.Set("ExternalHostName", externalName);
            }

            if (externalName == "SYSTEMIP")
            {
                m_externalHostName = Util.GetLocalHost().ToString();
                m_log.InfoFormat(
                    "[REGIONINFO]: Resolving SYSTEMIP to {0} for external hostname of region {1}",
                    m_externalHostName, name);
            }
            else
            {
                m_externalHostName = externalName;
            }

            m_regionType = config.GetString("RegionType", String.Empty);

            // Prim stuff
            //
            m_nonphysPrimMax = config.GetInt("NonphysicalPrimMax", 256);

            m_physPrimMax = config.GetInt("PhysicalPrimMax", 10);

            m_clampPrimSize = config.GetBoolean("ClampPrimSize", false);

            m_objectCapacity = config.GetInt("MaxPrims", 15000);


            // Multi-tenancy
            //
            ScopeID = new UUID(config.GetString("ScopeID", UUID.Zero.ToString()));
        }
Exemplo n.º 31
0
		public FormMain()
		{
			// Set the resize event handler.
			resizeEventHandler = new EventHandler(FormMain_Resize);
			Resize += resizeEventHandler;

			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			// Get the window handle.
			Capture = true;
			hwnd = OpenNETCF.Win32.Win32Window.GetCapture();
			Capture = false;

			// Add a message filter.
			ApplicationEx.AddMessageFilter(this);

			// Load the configuration.
			executablePath = ApplicationEx.StartupPath;
			extensionPath = Path.Combine(executablePath, "Extensions");
			string iniFileName = Path.Combine(executablePath, "GPSProxy.ini");
			if (! File.Exists(iniFileName))
			{
				try
				{
					File.Copy(Path.Combine(executablePath, "GPSProxy.ini.default"), iniFileName, false);
				}
				catch
				{
				}
			}
			if (! File.Exists(iniFileName))
				using (File.Create(iniFileName))
				{
				}
			configSource = new IniConfigSource(iniFileName);
			configSource.Alias.AddAlias("On", true);
			configSource.Alias.AddAlias("Off", false);
			configSource.Alias.AddAlias("True", true);
			configSource.Alias.AddAlias("False", false);
			if (configSource.Configs["Settings"] == null)
				configSource.AddConfig("Settings");

			configSettings = configSource.Configs["Settings"];
			settings["autoStart"].Value = configSettings.GetBoolean("Start Proxy Automatically on Launch", (bool)settings["autoStart"].Value);
			settings["runExternalApp"].Value = configSettings.GetBoolean("Run External App after Proxy Startup", (bool)settings["runExternalApp"].Value);
			settings["externalApp"].Value = configSettings.GetString("External Application", (string)settings["externalApp"].Value);
			settings["autoReconnect"].Value = configSettings.GetBoolean("Reconnect after Power-on", (bool)settings["autoReconnect"].Value);
			settings["reconnectDelay"].Value = configSettings.GetInt("Power-on Reconnect Delay", (int)settings["reconnectDelay"].Value);

			// Create the main and page menu panels.
			mainMenuPanel = new ScrollablePanel();
			mainMenuPanel.Visible = false;
			Controls.Add(mainMenuPanel);
			mainMenuPanel.Size = pluginPanel.ClientSize;
			mainMenuPanel.BringToFront();

			pageMenuPanel = new ScrollablePanel();
			pageMenuPanel.Visible = false;
			Controls.Add(pageMenuPanel);
			pageMenuPanel.Size = pluginPanel.ClientSize;
			pageMenuPanel.BringToFront();

			// Add the main menu buttons.
			AboutButton = AddMenuButton(mainMenuPanel, "About...",
				new EventHandler(AboutButton_Click));
			SettingsButton = AddMenuButton(mainMenuPanel, "Settings...",
				new EventHandler(SettingsButton_Click), true);
			ExtensionsButton = AddMenuButton(mainMenuPanel, "Extensions...",
				new EventHandler(ExtensionsButton_Click));
			VirtualComPortsButton = AddMenuButton(mainMenuPanel, "Virtual COM Ports...",
				new EventHandler(VirtualComPortsButton_Click));
			ExitButton = AddMenuButton(mainMenuPanel, "Exit",
				new EventHandler(ExitButton_Click), true);

			// Load the extension DLLs.
			LoadExtensions();

			// Activate extensions according to the configuration file.
			ActivateExtensions();

			// NOTE: do not attempt to show an message boxes before this point, as this triggers
			// other form events that expect the activeExtensions array to have been created.

			// Load the virtual COM port drivers.
			virtualComPortRootKey = Registry.LocalMachine.CreateSubKey(@"Drivers\GPSProxyVirtualCOMPorts");
			if (virtualComPortRootKey == null)
			{
				MessageBox.Show(@"Unable to open/create registry key: " + virtualComPortRootKey.Name,
					"Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
			}
			else
			{
				LoadVirtualComPortDrivers();
			}

			// Create and populate the extensions dialog.
			extensionsDialog = new FormExtensions();
			extensionsDialog.ComboBoxProvider.SelectedIndexChanged += new EventHandler(ComboBoxProvider_SelectedIndexChanged);
			extensionsDialog.ListBoxExtensions.SelectedIndexChanged += new EventHandler(ListBoxExtensions_SelectedIndexChanged);
			extensionsDialog.ButtonConfigureProvider.Click += new EventHandler(ButtonConfigureProvider_Click);
			extensionsDialog.ButtonAddExtension.Click += new EventHandler(ButtonAddExtension_Click);
			extensionsDialog.ButtonRemoveExtension.Click += new EventHandler(ButtonRemoveExtension_Click);
			extensionsDialog.ButtonConfigureExtension.Click += new EventHandler(ButtonConfigureExtension_Click);
			RepopulateExtensionsDialog();

			// Create and populate the virtual COM port dialog.
			virtualComPortsDialog = new FormVirtualComPorts();
			virtualComPortsDialog.VirtualComPortListBox.SelectedIndexChanged += new EventHandler(VirtualComPortListBox_SelectedIndexChanged);
			virtualComPortsDialog.ButtonAdd.Click += new EventHandler(ButtonAddVirtualComPort_Click);
			virtualComPortsDialog.ButtonRemove.Click += new EventHandler(ButtonRemoveVirtualComPort_Click);
			RepopulateVirtualComPortsDialog();
		}
Exemplo n.º 32
0
        //Returns true if the source should be updated. Returns false if it does not.
        private bool ReadNiniConfig(IConfigSource source, string name)
        {
//            bool creatingNew = false;

            if (name == String.Empty || source.Configs.Count == 0)
            {
                MainConsole.Instance.Output("=====================================\n");
                MainConsole.Instance.Output("We are now going to ask a couple of questions about your region.\n");
                MainConsole.Instance.Output("You can press 'enter' without typing anything to use the default\n");
                MainConsole.Instance.Output("the default is displayed between [ ] brackets.\n");
                MainConsole.Instance.Output("=====================================\n");
            }

            bool NeedsUpdate = false;
            if (name == String.Empty)
                name = MainConsole.Instance.CmdPrompt("New region name", name);
            if (name == String.Empty)
                throw new Exception("Cannot interactively create region with no name");

            if (source.Configs.Count == 0)
            {
                source.AddConfig(name);

//                creatingNew = true;
                NeedsUpdate = true;
            }

            if (source.Configs[name] == null)
            {
                source.AddConfig(name);
                NeedsUpdate = true;
//                creatingNew = true;
            }

            IConfig config = source.Configs[name];

            // UUID
            //
            string regionUUID = config.GetString("RegionUUID", string.Empty);

            if (regionUUID == String.Empty)
            {
                NeedsUpdate = true;
                UUID newID = UUID.Random();

                regionUUID = MainConsole.Instance.CmdPrompt("Region UUID", newID.ToString());
                config.Set("RegionUUID", regionUUID);
            }

            RegionID = new UUID(regionUUID);
            
            RegionName = name;
            string location = config.GetString("Location", String.Empty);

            if (location == String.Empty)
            {
                NeedsUpdate = true;
                location = MainConsole.Instance.CmdPrompt("Region Location", "1000,1000");
                config.Set("Location", location);
            }

            string[] locationElements = location.Split(new char[] {','});

            m_regionLocX = Convert.ToUInt32(locationElements[0]);
            m_regionLocY = Convert.ToUInt32(locationElements[1]);

            // Internal IP
            IPAddress address;

            if (config.Contains("InternalAddress"))
            {
                address = IPAddress.Parse(config.GetString("InternalAddress", String.Empty));
            }
            else
            {
                NeedsUpdate = true;
                address = IPAddress.Parse(MainConsole.Instance.CmdPrompt("Internal IP address", "0.0.0.0"));
                config.Set("InternalAddress", address.ToString());
            }

            int port;

            if (config.Contains("InternalPort"))
            {
                port = config.GetInt("InternalPort", 9000);
            }
            else
            {
                NeedsUpdate = true;
                port = Convert.ToInt32(MainConsole.Instance.CmdPrompt("Internal port", "9000"));
                config.Set("InternalPort", port);
            }

            m_internalEndPoint = new IPEndPoint(address, port);

            if (config.Contains("AllowAlternatePorts"))
            {
                m_allow_alternate_ports = config.GetBoolean("AllowAlternatePorts", true);
            }
            else
            {
                NeedsUpdate = true;
                m_allow_alternate_ports = Convert.ToBoolean(MainConsole.Instance.CmdPrompt("Allow alternate ports", "False"));

                config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());
            }

            // External IP
            //
            string externalName;

            if (config.Contains("ExternalHostName"))
            {
                externalName = config.GetString("ExternalHostName", "SYSTEMIP");
            }
            else
            {
                NeedsUpdate = true;
                externalName = MainConsole.Instance.CmdPrompt("External host name", "SYSTEMIP");
                config.Set("ExternalHostName", externalName);
            }

            if (externalName == "SYSTEMIP")
            {
                m_externalHostName = Util.GetLocalHost().ToString();
                m_log.InfoFormat(
                    "[REGIONINFO]: Resolving SYSTEMIP to {0} for external hostname of region {1}",
                    m_externalHostName, name);
            }
            else
            {
                m_externalHostName = externalName;
            }

            m_regionType = config.GetString("RegionType", String.Empty);
            GridSecureSessionID = UUID.Parse(config.GetString("GridSessionID", GridSecureSessionID.ToString()));
            EstateSettings.EstatePass = config.GetString("EstatePass", "");

            if (m_regionType == String.Empty)
            {
                NeedsUpdate = true;
                m_regionType = MainConsole.Instance.CmdPrompt("Region Type", "Mainland");
                config.Set("RegionType", m_regionType);
            }

            m_allowPhysicalPrims = config.GetBoolean("AllowPhysicalPrims", m_allowPhysicalPrims);

            m_allowScriptCrossing = config.GetBoolean("AllowScriptCrossing", m_allowScriptCrossing);

            m_trustBinariesFromForeignSims = config.GetBoolean("TrustBinariesFromForeignSims", m_trustBinariesFromForeignSims);

            m_seeIntoThisSimFromNeighbor = config.GetBoolean("SeeIntoThisSimFromNeighbor", m_seeIntoThisSimFromNeighbor);

            m_objectCapacity = config.GetInt("MaxPrims", m_objectCapacity);


            // Multi-tenancy
            //
            ScopeID = new UUID(config.GetString("ScopeID", ScopeID.ToString()));
            return NeedsUpdate;
        }
Exemplo n.º 33
0
 public void AddSection(string sectionName)
 {
     source.AddConfig(sectionName);
     source.Save();
     source.Reload();
 }
Exemplo n.º 34
0
        private void WriteNiniConfig(IConfigSource source)
        {
            IConfig config = source.Configs[RegionName];

            if (config != null)
                source.Configs.Remove(config);

            config = source.AddConfig(RegionName);

            config.Set("RegionUUID", RegionID.ToString());

            string location = String.Format("{0},{1}", m_regionLocX, m_regionLocY);
            config.Set("Location", location);

            config.Set("InternalAddress", m_internalEndPoint.Address.ToString());
            config.Set("InternalPort", m_internalEndPoint.Port);

            config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());

            config.Set("ExternalHostName", m_externalHostName);

            if (m_nonphysPrimMax != 0)
                config.Set("NonphysicalPrimMax", m_nonphysPrimMax);
            if (m_physPrimMax != 0)
                config.Set("PhysicalPrimMax", m_physPrimMax);
            config.Set("ClampPrimSize", m_clampPrimSize.ToString());

            if (m_objectCapacity != 0)
                config.Set("MaxPrims", m_objectCapacity);

            if (m_agentCapacity != 0)
                config.Set("MaxAgents", m_agentCapacity);

            if (ScopeID != UUID.Zero)
                config.Set("ScopeID", ScopeID.ToString());

            if (RegionType != String.Empty)
                config.Set("RegionType", RegionType);
        }
Exemplo n.º 35
0
        public void CreateIConfig(IConfigSource source)
        {
            IConfig config = source.Configs[RegionName];

            if (config != null)
                source.Configs.Remove(config);

            config = source.AddConfig(RegionName);

            config.Set("RegionUUID", RegionID.ToString());

            string location = String.Format("{0},{1}", m_regionLocX / 256, m_regionLocY / 256);
            config.Set("Location", location);

            config.Set("InternalAddress", m_internalEndPoint.Address.ToString());
            config.Set("InternalPort", m_internalEndPoint.Port);

            config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());

            config.Set("ExternalHostName", m_externalHostName);

            if (m_objectCapacity != 0)
                config.Set("MaxPrims", m_objectCapacity);

            if (ScopeID != UUID.Zero)
                config.Set("ScopeID", ScopeID.ToString());

            if (RegionType != String.Empty)
                config.Set("RegionType", RegionType);

            config.Set("AllowPhysicalPrims", AllowPhysicalPrims);
            config.Set("AllowScriptCrossing", AllowScriptCrossing);
            config.Set("TrustBinariesFromForeignSims", TrustBinariesFromForeignSims);
            config.Set("SeeIntoThisSimFromNeighbor", SeeIntoThisSimFromNeighbor);
            config.Set("RegionSizeX", RegionSizeX);
            config.Set ("RegionSizeY", RegionSizeY);
            config.Set ("RegionSizeZ", RegionSizeZ);

            config.Set ("StartupType", Startup.ToString());

            config.Set("NeighborPassword", Password.ToString());
        }
Exemplo n.º 36
0
        //Returns true if the source should be updated. Returns false if it does not.
        public bool ReadNiniConfig(RegionInfo region, IConfigSource source, string name)
        {
            //            bool creatingNew = false;

            if (name == String.Empty || source.Configs.Count == 0)
            {
                MainConsole.Instance.Info("=====================================\n");
                MainConsole.Instance.Info("We are now going to ask a couple of questions about your region.\n");
                MainConsole.Instance.Info("You can press 'enter' without typing anything to use the default\n");
                MainConsole.Instance.Info("the default is displayed between [ ] brackets.\n");
                MainConsole.Instance.Info("=====================================\n");
            }

            bool NeedsUpdate = false;

            if (name == String.Empty)
            {
                name = MainConsole.Instance.Prompt("New region name", name);
            }
            if (name == String.Empty)
            {
                throw new Exception("Cannot interactively create region with no name");
            }

            if (source.Configs.Count == 0)
            {
                source.AddConfig(name);

                //                creatingNew = true;
                NeedsUpdate = true;
            }

            if (source.Configs[name] == null)
            {
                source.AddConfig(name);
                NeedsUpdate = true;
                //                creatingNew = true;
            }

            IConfig config = source.Configs[name];

            // UUID
            //
            string regionUUID = config.GetString("RegionUUID", string.Empty);

            if (regionUUID == String.Empty)
            {
                NeedsUpdate = true;
                UUID newID = UUID.Random();

                regionUUID = MainConsole.Instance.Prompt("Region UUID for region " + name, newID.ToString());
                config.Set("RegionUUID", regionUUID);
            }

            region.RegionID = new UUID(regionUUID);

            region.RegionName = name;
            string location = config.GetString("Location", String.Empty);

            if (location == String.Empty)
            {
                NeedsUpdate = true;
                location    = MainConsole.Instance.Prompt("Region Location for region " + name, "1000,1000");
                config.Set("Location", location);
            }

            string[] locationElements = location.Split(new[] { ',' });

            region.RegionLocX = Convert.ToInt32(locationElements[0]) * Constants.RegionSize;
            region.RegionLocY = Convert.ToInt32(locationElements[1]) * Constants.RegionSize;

            int regionSizeX = config.GetInt("RegionSizeX", 0);

            if (regionSizeX == 0 || ((region.RegionSizeX % Constants.MinRegionSize) != 0))
            {
                NeedsUpdate = true;
                while (true)
                {
                    if (int.TryParse(MainConsole.Instance.Prompt("Region X Size for region " + name, "256"), out regionSizeX))
                    {
                        break;
                    }
                }
                config.Set("RegionSizeX", regionSizeX);
            }
            region.RegionSizeX = Convert.ToInt32(regionSizeX);

            int regionSizeY = config.GetInt("RegionSizeY", 0);

            if (regionSizeY == 0 || ((region.RegionSizeY % Constants.MinRegionSize) != 0))
            {
                NeedsUpdate = true;
                while (true)
                {
                    if (int.TryParse(MainConsole.Instance.Prompt("Region Y Size for region " + name, "256"), out regionSizeY))
                    {
                        break;
                    }
                }
                config.Set("RegionSizeY", regionSizeY);
            }
            region.RegionSizeY = regionSizeY;

            int regionSizeZ = config.GetInt("RegionSizeZ", 1024);

            //if (regionSizeZ == String.Empty)
            //{
            //    NeedsUpdate = true;
            //    regionSizeZ = MainConsole.Instance.CmdPrompt("Region Z Size for region " + name, "1024");
            //    config.Set("RegionSizeZ", regionSizeZ);
            //}
            region.RegionSizeZ = regionSizeZ;

            // Internal IP
            IPAddress address;

            if (config.Contains("InternalAddress"))
            {
                address = IPAddress.Parse(config.GetString("InternalAddress", String.Empty));
            }
            else
            {
                NeedsUpdate = true;
                address     = IPAddress.Parse(MainConsole.Instance.Prompt("Internal IP address for region " + name, "0.0.0.0"));
                config.Set("InternalAddress", address.ToString());
            }

            int port;

            if (config.Contains("InternalPort"))
            {
                port = config.GetInt("InternalPort", 9000);
            }
            else
            {
                NeedsUpdate = true;
                port        = Convert.ToInt32(MainConsole.Instance.Prompt("Internal port for region " + name, "9000"));
                config.Set("InternalPort", port);
            }
            region.UDPPorts.Add(port);
            region.InternalEndPoint = new IPEndPoint(address, port);

            // External IP
            //
            string externalName;

            if (config.Contains("ExternalHostName"))
            {
                //Let's know our external IP (by Enrico Nirvana)
                externalName = config.GetString("ExternalHostName", Aurora.Framework.Utilities.GetExternalIp());
            }
            else
            {
                NeedsUpdate = true;
                //Let's know our external IP (by Enrico Nirvana)
                externalName = MainConsole.Instance.Prompt("External host name for region " + name, Aurora.Framework.Utilities.GetExternalIp());
                config.Set("ExternalHostName", externalName);
                //ended here (by Enrico Nirvana)
            }

            region.RegionType = config.GetString("RegionType", region.RegionType);

            if (region.RegionType == String.Empty)
            {
                NeedsUpdate       = true;
                region.RegionType = MainConsole.Instance.Prompt("Region Type for region " + name, "Mainland");
                config.Set("RegionType", region.RegionType);
            }

            region.AllowPhysicalPrims = config.GetBoolean("AllowPhysicalPrims", region.AllowPhysicalPrims);

            region.AllowScriptCrossing = config.GetBoolean("AllowScriptCrossing", region.AllowScriptCrossing);

            region.TrustBinariesFromForeignSims = config.GetBoolean("TrustBinariesFromForeignSims", region.TrustBinariesFromForeignSims);

            region.SeeIntoThisSimFromNeighbor = config.GetBoolean("SeeIntoThisSimFromNeighbor", region.SeeIntoThisSimFromNeighbor);

            region.ObjectCapacity = config.GetInt("MaxPrims", region.ObjectCapacity);

            region.Startup = (StartupType)Enum.Parse(typeof(StartupType), config.GetString("StartupType", region.Startup.ToString()));


            // Multi-tenancy
            //
            region.ScopeID = new UUID(config.GetString("ScopeID", region.ScopeID.ToString()));

            //Do this last so that we can save the password immediately if it doesn't exist
            UUID password = region.Password; //Save the pass as this TryParse will wipe it out

            if (!UUID.TryParse(config.GetString("NeighborPassword", ""), out region.Password))
            {
                region.Password = password;
                config.Set("NeighborPassword", password);
                region.WriteNiniConfig(source);
            }

            return(NeedsUpdate);
        }
Exemplo n.º 37
0
        private void AddScriptingConfig(IConfigSource config, List<object> modules)
        {
            IConfig startupConfig = config.AddConfig("Startup");
            startupConfig.Set("DefaultScriptEngine", "XEngine");

            IConfig xEngineConfig = config.AddConfig("XEngine");
            xEngineConfig.Set("Enabled", "true");
            xEngineConfig.Set("StartDelay", "0");

            // These tests will not run with AppDomainLoading = true, at least on mono.  For unknown reasons, the call
            // to AssemblyResolver.OnAssemblyResolve fails.
            xEngineConfig.Set("AppDomainLoading", "false");

            modules.Add(new XEngine());

            // Necessary to stop serialization complaining
            // FIXME: Stop this being necessary if at all possible
//            modules.Add(new WorldCommModule());
        }
Exemplo n.º 38
0
        private void ReadNiniConfig(IConfigSource source, string name)
        {
            bool creatingNew = false;

            if (source.Configs.Count == 0)
            {
                MainConsole.Instance.Output("=====================================\n");
                MainConsole.Instance.Output("We are now going to ask a couple of questions about your region.\n");
                MainConsole.Instance.Output("You can press 'enter' without typing anything to use the default\n");
                MainConsole.Instance.Output("the default is displayed between [ ] brackets.\n");
                MainConsole.Instance.Output("=====================================\n");

                if (name == String.Empty)
                    name = MainConsole.Instance.CmdPrompt("New region name", name);
                if (name == String.Empty)
                    throw new Exception("Cannot interactively create region with no name");

                source.AddConfig(name);

                creatingNew = true;
            }

            if (name == String.Empty)
                name = source.Configs[0].Name;

            if (source.Configs[name] == null)
            {
                source.AddConfig(name);

                creatingNew = true;
            }

            IConfig config = source.Configs[name];

            // UUID
            //
            string regionUUID = config.GetString("RegionUUID", string.Empty);

            if (regionUUID == String.Empty)
            {
                UUID newID = UUID.Random();

                regionUUID = MainConsole.Instance.CmdPrompt("Region UUID", newID.ToString());
                config.Set("RegionUUID", regionUUID);
            }

            RegionID = new UUID(regionUUID);
            originRegionID = RegionID; // What IS this?!

            
            // Region name
            //
            RegionName = name;

            
            // Region location
            //
            string location = config.GetString("Location", String.Empty);

            if (location == String.Empty)
            {
                location = MainConsole.Instance.CmdPrompt("Region Location", "1000,1000");
                config.Set("Location", location);
            }

            string[] locationElements = location.Split(new char[] {','});

            m_regionLocX = Convert.ToUInt32(locationElements[0]);
            m_regionLocY = Convert.ToUInt32(locationElements[1]);


            // Datastore (is this implemented? Omitted from example!)
            //
            DataStore = config.GetString("Datastore", String.Empty);


            // Internal IP
            //
            IPAddress address;
            
            if (config.Contains("InternalAddress"))
            {
                address = IPAddress.Parse(config.GetString("InternalAddress", String.Empty));
            }
            else
            {
                address = IPAddress.Parse(MainConsole.Instance.CmdPrompt("Internal IP address", "0.0.0.0"));
                config.Set("InternalAddress", address.ToString());
            }

            int port;

            if (config.Contains("InternalPort"))
            {
                port = config.GetInt("InternalPort", 9000);
            }
            else
            {
                port = Convert.ToInt32(MainConsole.Instance.CmdPrompt("Internal port", "9000"));
                config.Set("InternalPort", port);
            }

            m_internalEndPoint = new IPEndPoint(address, port);

            if (config.Contains("AllowAlternatePorts"))
            {
                m_allow_alternate_ports = config.GetBoolean("AllowAlternatePorts", true);
            }
            else
            {
                m_allow_alternate_ports = Convert.ToBoolean(MainConsole.Instance.CmdPrompt("Allow alternate ports", "False"));

                config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());
            }

            // External IP
            //
            string externalName;

            if (config.Contains("ExternalHostName"))
            {
                externalName = config.GetString("ExternalHostName", "SYSTEMIP");
            }
            else
            {
                externalName = MainConsole.Instance.CmdPrompt("External host name", "SYSTEMIP");
                config.Set("ExternalHostName", externalName);
            }

            if (externalName == "SYSTEMIP")
                m_externalHostName = Util.GetLocalHost().ToString();
            else
                m_externalHostName = externalName;


            // Master avatar cruft
            //
            string masterAvatarUUID;
            if (!creatingNew)
            {
                masterAvatarUUID = config.GetString("MasterAvatarUUID", UUID.Zero.ToString());
                MasterAvatarFirstName = config.GetString("MasterAvatarFirstName", String.Empty);
                MasterAvatarLastName = config.GetString("MasterAvatarLastName", String.Empty);
                MasterAvatarSandboxPassword = config.GetString("MasterAvatarSandboxPassword", String.Empty);
            }
            else
            {
                masterAvatarUUID = MainConsole.Instance.CmdPrompt("Master Avatar UUID", UUID.Zero.ToString());
                if (masterAvatarUUID != UUID.Zero.ToString())
                {
                    config.Set("MasterAvatarUUID", masterAvatarUUID);
                }
                else
                {
                    MasterAvatarFirstName = MainConsole.Instance.CmdPrompt("Master Avatar first name (enter for no master avatar)", String.Empty);
                    if (MasterAvatarFirstName != String.Empty)
                    {
                        MasterAvatarLastName = MainConsole.Instance.CmdPrompt("Master Avatar last name", String.Empty);
                        MasterAvatarSandboxPassword = MainConsole.Instance.CmdPrompt("Master Avatar sandbox password", String.Empty);
                        
                        config.Set("MasterAvatarFirstName", MasterAvatarFirstName);
                        config.Set("MasterAvatarLastName", MasterAvatarLastName);
                        config.Set("MasterAvatarSandboxPassword", MasterAvatarSandboxPassword);
                    }
                }
            }

            MasterAvatarAssignedUUID = new UUID(masterAvatarUUID);

            m_regionType = config.GetString("RegionType", String.Empty);

            // Prim stuff
            //
            m_nonphysPrimMax = config.GetInt("NonphysicalPrimMax", 256);

            m_physPrimMax = config.GetInt("PhysicalPrimMax", 10);

            m_clampPrimSize = config.GetBoolean("ClampPrimSize", false);

            m_objectCapacity = config.GetInt("MaxPrims", 15000);


            // Multi-tenancy
            //
            ScopeID = new UUID(config.GetString("ScopeID", UUID.Zero.ToString()));
        }