/// <summary> /// Registers all of the hostnames configured in the database. /// </summary> public static void RegisterDefaultHostNames() { // Make sure we don't try to register the host names before // the database has been installed. if (SysParam.GetByName("SITE_VERSION") != null) { if (hostNames == null) { hostNames = new Dictionary <string, Entities.SiteTree>(); } HostNames.Clear(); // We need to check version so we don't try to access the column sitetree_hostnames // before it's been created in the database. if (Data.Database.InstalledVersion > 26) { using (var db = new DataContext()) { var sites = db.SiteTrees.ToList(); foreach (var site in sites) { if (HttpContext.Current != null) { Page.InvalidateStartpage(site.Id); } if (!String.IsNullOrEmpty(site.HostNames)) { var hostnames = site.HostNames.Split(new char[] { ',' }); foreach (var host in hostnames) { if (HostNames.ContainsKey(host)) { throw new Exception("Duplicates of the hostname [" + host + "] was found configured"); } HostNames.Add(host.ToLower(), site); } } if (site.Id == Config.DefaultSiteTreeId) { DefaultSite = site; } } } } } }
public void DisplayHosts(List <string> hostNames) { if (hostNames == null || hostNames.Equals(HostNames)) { return; } HostNames.Clear(); foreach (string hostname in hostNames) { HostNames.Add(hostname.Split(':').Last()); } if (!HostNames.Contains(SelectedHost)) { SelectedHost = string.Empty; joinButton.interactable = false; } Rebuild(HostNames, SelectHost, SelectedHost); }
/// <summary> /// /// </summary> /// <param name="itemType"></param> /// <param name="value"></param> private void AddItem(ItemType itemType, object value) { if (value.ToString().Length == 0) { return; } switch (itemType) { case ItemType.IpAddress: var ipAddresses = from ipAddress in IpAddresses where ipAddress.Text.ToUpper() == ((string)value).ToUpper() select ipAddress; if (ipAddresses.Count() == 0) { IpAddress ipAddress = new IpAddress(); ipAddress.Text = (string)value; IpAddresses.Add(ipAddress); } break; case ItemType.HostName: var hosts = from host in HostNames where host.ToUpper() == ((string)value).ToUpper() select host; if (hosts.Count() == 0) { HostNames.Add((string)value); } break; case ItemType.Port: var ports = from port in Ports where port == (int)value select port; if (ports.Count() == 0) { Ports.Add((int)value); } break; case ItemType.Protocol: var protocols = from protocol in Protocols where protocol.ToUpper() == ((string)value).ToUpper() select protocol; if (protocols.Count() == 0) { Protocols.Add(((string)value).ToUpper()); } break; case ItemType.Service: var services = from service in Services where service.ToUpper() == ((string)value).ToUpper() select service; if (services.Count() == 0) { Services.Add((string)value); } break; case ItemType.State: var states = from state in States where state.ToUpper() == ((string)value).ToUpper() select state; if (states.Count() == 0) { States.Add((string)value); } break; case ItemType.Severities: var severities = from severity in Severities where severity.ToUpper() == ((string)value).ToUpper() select severity; if (severities.Count() == 0) { Severities.Add((string)value); } break; case ItemType.PluginFamily: var pluginFamilies = from pluginFamily in PluginFamilys where pluginFamily.ToUpper() == ((string)value).ToUpper() select pluginFamily; if (pluginFamilies.Count() == 0) { PluginFamilys.Add((string)value); } break; case ItemType.PluginId: var pluginIds = from pluginId in PluginIds where pluginId.ToString().ToUpper() == ((string)value).ToUpper() select pluginId; if (pluginIds.Count() == 0) { PluginIds.Add(int.Parse(value.ToString())); } break; case ItemType.PluginName: var pluginNames = from pluginName in PluginNames where pluginName.ToUpper() == ((string)value).ToUpper() select pluginName; if (pluginNames.Count() == 0) { PluginNames.Add((string)value); } break; case ItemType.Product: var products = from product in Products where product.ToUpper() == ((string)value).ToUpper() select product; if (products.Count() == 0) { Products.Add((string)value); } break; case ItemType.Versions: var versions = from version in Versions where version.ToUpper() == ((string)value).ToUpper() select version; if (versions.Count() == 0) { Versions.Add((string)value); } break; case ItemType.ExploitAvailable: var exploitAvailable = from e in ExploitAvailable where e.ToUpper() == ((string)value).ToUpper() select e; if (exploitAvailable.Count() == 0) { ExploitAvailable.Add((string)value); } break; default: break; } }