public string CheckExternalHostName() { if (!m_CheckDynDns && !String.IsNullOrEmpty(m_lastExternalHostName)) { /* no recheck */ } else if (m_externalHostName == "SYSTEMIP") { if (DateTime.UtcNow - m_lastResolverTime > TimeSpan.FromMinutes(1)) { string newIP = Util.GetLocalHost().ToString(); lock (this) { if (newIP != m_lastExternalHostName && m_lastExternalHostName != string.Empty) { m_IPChanged = true; } if (newIP != m_lastExternalHostName || m_lastExternalHostName == string.Empty) { m_log.InfoFormat( "[REGIONINFO]: Resolving SYSTEMIP to {0} for external hostname of region {1}", m_externalHostName, m_regionName); } m_lastExternalHostName = newIP; m_lastResolverTime = DateTime.UtcNow; } } } else if (m_CheckDynDns) { if (DateTime.UtcNow - m_lastResolverTime > TimeSpan.FromMinutes(1)) { try { string newIP = Util.GetHostFromDNS(m_externalHostName).ToString(); lock (this) { if (newIP != m_lastExternalHostName && m_lastExternalHostName != string.Empty) { m_IPChanged = true; m_lastExternalHostName = newIP; } m_lastResolverTime = DateTime.UtcNow; } } catch { } } return(m_externalHostName); } else { m_lastExternalHostName = m_externalHostName; } return(m_lastExternalHostName); }
//not in use, should swap to nini though. public void LoadFromNiniSource(IConfigSource source, string sectionName) { string errorMessage = String.Empty; RegionID = new UUID(source.Configs[sectionName].GetString("Region_ID", UUID.Random().ToString())); RegionName = source.Configs[sectionName].GetString("sim_name", "Halcyon Test"); m_regionLocX = Convert.ToUInt32(source.Configs[sectionName].GetString("sim_location_x", "1000")); m_regionLocY = Convert.ToUInt32(source.Configs[sectionName].GetString("sim_location_y", "1000")); // this.DataStore = source.Configs[sectionName].GetString("datastore", "OpenSim.db"); string ipAddress = source.Configs[sectionName].GetString("internal_ip_address", "0.0.0.0"); IPAddress ipAddressResult; if (IPAddress.TryParse(ipAddress, out ipAddressResult)) { m_internalEndPoint = new IPEndPoint(ipAddressResult, 0); } else { errorMessage = "needs an IP Address (IPAddress)"; } m_internalEndPoint.Port = source.Configs[sectionName].GetInt("internal_ip_port", (int)ConfigSettings.DefaultRegionHttpPort); string externalHost = source.Configs[sectionName].GetString("external_host_name", "127.0.0.1"); if (externalHost != "SYSTEMIP") { m_externalHostName = externalHost; } else { m_externalHostName = Util.GetLocalHost().ToString(); } OutsideIP = source.Configs[sectionName].GetString("outside_ip", String.Empty); if (String.IsNullOrEmpty(OutsideIP)) { OutsideIP = null; } MasterAvatarFirstName = source.Configs[sectionName].GetString("master_avatar_first", "Test"); MasterAvatarLastName = source.Configs[sectionName].GetString("master_avatar_last", "User"); MasterAvatarSandboxPassword = source.Configs[sectionName].GetString("master_avatar_pass", "test"); MasterAvatarSandboxPassword = source.Configs[sectionName].GetString("master_avatar_pass", "test"); if (!String.IsNullOrEmpty(errorMessage)) { // TODO: a error } }
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())); }
public bool handleIncomingConfiguration(string configuration_key, object configuration_result) { switch (configuration_key) { case "sim_UUID": RegionID = (UUID)configuration_result; originRegionID = (UUID)configuration_result; break; case "sim_name": RegionName = (string)configuration_result; break; case "sim_location_x": m_regionLocX = (uint)configuration_result; break; case "sim_location_y": m_regionLocY = (uint)configuration_result; break; case "datastore": DataStore = (string)configuration_result; break; case "internal_ip_address": IPAddress address = (IPAddress)configuration_result; m_internalEndPoint = new IPEndPoint(address, 0); break; case "internal_ip_port": m_internalEndPoint.Port = (int)configuration_result; break; case "allow_alternate_ports": m_allow_alternate_ports = (bool)configuration_result; break; case "external_host_name": if ((string)configuration_result != "SYSTEMIP") { m_externalHostName = (string)configuration_result; } else { m_externalHostName = Util.GetLocalHost().ToString(); } break; case "lastmap_uuid": lastMapUUID = (UUID)configuration_result; break; case "lastmap_refresh": lastMapRefresh = (string)configuration_result; break; case "nonphysical_prim_max": m_nonphysPrimMax = (int)configuration_result; break; case "physical_prim_max": m_physPrimMax = (int)configuration_result; break; case "clamp_prim_size": m_clampPrimSize = (bool)configuration_result; break; case "object_capacity": m_objectCapacity = (int)configuration_result; break; case "scope_id": ScopeID = (UUID)configuration_result; break; case "region_type": m_regionType = (string)configuration_result; break; } return(true); }
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)); } }
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())); }
public bool handleIncomingConfiguration(string configuration_key, object configuration_result) { switch (configuration_key) { case "sim_UUID": RegionID = (UUID)configuration_result; originRegionID = (UUID)configuration_result; break; case "sim_name": RegionName = (string)configuration_result; break; case "sim_location_x": m_regionLocX = (uint)configuration_result; break; case "sim_location_y": m_regionLocY = (uint)configuration_result; break; case "datastore": DataStore = (string)configuration_result; break; case "internal_ip_address": IPAddress address = (IPAddress)configuration_result; m_internalEndPoint = new IPEndPoint(address, 0); break; case "internal_ip_port": m_internalEndPoint.Port = (int)configuration_result; break; case "allow_alternate_ports": m_allow_alternate_ports = (bool)configuration_result; break; case "external_host_name": if ((string)configuration_result != "SYSTEMIP") { m_externalHostName = (string)configuration_result; } else { m_externalHostName = Util.GetLocalHost().ToString(); } break; case "master_avatar_uuid": MasterAvatarAssignedUUID = (UUID)configuration_result; break; case "master_avatar_first": MasterAvatarFirstName = (string)configuration_result; break; case "master_avatar_last": MasterAvatarLastName = (string)configuration_result; break; case "master_avatar_pass": MasterAvatarSandboxPassword = (string)configuration_result; break; case "lastmap_uuid": lastMapUUID = (UUID)configuration_result; break; case "lastmap_refresh": lastMapRefresh = (string)configuration_result; break; case "nonphysical_prim_max": PrimLimitDefault = (int)configuration_result; break; case "physical_prim_max": m_physPrimMax = (int)configuration_result; break; case "clamp_prim_size": m_clampPrimSize = (bool)configuration_result; break; case "object_capacity": m_objectCapacity = (int)configuration_result; break; case "region_product": switch ((int)configuration_result) { case 1: m_product = ProductRulesUse.FullUse; break; case 2: m_product = ProductRulesUse.OceanUse; break; case 3: m_product = ProductRulesUse.ScenicUse; break; case 4: m_product = ProductRulesUse.PlusUse; break; case 0: default: m_product = ProductRulesUse.UnknownUse; break; } ApplyProductRules(); break; case "region_access": switch ((int)configuration_result) { case 1: m_productAccess = ProductAccessUse.PlusOnly; break; case 0: default: m_productAccess = ProductAccessUse.Anyone; break; } break; case "outside_ip": OutsideIP = (string)configuration_result; if (String.IsNullOrEmpty(OutsideIP)) { OutsideIP = null; } break; } return(true); }