public WinINETConnectoids() { string[] connectionNames = RASInfo.GetConnectionNames(); string[] array = connectionNames; for (int i = 0; i < array.Length; i++) { string text = array[i]; if (CONFIG.bDebugSpew) { FiddlerApplication.DebugSpew("Collecting information for Connectoid '{0}'", new object[] { text }); } if (!this._oConnectoids.ContainsKey(text)) { try { WinINETProxyInfo winINETProxyInfo = WinINETProxyInfo.CreateFromNamedConnection(text); if (winINETProxyInfo == null) { FiddlerApplication.Log.LogFormat("!WARNING: Failed to get proxy information for Connection '{0}'.", new object[] { text }); } else { WinINETConnectoid winINETConnectoid = new WinINETConnectoid(); winINETConnectoid.sConnectionName = text; if (!string.IsNullOrEmpty(winINETProxyInfo.sHttpProxy) && winINETProxyInfo.sHttpProxy.Contains(CONFIG.sFiddlerListenHostPort)) { FiddlerApplication.Log.LogString("When connecting, upstream proxy settings were already pointed at Fiddler. Clearing upstream proxy."); winINETProxyInfo.sHttpProxy = (winINETProxyInfo.sHttpsProxy = (winINETProxyInfo.sFtpProxy = null)); winINETProxyInfo.bUseManualProxies = false; winINETProxyInfo.bAllowDirect = true; } if (!string.IsNullOrEmpty(winINETProxyInfo.sPACScriptLocation) && (winINETProxyInfo.sPACScriptLocation == "file://" + CONFIG.GetPath("Pac") || winINETProxyInfo.sPACScriptLocation == "http://" + CONFIG.sFiddlerListenHostPort + "/proxy.pac")) { FiddlerApplication.Log.LogString("When connecting, upstream proxy script was already pointed at Fiddler. Clearing upstream proxy."); winINETProxyInfo.sPACScriptLocation = null; } winINETConnectoid.oOriginalProxyInfo = winINETProxyInfo; this._oConnectoids.Add(text, winINETConnectoid); } } catch (Exception eX) { FiddlerApplication.Log.LogFormat("!WARNING: Failed to get proxy information for Connection '{0}' due to {1}", new object[] { text, Utilities.DescribeException(eX) }); } } } }
private static string GetConnectedState() { RASInfo.InternetConnectionState internetConnectionState = (RASInfo.InternetConnectionState) 0; if (RASInfo.InternetGetConnectedState(ref internetConnectionState, 0)) { return("CONNECTED (" + internetConnectionState.ToString() + ")"); } return("NOT_CONNECTED (" + internetConnectionState.ToString() + ")"); }
public WinINETConnectoids() { foreach (string str in RASInfo.GetConnectionNames()) { if (!this._oConnectoids.ContainsKey(str)) { WinINETProxyInfo info = WinINETProxyInfo.CreateFromNamedConnection(str); if (info != null) { WinINETConnectoid connectoid = new WinINETConnectoid { sConnectionName = str }; if ((info.sHttpProxy != null) && info.sHttpProxy.Contains(CONFIG.sFiddlerListenHostPort)) { info.sHttpProxy = info.sHttpsProxy = (string)(info.sFtpProxy = null); info.bUseManualProxies = false; info.bAllowDirect = true; } connectoid.oOriginalProxyInfo = info; this._oConnectoids.Add(str, connectoid); } } } }
internal static string[] GetConnectionNames() { if (CONFIG.bDebugSpew) { FiddlerApplication.DebugSpew("WinINET indicates connectivity is via: " + RASInfo.GetConnectedState()); } string[] result; try { int dwSize = Marshal.SizeOf(typeof(RASInfo.RASENTRYNAME)); int num = 0; uint num2; if (Environment.OSVersion.Version.Major < 6) { RASInfo.RASENTRYNAME[] array = new RASInfo.RASENTRYNAME[1]; array[0].dwSize = dwSize; num2 = RASInfo.RasEnumEntries(IntPtr.Zero, IntPtr.Zero, array, ref dwSize, ref num); } else { num2 = RASInfo.RasEnumEntries(IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, ref dwSize, ref num); } if (num2 != 0u && 603u != num2) { FiddlerApplication.Log.LogFormat("! WARNING: RasEnumEntries failed (0x{0:x}). Ignoring non-LAN Connectoids. ", new object[] { num2 }); num = 0; } string[] array2 = new string[num + 1]; array2[0] = "DefaultLAN"; if (num == 0) { result = array2; } else { RASInfo.RASENTRYNAME[] array = new RASInfo.RASENTRYNAME[num]; for (int i = 0; i < num; i++) { array[i].dwSize = Marshal.SizeOf(typeof(RASInfo.RASENTRYNAME)); } num2 = RASInfo.RasEnumEntries(IntPtr.Zero, IntPtr.Zero, array, ref dwSize, ref num); if (num2 != 0u) { FiddlerApplication.Log.LogFormat("! WARNING: RasEnumEntries failed (0x{0:x}). Ignoring non-LAN Connectoids. ", new object[] { num2 }); result = new string[] { "DefaultLAN" }; } else { for (int j = 0; j < num; j++) { array2[j + 1] = array[j].szEntryName; } result = array2; } } } catch (Exception eX) { FiddlerApplication.Log.LogFormat("! WARNING: Enumerating connections failed. Ignoring non-LAN Connectoids.\n{0}", new object[] { Utilities.DescribeException(eX) }); result = new string[] { "DefaultLAN" }; } return(result); }