public override bool GetProxies(Uri destination, out IList <string> proxyList) { bool flag2; try { proxyList = null; this.EnsureEngineAvailable(); if (base.State != BaseWebProxyFinder.AutoWebProxyState.Completed) { return(false); } bool flag = false; try { string scriptReturn = this.scriptInstance.FindProxyForURL(destination.ToString(), destination.Host); proxyList = ParseScriptResult(scriptReturn); flag = true; } catch (Exception exception) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString("net_log_proxy_script_execution_error", new object[] { exception })); } } flag2 = flag; } finally { this.aborted = false; } return(flag2); }
public static IPHostEntry EndResolve(IAsyncResult asyncResult) { IPHostEntry unresolveAnswer; if (Logging.On) { Logging.Enter(Logging.Sockets, "DNS", "EndResolve", asyncResult); } try { unresolveAnswer = HostResolutionEndHelper(asyncResult); } catch (SocketException exception) { IPAddress address = ((ResolveAsyncResult)asyncResult).address; if (address == null) { throw; } if (Logging.On) { Logging.PrintWarning(Logging.Sockets, "DNS", "DNS.EndResolve", exception.Message); } unresolveAnswer = GetUnresolveAnswer(address); } if (Logging.On) { Logging.Exit(Logging.Sockets, "DNS", "EndResolve", unresolveAnswer); } return(unresolveAnswer); }
public bool localHostOrDomainIs(string host, string hostDom) { if (host == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString("net_log_proxy_called_with_null_parameter", new object[] { "WebProxyScriptHelper.localHostOrDomainIs()", "host" })); } throw new ArgumentNullException("host"); } if (hostDom == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString("net_log_proxy_called_with_null_parameter", new object[] { "WebProxyScriptHelper.localHostOrDomainIs()", "hostDom" })); } throw new ArgumentNullException("hostDom"); } if (this.isPlainHostName(host)) { int index = hostDom.IndexOf('.'); if (index > 0) { hostDom = hostDom.Substring(0, index); } } return(string.Compare(host, hostDom, StringComparison.OrdinalIgnoreCase) == 0); }
private static void LogWarning(string methodName, string message, params object[] args) { if (Logging.On) { Logging.PrintWarning(Logging.HttpListener, typeof(HttpSysSettings), methodName, SR.GetString(message, args)); } }
public string dnsResolve(string host) { GlobalLog.Print("WebProxyScriptHelper::dnsResolve() host:" + ValidationHelper.ToString(host)); if (host == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString(SR.net_log_proxy_called_with_null_parameter, "WebProxyScriptHelper.dnsResolve()", "host")); } throw new ArgumentNullException("host"); } IPHostEntry ipHostEntry = null; try { ipHostEntry = Dns.InternalGetHostByName(host); } catch { } if (ipHostEntry == null) { return(string.Empty); } for (int i = 0; i < ipHostEntry.AddressList.Length; i++) { if (ipHostEntry.AddressList[i].AddressFamily == AddressFamily.InterNetwork) { return(ipHostEntry.AddressList[i].ToString()); } } return(string.Empty); }
public bool shExpMatch(string host, string pattern) { if (host == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString("net_log_proxy_called_with_null_parameter", new object[] { "WebProxyScriptHelper.shExpMatch()", "host" })); } throw new ArgumentNullException("host"); } if (pattern == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString("net_log_proxy_called_with_null_parameter", new object[] { "WebProxyScriptHelper.shExpMatch()", "pattern" })); } throw new ArgumentNullException("pattern"); } try { ShellExpression expression = new ShellExpression(pattern); return(expression.IsMatch(host)); } catch (FormatException) { return(false); } }
// See public bool shExpMatch(string host, string pattern) { GlobalLog.Print("WebProxyScriptHelper::shExpMatch() host:" + ValidationHelper.ToString(host) + " pattern:" + ValidationHelper.ToString(pattern)); if (host == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString(SR.net_log_proxy_called_with_null_parameter, "WebProxyScriptHelper.shExpMatch()", "host")); } throw new ArgumentNullException("host"); } if (pattern == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString(SR.net_log_proxy_called_with_null_parameter, "WebProxyScriptHelper.shExpMatch()", "pattern")); } throw new ArgumentNullException("pattern"); } try { // This can throw - treat as no match. ShellExpression exp = new ShellExpression(pattern); return(exp.IsMatch(host)); } catch (FormatException) { return(false); } }
public bool isResolvableEx(string host) { if (host == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString("net_log_proxy_called_with_null_parameter", new object[] { "WebProxyScriptHelper.dnsResolve()", "host" })); } throw new ArgumentNullException("host"); } IPHostEntry hostByName = null; try { hostByName = Dns.InternalGetHostByName(host); } catch { } if (hostByName == null) { return(false); } if (hostByName.AddressList.Length == 0) { return(false); } return(true); }
/// <devdoc> /// <para> /// This is a strange function, if its not a local hostname /// we do a straight compare against the passed in domain /// string. If its not a direct match, then its false, /// even if the root of the domain/hostname are the same. /// </para> /// </devdoc> public bool localHostOrDomainIs(string host, string hostDom) { GlobalLog.Print("WebProxyScriptHelper::localHostOrDomainIs() host:" + ValidationHelper.ToString(host) + " hostDom:" + ValidationHelper.ToString(hostDom)); if (host == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString(SR.net_log_proxy_called_with_null_parameter, "WebProxyScriptHelper.localHostOrDomainIs()", "host")); } throw new ArgumentNullException("host"); } if (hostDom == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString(SR.net_log_proxy_called_with_null_parameter, "WebProxyScriptHelper.localHostOrDomainIs()", "hostDom")); } throw new ArgumentNullException("hostDom"); } if (isPlainHostName(host)) { int index = hostDom.IndexOf('.'); if (index > 0) { hostDom = hostDom.Substring(0, index); } } return(string.Compare(host, hostDom, StringComparison.OrdinalIgnoreCase) == 0); }
public bool isResolvableEx(string host) { GlobalLog.Print("WebProxyScriptHelper::dnsResolveEx() host:" + ValidationHelper.ToString(host)); if (host == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString(SR.net_log_proxy_called_with_null_parameter, "WebProxyScriptHelper.dnsResolve()", "host")); } throw new ArgumentNullException("host"); } IPHostEntry ipHostEntry = null; try { ipHostEntry = Dns.InternalGetHostByName(host); } catch { } if (ipHostEntry == null) { return(false); } IPAddress[] addresses = ipHostEntry.AddressList; if (addresses.Length == 0) { return(false); } return(true); }
public bool isResolvable(string host) { if (host == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString("net_log_proxy_called_with_null_parameter", new object[] { "WebProxyScriptHelper.isResolvable()", "host" })); } throw new ArgumentNullException("host"); } IPHostEntry hostByName = null; try { hostByName = Dns.InternalGetHostByName(host); } catch { } if (hostByName != null) { for (int i = 0; i < hostByName.AddressList.Length; i++) { if (hostByName.AddressList[i].AddressFamily == AddressFamily.InterNetwork) { return(true); } } } return(false); }
private void ConnectoidChanged() { GlobalLog.Print("AutoWebProxyScriptEngine#" + ValidationHelper.HashString(this) + "::ConnectoidChanged()"); if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString(SR.net_log_proxy_update_due_to_ip_config_change)); } // Get the new connectoid/detector. Only do this after detecting a change, to avoid ----s with other people detecting changes. // (We don't want to end up using a detector/connectoid that doesn't match what we read from the registry.) m_AutoDetector = AutoDetector.CurrentAutoDetector; if (m_UseRegistry) { // update the engine and proxy WebProxyData webProxyData; using (m_Identity.Impersonate()) { webProxyData = GetWebProxyData(); } webProxy.Update(webProxyData); } // Always uninitialized if the connectoid/address changed and we are autodetecting. if (automaticallyDetectSettings) { webProxyFinder.Reset(); } }
private void LogWarning(string methodName, string message, params object[] args) { if (Logging.On) { Logging.PrintWarning(Logging.HttpListener, this, methodName, SR.GetString(message, args)); } }
private static WindowsInstallationType GetWindowsInstallType() { WindowsInstallationType unknown; try { using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows NT\CurrentVersion")) { string str = key.GetValue("InstallationType") as string; if (string.IsNullOrEmpty(str)) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString("net_empty_osinstalltype", new object[] { @"Software\Microsoft\Windows NT\CurrentVersion\InstallationType" })); } return(WindowsInstallationType.Unknown); } if (string.Compare(str, "Client", StringComparison.OrdinalIgnoreCase) == 0) { return(WindowsInstallationType.Client); } if (string.Compare(str, "Server", StringComparison.OrdinalIgnoreCase) == 0) { return(WindowsInstallationType.Server); } if (string.Compare(str, "Server Core", StringComparison.OrdinalIgnoreCase) == 0) { return(WindowsInstallationType.ServerCore); } if (string.Compare(str, "Embedded", StringComparison.OrdinalIgnoreCase) == 0) { return(WindowsInstallationType.Embedded); } if (Logging.On) { Logging.PrintError(Logging.Web, SR.GetString("net_unknown_osinstalltype", new object[] { str })); } unknown = WindowsInstallationType.Unknown; } } catch (UnauthorizedAccessException exception) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString("net_cant_determine_osinstalltype", new object[] { @"Software\Microsoft\Windows NT\CurrentVersion", exception.Message })); } unknown = WindowsInstallationType.Unknown; } catch (SecurityException exception2) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString("net_cant_determine_osinstalltype", new object[] { @"Software\Microsoft\Windows NT\CurrentVersion", exception2.Message })); } unknown = WindowsInstallationType.Unknown; } return(unknown); }
public override void Abort() { GlobalLog.Enter("FileWebRequest::Abort"); if (Logging.On) { Logging.PrintWarning(Logging.Web, NetRes.GetWebStatusString("net_requestaborted", WebExceptionStatus.RequestCanceled)); } try { if (Interlocked.Increment(ref m_Aborted) == 1) { LazyAsyncResult readAResult = m_ReadAResult; LazyAsyncResult writeAResult = m_WriteAResult; WebException webException = new WebException(NetRes.GetWebStatusString("net_requestaborted", WebExceptionStatus.RequestCanceled), WebExceptionStatus.RequestCanceled); Stream requestStream = m_stream; if (readAResult != null && !readAResult.IsCompleted) { readAResult.InvokeCallback(webException); } if (writeAResult != null && !writeAResult.IsCompleted) { writeAResult.InvokeCallback(webException); } if (requestStream != null) { if (requestStream is ICloseEx) { ((ICloseEx)requestStream).CloseEx(CloseExState.Abort); } else { requestStream.Close(); } } if (m_response != null) { ((ICloseEx)m_response).CloseEx(CloseExState.Abort); } } } catch (Exception exception) { if (Logging.On) { Logging.Exception(Logging.Web, this, "Abort", exception); } throw; } finally { GlobalLog.Leave("FileWebRequest::Abort"); } }
public bool isPlainHostName(string hostName) { if (hostName != null) { return(hostName.IndexOf('.') == -1); } if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString("net_log_proxy_called_with_null_parameter", new object[] { "WebProxyScriptHelper.isPlainHostName()", "hostName" })); } throw new ArgumentNullException("hostName"); }
public bool isInNet(string host, string pattern, string mask) { GlobalLog.Print("WebProxyScriptHelper::isInNet() host:" + ValidationHelper.ToString(host) + " pattern:" + ValidationHelper.ToString(pattern) + " mask:" + ValidationHelper.ToString(mask)); if (host == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString(SR.net_log_proxy_called_with_null_parameter, "WebProxyScriptHelper.isInNet()", "host")); } throw new ArgumentNullException("host"); } if (pattern == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString(SR.net_log_proxy_called_with_null_parameter, "WebProxyScriptHelper.isInNet()", "pattern")); } throw new ArgumentNullException("pattern"); } if (mask == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString(SR.net_log_proxy_called_with_null_parameter, "WebProxyScriptHelper.isInNet()", "mask")); } throw new ArgumentNullException("mask"); } try { IPAddress hostAddress = IPAddress.Parse(host); IPAddress patternAddress = IPAddress.Parse(pattern); IPAddress maskAddress = IPAddress.Parse(mask); byte[] maskAddressBytes = maskAddress.GetAddressBytes(); byte[] hostAddressBytes = hostAddress.GetAddressBytes(); byte[] patternAddressBytes = patternAddress.GetAddressBytes(); if (maskAddressBytes.Length != hostAddressBytes.Length || maskAddressBytes.Length != patternAddressBytes.Length) { return(false); } for (int i = 0; i < maskAddressBytes.Length; i++) { if ((patternAddressBytes[i] & maskAddressBytes[i]) != (hostAddressBytes[i] & maskAddressBytes[i])) { return(false); } } } catch { return(false); } return(true); }
public bool weekdayRange(string wd1, [Optional] object wd2, [Optional] object gmt) { GlobalLog.Print("WebProxyScriptHelper::weekdayRange() wd1:" + ValidationHelper.ToString(wd1) + " wd2:" + ValidationHelper.ToString(wd2) + " gmt:" + ValidationHelper.ToString(gmt)); if (wd1 == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString(SR.net_log_proxy_called_with_null_parameter, "WebProxyScriptHelper.weekdayRange()", "wd1")); } throw new ArgumentNullException("wd1"); } string _gmt = null; string _wd2 = null; if (gmt != null && gmt != DBNull.Value && gmt != Missing.Value) { _gmt = gmt as string; if (_gmt == null) { throw new ArgumentException(SR.GetString(SR.net_param_not_string, gmt.GetType().FullName), "gmt"); } } if (wd2 != null && wd2 != DBNull.Value && gmt != Missing.Value) { _wd2 = wd2 as string; if (_wd2 == null) { throw new ArgumentException(SR.GetString(SR.net_param_not_string, wd2.GetType().FullName), "wd2"); } } if (_gmt != null) { if (!isGMT(_gmt)) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString(SR.net_log_proxy_called_with_null_parameter, "WebProxyScriptHelper.weekdayRange()", "gmt")); } throw new ArgumentException(SR.GetString(SR.net_proxy_not_gmt), "gmt"); } return(weekdayRangeInternal(DateTime.UtcNow, dayOfWeek(wd1), dayOfWeek(_wd2))); } if (_wd2 != null) { if (isGMT(_wd2)) { return(weekdayRangeInternal(DateTime.UtcNow, dayOfWeek(wd1), dayOfWeek(wd1))); } return(weekdayRangeInternal(DateTime.Now, dayOfWeek(wd1), dayOfWeek(_wd2))); } return(weekdayRangeInternal(DateTime.Now, dayOfWeek(wd1), dayOfWeek(wd1))); }
public bool isPlainHostName(string hostName) { GlobalLog.Print("WebProxyScriptHelper::isPlainHostName() hostName:" + ValidationHelper.ToString(hostName)); if (hostName == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString(SR.net_log_proxy_called_with_null_parameter, "WebProxyScriptHelper.isPlainHostName()", "hostName")); } throw new ArgumentNullException("hostName"); } return(hostName.IndexOf('.') == -1); }
public bool weekdayRange(string wd1, [Optional] object wd2, [Optional] object gmt) { if (wd1 == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString("net_log_proxy_called_with_null_parameter", new object[] { "WebProxyScriptHelper.weekdayRange()", "wd1" })); } throw new ArgumentNullException("wd1"); } string str = null; string str2 = null; if (((gmt != null) && (gmt != DBNull.Value)) && (gmt != Missing.Value)) { str = gmt as string; if (str == null) { throw new ArgumentException(SR.GetString("net_param_not_string", new object[] { gmt.GetType().FullName }), "gmt"); } } if (((wd2 != null) && (wd2 != DBNull.Value)) && (gmt != Missing.Value)) { str2 = wd2 as string; if (str2 == null) { throw new ArgumentException(SR.GetString("net_param_not_string", new object[] { wd2.GetType().FullName }), "wd2"); } } if (str == null) { if (str2 == null) { return(weekdayRangeInternal(DateTime.Now, dayOfWeek(wd1), dayOfWeek(wd1))); } if (isGMT(str2)) { return(weekdayRangeInternal(DateTime.UtcNow, dayOfWeek(wd1), dayOfWeek(wd1))); } return(weekdayRangeInternal(DateTime.Now, dayOfWeek(wd1), dayOfWeek(str2))); } if (isGMT(str)) { return(weekdayRangeInternal(DateTime.UtcNow, dayOfWeek(wd1), dayOfWeek(str2))); } if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString("net_log_proxy_called_with_null_parameter", new object[] { "WebProxyScriptHelper.weekdayRange()", "gmt" })); } throw new ArgumentException(SR.GetString("net_proxy_not_gmt"), "gmt"); }
public bool isInNet(string host, string pattern, string mask) { if (host == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString("net_log_proxy_called_with_null_parameter", new object[] { "WebProxyScriptHelper.isInNet()", "host" })); } throw new ArgumentNullException("host"); } if (pattern == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString("net_log_proxy_called_with_null_parameter", new object[] { "WebProxyScriptHelper.isInNet()", "pattern" })); } throw new ArgumentNullException("pattern"); } if (mask == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString("net_log_proxy_called_with_null_parameter", new object[] { "WebProxyScriptHelper.isInNet()", "mask" })); } throw new ArgumentNullException("mask"); } try { IPAddress address = IPAddress.Parse(host); IPAddress address2 = IPAddress.Parse(pattern); byte[] addressBytes = IPAddress.Parse(mask).GetAddressBytes(); byte[] buffer2 = address.GetAddressBytes(); byte[] buffer3 = address2.GetAddressBytes(); if ((addressBytes.Length != buffer2.Length) || (addressBytes.Length != buffer3.Length)) { return(false); } for (int i = 0; i < addressBytes.Length; i++) { if ((buffer3[i] & addressBytes[i]) != (buffer2[i] & addressBytes[i])) { return(false); } } } catch { return(false); } return(true); }
private void RegistryChanged() { WebProxyData webProxyData; if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString("net_log_proxy_system_setting_update")); } using (this.m_Identity.Impersonate()) { webProxyData = this.GetWebProxyData(); } this.webProxy.Update(webProxyData); }
public override void Abort() { if (Logging.On) { Logging.PrintWarning(Logging.Web, NetRes.GetWebStatusString("net_requestaborted", WebExceptionStatus.RequestCanceled)); } try { if (Interlocked.Increment(ref this.m_Aborted) == 1) { LazyAsyncResult readAResult = this.m_ReadAResult; LazyAsyncResult writeAResult = this.m_WriteAResult; WebException result = new WebException(NetRes.GetWebStatusString("net_requestaborted", WebExceptionStatus.RequestCanceled), WebExceptionStatus.RequestCanceled); Stream stream = this.m_stream; if ((readAResult != null) && !readAResult.IsCompleted) { readAResult.InvokeCallback(result); } if ((writeAResult != null) && !writeAResult.IsCompleted) { writeAResult.InvokeCallback(result); } if (stream != null) { if (stream is ICloseEx) { ((ICloseEx)stream).CloseEx(CloseExState.Abort); } else { stream.Close(); } } if (this.m_response != null) { ((ICloseEx)this.m_response).CloseEx(CloseExState.Abort); } } } catch (Exception exception2) { if (Logging.On) { Logging.Exception(Logging.Web, this, "Abort", exception2); } throw; } }
private static unsafe Uri SafeDetectAutoProxyUrl( UnsafeNclNativeMethods.WinHttp.AutoDetectType discoveryMethod) { Uri autoProxy = null; #if !FEATURE_PAL string url = null; GlobalLog.Print("NetWebProxyFinder::SafeDetectAutoProxyUrl() Using WinHttp."); SafeGlobalFree autoProxyUrl; bool success = UnsafeNclNativeMethods.WinHttp.WinHttpDetectAutoProxyConfigUrl(discoveryMethod, out autoProxyUrl); if (!success) { if (autoProxyUrl != null) { autoProxyUrl.SetHandleAsInvalid(); } } else { url = new string((char *)autoProxyUrl.DangerousGetHandle()); autoProxyUrl.Close(); } if (url != null) { bool parsed = Uri.TryCreate(url, UriKind.Absolute, out autoProxy); if (!parsed) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString(SR.net_log_proxy_autodetect_script_location_parse_error, ValidationHelper.ToString(url))); } GlobalLog.Print("NetWebProxyFinder::SafeDetectAutoProxyUrl() Uri.TryParse() failed url:" + ValidationHelper.ToString(url)); } } else { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString(SR.net_log_proxy_autodetect_failed)); } GlobalLog.Print("NetWebProxyFinder::SafeDetectAutoProxyUrl() DetectAutoProxyUrl() returned false"); } #endif // !FEATURE_PAL return(autoProxy); }
private static bool weekdayRangeInternal(DateTime now, DayOfWeek wd1, DayOfWeek wd2) { if (wd1 < 0 || wd2 < 0) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString(SR.net_log_proxy_called_with_invalid_parameter, "WebProxyScriptHelper.weekdayRange()")); } throw new ArgumentException(SR.GetString(SR.net_proxy_invalid_dayofweek), wd1 < 0 ? "wd1" : "wd2"); } if (wd1 <= wd2) { return(wd1 <= now.DayOfWeek && now.DayOfWeek <= wd2); } return(wd2 >= now.DayOfWeek || now.DayOfWeek >= wd1); }
private static bool IsAddressListLoopback(IPAddress[] addressList) { IPAddress[] localAddresses = null; try { localAddresses = NclUtilities.LocalAddresses; } catch (Exception exception) { if (NclUtilities.IsFatal(exception)) { throw; } if (Logging.On) { Logging.PrintError(Logging.Web, SR.GetString("net_log_retrieving_localhost_exception", new object[] { exception })); Logging.PrintWarning(Logging.Web, SR.GetString("net_log_resolved_servicepoint_may_not_be_remote_server")); } } int index = 0; while (index < addressList.Length) { if (!IPAddress.IsLoopback(addressList[index])) { if (localAddresses == null) { break; } int num2 = 0; while (num2 < localAddresses.Length) { if (addressList[index].Equals(localAddresses[num2])) { break; } num2++; } if (num2 >= localAddresses.Length) { break; } } index++; } return(index == addressList.Length); }
private void RegistryChanged() { GlobalLog.Print("AutoWebProxyScriptEngine#" + ValidationHelper.HashString(this) + "::RegistryChanged()"); if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString(SR.net_log_proxy_system_setting_update)); } // always refresh settings because they might have changed WebProxyData webProxyData; using (m_Identity.Impersonate()) { webProxyData = GetWebProxyData(); } webProxy.Update(webProxyData); }
private static void ReadSuppressExtendedProtectionRegistryValue() { suppressExtendedProtection = !ComNetOS.IsWin7; try { using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"System\CurrentControlSet\Control\Lsa")) { try { if (key.GetValueKind("SuppressExtendedProtection") == RegistryValueKind.DWord) { suppressExtendedProtection = ((int)key.GetValue("SuppressExtendedProtection")) == 1; } } catch (UnauthorizedAccessException exception) { if (Logging.On) { Logging.PrintWarning(Logging.Web, typeof(HttpDigest), "ReadSuppressExtendedProtectionRegistryValue", exception.Message); } } catch (IOException exception2) { if (Logging.On) { Logging.PrintWarning(Logging.Web, typeof(HttpDigest), "ReadSuppressExtendedProtectionRegistryValue", exception2.Message); } } } } catch (SecurityException exception3) { if (Logging.On) { Logging.PrintWarning(Logging.Web, typeof(HttpDigest), "ReadSuppressExtendedProtectionRegistryValue", exception3.Message); } } catch (ObjectDisposedException exception4) { if (Logging.On) { Logging.PrintWarning(Logging.Web, typeof(HttpDigest), "ReadSuppressExtendedProtectionRegistryValue", exception4.Message); } } }
public string dnsResolveEx(string host) { if (host == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString("net_log_proxy_called_with_null_parameter", new object[] { "WebProxyScriptHelper.dnsResolve()", "host" })); } throw new ArgumentNullException("host"); } IPHostEntry hostByName = null; try { hostByName = Dns.InternalGetHostByName(host); } catch { } if (hostByName == null) { return(string.Empty); } IPAddress[] addressList = hostByName.AddressList; if (addressList.Length == 0) { return(string.Empty); } StringBuilder builder = new StringBuilder(); for (int i = 0; i < addressList.Length; i++) { builder.Append(addressList[i].ToString()); if (i != (addressList.Length - 1)) { builder.Append(";"); } } if (builder.Length <= 0) { return(string.Empty); } return(builder.ToString()); }
private static unsafe Uri SafeDetectAutoProxyUrl(UnsafeNclNativeMethods.WinHttp.AutoDetectType discoveryMethod) { Uri result = null; string uriString = null; if (ComNetOS.IsWinHttp51) { SafeGlobalFree free; if (!UnsafeNclNativeMethods.WinHttp.WinHttpDetectAutoProxyConfigUrl(discoveryMethod, out free)) { if (free != null) { free.SetHandleAsInvalid(); } } else { uriString = new string((char *)free.DangerousGetHandle()); free.Close(); } } else { StringBuilder autoProxyUrl = new StringBuilder(0x80a); if (UnsafeNclNativeMethods.WinInet.DetectAutoProxyUrl(autoProxyUrl, 0x80a, (int)discoveryMethod)) { uriString = autoProxyUrl.ToString(); } } if (uriString == null) { if (Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString("net_log_proxy_autodetect_failed")); } return(result); } if (!Uri.TryCreate(uriString, UriKind.Absolute, out result) && Logging.On) { Logging.PrintWarning(Logging.Web, SR.GetString("net_log_proxy_autodetect_script_location_parse_error", new object[] { ValidationHelper.ToString(uriString) })); } return(result); }