private void HandleNewUrl(string url) { KnownGlobalLinks.Add(url); IsDataChanged = true; if (url.Length == 0 || url.StartsWith("#")) { return; } var r = new Regex(@"^(?:(?<protocol>[a-zA-Z0-9]+)\:)?(?:\/\/)?(?<host>[^\/]+)?(?:\:(?<port>[0-9]+))?(?<subpath>.*)$"); var match = r.Match(url); if (!match.Success) { throw new NotImplementedException($"Unexpected url format could not be understood: {url}"); } var host = match.Groups["host"].Value; // A link without a host is a relative link. As we only visit content from our host under test the relative links are always links to the host under test. var isLocal = host.Length == 0 || HostNames.Contains(host); if (!isLocal) { return; } KnownLocalSubpaths.Add(match.Groups["subpath"].Value); IsDataChanged = true; }
public void Show(UnityAction cancelAction) { gameObject.SetActive(true); transform.SetAsLastSibling(); HostNames.Clear(); SelectedHost = string.Empty; Rebuild(HostNames, SelectHost, SelectedHost); CardGameManager.Instance.discovery.lobby = this; CardGameManager.Instance.discovery.SearchForHost(); }
/// <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 Show(UnityAction cancelAction) { gameObject.SetActive(true); transform.SetAsLastSibling(); cancelButton.onClick.RemoveAllListeners(); cancelButton.onClick.AddListener(cancelAction); HostNames.Clear(); SelectedHost = string.Empty; Rebuild(HostNames, SelectHost, SelectedHost); CardGameManager.Instance.Discovery.lobby = this; CardGameManager.Instance.Discovery.SearchForHost(); }
private void OnAddCommand() { var hostList = new List <string>(HostNames.ToUpperInvariant().Replace("\r", string.Empty).Split('\n')); hostList.RemoveAll(e => e.Trim().Equals(string.Empty)); var removeList = (from o in _originalHostNameList where !hostList.Contains(o.ToUpperInvariant()) select o).ToList(); var addList = (from h in hostList where !_originalHostNameList.Contains(h.ToUpperInvariant()) select h).ToList(); App.Mediator.Publish(App._EVENT_ADDHOSTLIST_ADDED, new HostListAddedMessage { AddList = addList, RemoveList = removeList }); CloseModal(); }
private void StartConnection() { var t = Task.Factory.StartNew(() => { try { _Connection = GetConnectionFac().CreateConnection(HostNames.Split('|')); AddConnectionShutdownDelegate(_Connection); try { _Model = _Connection.CreateModel(); } catch (Exception e) { InternalLogger.Error("could not create model, {0}", e); } if (_Model != null && !Passive) { try { _Model.ExchangeDeclare(_Exchange, _ExchangeType, _Durable); } catch (Exception e) { if (_Model != null) { _Model.Dispose(); _Model = null; } InternalLogger.Error(string.Format("could not declare exchange, {0}", e)); } } } catch (Exception e) { InternalLogger.Error(string.Format("could not connect to Rabbit instance, {0}", e)); } }); if (!t.Wait(TimeSpan.FromMilliseconds(Timeout))) { InternalLogger.Warn("starting connection-task timed out, continuing"); } }
private void UpdateHostNames() { if (HostNames != null) { string hostname = WebsitesClient.GetHostName(Name, Slot); List <string> newHostNames = new List <string>(); if (!HostNames.Contains(hostname)) { newHostNames.Add(hostname); newHostNames.AddRange(HostNames); } if (newHostNames.Count > 0) { WebsitesClient.UpdateWebsiteHostNames(website, newHostNames, Slot); } } }
/// <summary>Indicates whether the current object is equal to another object of the same type.</summary> /// <param name="other">An object to compare with this object.</param> /// <returns> /// <see langword="true" /> if the current object is equal to the <paramref name="other" /> parameter; otherwise, <see langword="false" />.</returns> public bool Equals(MqConnectionSettings?other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(HostNames.Equals(other.HostNames) && Port == other.Port && UseAsyncConsumer == other.UseAsyncConsumer && string.Equals(UserName, other.UserName, StringComparison.Ordinal) && string.Equals(Password, other.Password, StringComparison.Ordinal) && string.Equals(VirtualHost, other.VirtualHost, StringComparison.Ordinal) && string.Equals(ConnectionName, other.ConnectionName, StringComparison.Ordinal)); }
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); }
public void DisplayHosts(List <string> hosts) { if (hosts == null || hosts.OrderBy(t => t).ToList().SequenceEqual(HostNames.Keys.ToList())) { return; } HostNames.Clear(); foreach (string host in hosts) { HostNames[host] = host.Split(':').Last(); } if (!HostNames.ContainsValue(SelectedHost)) { SelectedHost = string.Empty; joinButton.interactable = false; } Rebuild(HostNames, SelectHost, SelectedHost); }
/// <summary> /// Handles the URL Rewriting for the application /// </summary> /// <param name="context">Http context</param> public static void BeginRequest(HttpContext context) { try { string path = context.Request.Path.Substring(context.Request.ApplicationPath.Length > 1 ? context.Request.ApplicationPath.Length : 0); string[] args = path.Split(new char[] { '/' }).Subset(1); if (args.Length > 0) { int pos = 0; // Ensure database if (args[0] == "" && SysParam.GetByName("SITE_VERSION") == null) { context.Response.Redirect("~/manager", false); context.Response.EndClean(); } // Check for culture prefix if (Cultures.ContainsKey(args[0])) { System.Threading.Thread.CurrentThread.CurrentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture = Cultures[args[0]]; pos = 1; } else { var def = (GlobalizationSection)WebConfigurationManager.GetSection("system.web/globalization"); if (def != null && !String.IsNullOrWhiteSpace(def.Culture) && !def.Culture.StartsWith("auto:")) { System.Threading.Thread.CurrentThread.CurrentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(def.UICulture); } } // Check for hostname extension. This feature can't be combined with culture prefixes if (pos == 0) { var segments = context.Request.RawUrl.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); if (segments.Length > 0) { var hostExt = context.Request.Url.Host + "/" + segments[0]; if (HostNames.ContainsKey(hostExt)) { RequestedSite = new ExtendedHostName() { HostName = context.Request.Url.Host, Extension = segments[0], SiteTree = HostNames[hostExt] }; if (segments[0] == args[0]) { pos = 1; // If this was the last argument, add an empty one if (args.Length == 1) { args = args.Concat(new string[] { "" }).ToArray(); } } } } } var handled = false; // Find the correct request handler foreach (var hr in Application.Current.Handlers) { if (hr.UrlPrefix.ToLower() == args[pos].ToLower()) { if (hr.Id != "PERMALINK" || !Config.PrefixlessPermalinks) { // Don't execute permalink routing in passive mode if ((hr.Id != "PERMALINK" && hr.Id != "STARTPAGE") || !Config.PassiveMode) { // Execute the handler hr.Handler.HandleRequest(context, args.Subset(pos + 1)); handled = true; break; } } } } if (!handled && args[pos].ToLower() == "res.ashx") { Application.Current.Resources.HandleRequest(context, args.Subset(pos + 1)); handled = true; } // If no handler was found and we are using prefixless permalinks, // route traffic to the permalink handler. if (!Config.PassiveMode) { if (!handled && Config.PrefixlessPermalinks && args[pos].ToLower() != "manager" && String.IsNullOrEmpty(context.Request["permalink"])) { if (Permalink.GetByName(Config.SiteTreeNamespaceId, args[pos]) != null || Permalink.GetByName(Config.DefaultNamespaceId, args[pos]) != null) { var handler = Application.Current.Handlers["PERMALINK"]; handler.HandleRequest(context, args.Subset(pos)); } } } } } catch (ThreadAbortException) { // We simply swallow this exception as we don't want unhandled // exceptions flying around causing the app pool to die. } catch (Exception e) { // One catch to rule them all, and in the log file bind them. Application.Current.LogProvider.Error("WebPiranha.BeginRequest", "Unhandled exception", e); context.Response.StatusCode = 500; context.Response.EndClean(); } }
/// <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; } }