public WinHTTPAutoProxy(bool bAutoDiscover, string sAutoConfigUrl) { this._bUseAutoDiscovery = bAutoDiscover; if (!string.IsNullOrEmpty(sAutoConfigUrl)) { this._sPACScriptLocation = sAutoConfigUrl; } this._oAPO = GetAutoProxyOptionsStruct(this._sPACScriptLocation, this._bUseAutoDiscovery); this._hSession = WinHTTPNative.WinHttpOpen("Fiddler", 1, IntPtr.Zero, IntPtr.Zero, 0); }
private static string GetWPADUrl() { IntPtr ptr; string str; bool flag = WinHTTPNative.WinHttpDetectAutoProxyConfigUrl(3, out ptr); if (!flag) { Marshal.GetLastWin32Error(); } if (flag && (IntPtr.Zero != ptr)) { str = Marshal.PtrToStringUni(ptr); } else { str = string.Empty; } Utilities.GlobalFreeIfNonZero(ptr); return(str); }
public WinHTTPAutoProxy(bool bAutoDiscover, string sAutoConfigUrl) { this._bUseAutoDiscovery = bAutoDiscover; if (!string.IsNullOrEmpty(sAutoConfigUrl)) { if (sAutoConfigUrl.OICStartsWith("file:") || sAutoConfigUrl.StartsWith("\\\\") || (sAutoConfigUrl.Length > 2 && sAutoConfigUrl[1] == ':')) { Proxy.sUpstreamPACScript = WinHTTPAutoProxy.GetPACFileText(sAutoConfigUrl); if (!string.IsNullOrEmpty(Proxy.sUpstreamPACScript)) { FiddlerApplication.Log.LogFormat("!WARNING: System proxy was configured to use a file-protocol sourced script ({0}). Proxy scripts delivered by the file protocol are not supported by many clients. Please see http://blogs.msdn.com/b/ieinternals/archive/2013/10/11/web-proxy-configuration-and-ie11-changes.aspx for more information.", new object[] { sAutoConfigUrl }); sAutoConfigUrl = "http://" + CONFIG.sFiddlerListenHostPort + "/UpstreamProxy.pac"; } } this._sPACScriptLocation = sAutoConfigUrl; } this._oAPO = WinHTTPAutoProxy.GetAutoProxyOptionsStruct(this._sPACScriptLocation, this._bUseAutoDiscovery); this._hSession = WinHTTPNative.WinHttpOpen("Fiddler", 1, IntPtr.Zero, IntPtr.Zero, 0); }
private static string GetWPADUrl() { IntPtr intPtr; bool flag; if (!(flag = WinHTTPNative.WinHttpDetectAutoProxyConfigUrl(3, out intPtr))) { Marshal.GetLastWin32Error(); } string result; if (flag && IntPtr.Zero != intPtr) { result = Marshal.PtrToStringUni(intPtr); } else { result = string.Empty; } Utilities.GlobalFreeIfNonZero(intPtr); return(result); }
public void Dispose() { WinHTTPNative.WinHttpCloseHandle(this._hSession); }
public bool GetAutoProxyForUrl(string sUrl, out IPEndPoint ipepResult) { int num = 0; WinHTTPNative.WINHTTP_PROXY_INFO wINHTTP_PROXY_INFO; bool flag; if (!(flag = WinHTTPNative.WinHttpGetProxyForUrl(this._hSession, sUrl, ref this._oAPO, out wINHTTP_PROXY_INFO))) { num = Marshal.GetLastWin32Error(); } if (flag) { if (IntPtr.Zero != wINHTTP_PROXY_INFO.lpszProxy) { string text = Marshal.PtrToStringUni(wINHTTP_PROXY_INFO.lpszProxy); ipepResult = Utilities.IPEndPointFromHostPortString(text); if (ipepResult == null) { FiddlerApplication.Log.LogFormat("Proxy Configuration Script specified an unreachable proxy: {0} for URL: {1}", new object[] { text, sUrl }); } } else { ipepResult = null; } Utilities.GlobalFreeIfNonZero(wINHTTP_PROXY_INFO.lpszProxy); Utilities.GlobalFreeIfNonZero(wINHTTP_PROXY_INFO.lpszProxyBypass); return(true); } int num2 = num; if (num2 <= 12015) { if (num2 == 12006) { FiddlerApplication._Log.LogString("Fiddler.Network.ProxyPAC> PAC Script download failure; Fiddler only supports HTTP/HTTPS for PAC script URLs."); goto IL_13D; } if (num2 == 12015) { FiddlerApplication._Log.LogString("Fiddler.Network.ProxyPAC> PAC Script download failure; you must set the AutoProxyLogon registry key to TRUE."); goto IL_13D; } } else { switch (num2) { case 12166: FiddlerApplication._Log.LogString("Fiddler.Network.ProxyPAC> PAC Script contents were not valid."); goto IL_13D; case 12167: FiddlerApplication._Log.LogString("Fiddler.Network.ProxyPAC> PAC Script download failed."); goto IL_13D; default: if (num2 == 12180) { FiddlerApplication._Log.LogString("Fiddler.Network.AutoProxy> AutoProxy Detection failed."); goto IL_13D; } break; } } FiddlerApplication._Log.LogString("Fiddler.Network.ProxyPAC> Proxy determination failed with error code: " + num); IL_13D: Utilities.GlobalFreeIfNonZero(wINHTTP_PROXY_INFO.lpszProxy); Utilities.GlobalFreeIfNonZero(wINHTTP_PROXY_INFO.lpszProxyBypass); ipepResult = null; return(false); }
public bool GetAutoProxyForUrl(string sUrl, out IPEndPoint ipepResult) { WinHTTPNative.WINHTTP_PROXY_INFO winhttp_proxy_info; int num = 0; bool flag = WinHTTPNative.WinHttpGetProxyForUrl(this._hSession, sUrl, ref this._oAPO, out winhttp_proxy_info); if (!flag) { num = Marshal.GetLastWin32Error(); } if (flag) { if (IntPtr.Zero != winhttp_proxy_info.lpszProxy) { string sHostAndPort = Marshal.PtrToStringUni(winhttp_proxy_info.lpszProxy); ipepResult = Utilities.IPEndPointFromHostPortString(sHostAndPort); if (ipepResult == null) { FiddlerApplication.Log.LogFormat("Proxy Configuration Script specified an unreachable proxy: {0} for URL: {1}", new object[] { sHostAndPort, sUrl }); } } else { ipepResult = null; } Utilities.GlobalFreeIfNonZero(winhttp_proxy_info.lpszProxy); Utilities.GlobalFreeIfNonZero(winhttp_proxy_info.lpszProxyBypass); return(true); } int num2 = num; if (num2 <= 0x2eef) { switch (num2) { case 0x2ee6: FiddlerApplication._Log.LogString("Fiddler.Network.ProxyPAC> PAC Script download failure; Fiddler only supports HTTP/HTTPS for PAC script URLs."); goto Label_013E; case 0x2eef: FiddlerApplication._Log.LogString("Fiddler.Network.ProxyPAC> PAC Script download failure; you must set the AutoProxyLogon registry key to TRUE."); goto Label_013E; } } else { switch (num2) { case 0x2f86: FiddlerApplication._Log.LogString("Fiddler.Network.ProxyPAC> PAC Script contents were not valid."); goto Label_013E; case 0x2f87: FiddlerApplication._Log.LogString("Fiddler.Network.ProxyPAC> PAC Script download failed."); goto Label_013E; default: if (num2 != 0x2f94) { goto Label_0124; } FiddlerApplication._Log.LogString("Fiddler.Network.AutoProxy> AutoProxy Detection failed."); goto Label_013E; } } Label_0124: FiddlerApplication._Log.LogString("Fiddler.Network.ProxyPAC> Proxy determination failed with error code: " + num); Label_013E: Utilities.GlobalFreeIfNonZero(winhttp_proxy_info.lpszProxy); Utilities.GlobalFreeIfNonZero(winhttp_proxy_info.lpszProxyBypass); ipepResult = null; return(false); }