Пример #1
0
 internal bool Attach(bool bCollectGWInfo)
 {
     if (!this._bIsAttached)
     {
         if (bCollectGWInfo)
         {
             this.CollectConnectoidAndGatewayInfo();
         }
         WinINETProxyInfo oNewInfo = new WinINETProxyInfo();
         oNewInfo.bUseManualProxies = true;
         oNewInfo.bAllowDirect      = true;
         oNewInfo.sHttpProxy        = KPCONFIG.sKProxyListenHostPort;
         if (KPCONFIG.bCaptureCONNECT)
         {
             oNewInfo.sHttpsProxy = KPCONFIG.sKProxyListenHostPort;
         }
         else if (this.piPrior != null)
         {
             oNewInfo.sHttpsProxy = this.piPrior.sHttpsProxy;
         }
         if ((this.piPrior != null) && this.piPrior.bUseManualProxies)
         {
             oNewInfo.sFtpProxy   = this.piPrior.sFtpProxy;
             oNewInfo.sSocksProxy = this.piPrior.sSocksProxy;
         }
         if (KPCONFIG.bCaptureFTP)
         {
             oNewInfo.sFtpProxy = KPCONFIG.sKProxyListenHostPort;
         }
         oNewInfo.sHostsThatBypass = KPCONFIG.sHostsThatBypassKProxy;
         if (KPCONFIG.bHookWithPAC)
         {
             if (KProxyApplication.Prefs.GetBoolPref("KProxy.proxy.pacfile.usefileprotocol", true))
             {
                 oNewInfo.sPACScriptLocation = "file://" + KPCONFIG.GetPath("Pac");
             }
             else
             {
                 oNewInfo.sPACScriptLocation = "http://" + KPCONFIG.sKProxyListenHostPort + "/proxy.pac";
             }
         }
         if (!KPCONFIG.bIsViewOnly)
         {
             if (this.oAllConnectoids.HookConnections(oNewInfo))
             {
                 this._bIsAttached = true;
                 KProxyApplication.OnKProxyAttach();
                 this.WriteAutoProxyPACFile(true);
             }
             else
             {
                 KProxyApplication.DoNotifyUser("Failed to register KProxy as the system proxy.", "Error");
                 _setDynamicRegistryKey(false);
                 return(false);
             }
             _setDynamicRegistryKey(true);
         }
     }
     return(true);
 }
Пример #2
0
 internal void CollectConnectoidAndGatewayInfo()
 {
     this.oAllConnectoids = new WinINETConnectoids();
     this.piPrior         = this.oAllConnectoids.GetDefaultConnectionGatewayInfo();
     if (KPCONFIG.bForwardToGateway && ((this.piPrior.sPACScriptLocation != null) || this.piPrior.bAutoDetect))
     {
         this.oAutoProxy = new WinHTTPAutoProxy(this.piPrior.bAutoDetect, this.piPrior.sPACScriptLocation);
     }
     else if (this.oAutoProxy != null)
     {
         this.oAutoProxy.Dispose();
         this.oAutoProxy = null;
     }
     if (KPCONFIG.bForwardToGateway && this.piPrior.bUseManualProxies)
     {
         this._DetermineGatewayIPEndPoints();
         if (string.IsNullOrEmpty(this.piPrior.sHostsThatBypass))
         {
             this.oBypassList = null;
         }
         else
         {
             this.oBypassList = new ProxyBypassList(this.piPrior.sHostsThatBypass);
             if (!this.oBypassList.HasEntries)
             {
                 this.oBypassList = null;
             }
         }
     }
     else
     {
         this._ipepFtpGateway = this._ipepHttpGateway = (IPEndPoint)(this._ipepHttpsGateway = null);
         this.oBypassList     = null;
     }
 }
Пример #3
0
        public static WinINETProxyInfo CreateFromNamedConnection(string sConnectionName)
        {
            WinINETProxyInfo info = new WinINETProxyInfo();

            if (info.GetFromWinINET(sConnectionName))
            {
                return(info);
            }
            return(null);
        }
Пример #4
0
        internal bool HookConnections(WinINETProxyInfo oNewInfo)
        {
            if (KPCONFIG.bIsViewOnly)
            {
                return(false);
            }
            bool flag = false;

            foreach (WinINETConnectoid connectoid in this._oConnectoids.Values)
            {
                if ((KPCONFIG.bHookAllConnections || (connectoid.sConnectionName == KPCONFIG.sHookConnectionNamed)) && oNewInfo.SetToWinINET(connectoid.sConnectionName))
                {
                    flag = true;
                    connectoid.bIsHooked = true;
                }
            }
            return(flag);
        }
Пример #5
0
 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();
                 connectoid.sConnectionName = str;
                 if ((info.sHttpProxy != null) && info.sHttpProxy.Contains(KPCONFIG.sKProxyListenHostPort))
                 {
                     info.sHttpProxy        = info.sHttpsProxy = (string)(info.sFtpProxy = null);
                     info.bUseManualProxies = false;
                     info.bAllowDirect      = true;
                 }
                 connectoid.oOriginalProxyInfo = info;
                 this._oConnectoids.Add(str, connectoid);
             }
         }
     }
 }