public List <string> GetBootstrapUrls() { List <string> urls = new List <string>(); // Manual Urls foreach (string url in Engine.Instance.Storage.Get("bootstrap.urls").Split(';')) { string sUrl = url.Trim(); if (sUrl != "") { if (IpAddress.IsIP(sUrl)) { sUrl = "http://" + sUrl; } string host = UtilsCore.HostFromUrl(sUrl); if (host != "") { urls.Add(sUrl); } } } // Manifest Urls if (Manifest != null) { XmlNodeList nodesUrls = Manifest.SelectNodes("//urls/url"); foreach (XmlNode nodeUrl in nodesUrls) { urls.Add(nodeUrl.Attributes["address"].Value); } } return(urls); }
public override IpAddresses GetNetworkLockAllowedIps() { IpAddresses result = base.GetNetworkLockAllowedIps(); List <string> urls = GetBootstrapUrls(); foreach (string url in urls) { string host = UtilsCore.HostFromUrl(url); if (host != "") { result.Add(host); } } return(result); }
public static XmlDocument FetchUrls(string title, string authPublicKey, List <string> urls, Dictionary <string, string> parameters) { parameters["login"] = Engine.Instance.Storage.Get("login"); parameters["password"] = Engine.Instance.Storage.Get("password"); parameters["system"] = Platform.Instance.GetSystemCode(); parameters["version"] = Constants.VersionInt.ToString(CultureInfo.InvariantCulture); string firstError = ""; int hostN = 0; foreach (string url in urls) { string host = UtilsCore.HostFromUrl(url); hostN++; if (IpAddress.IsIP(host) == false) { // If locked network are enabled, skip the hostname and try only by IP. // To avoid DNS issue (generally, to avoid losing time). if (Engine.Instance.NetworkLockManager.IsDnsResolutionAvailable(host) == false) { continue; } } try { RouteScope routeScope = new RouteScope(host); XmlDocument xmlDoc = FetchUrl(authPublicKey, url, parameters); routeScope.End(); if (xmlDoc == null) { throw new Exception("No answer."); } if (xmlDoc.DocumentElement.Attributes["error"] != null) { throw new Exception(xmlDoc.DocumentElement.Attributes["error"].Value); } return(xmlDoc); } catch (Exception e) { string info = e.Message; string proxyMode = Engine.Instance.Storage.Get("proxy.mode").ToLowerInvariant(); string proxyWhen = Engine.Instance.Storage.Get("proxy.when").ToLowerInvariant(); string proxyAuth = Engine.Instance.Storage.Get("proxy.auth").ToLowerInvariant(); if (proxyMode != "none") { info += " - with '" + proxyMode + "' (" + proxyWhen + ") proxy and '" + proxyAuth + "' auth"; } if (Engine.Instance.Storage.GetBool("advanced.expert")) { Engine.Instance.Logs.Log(LogType.Verbose, MessagesFormatter.Format(Messages.ExchangeTryFailed, title, hostN.ToString(), info)); } if (firstError == "") { firstError = info; } } } throw new Exception(firstError); }