예제 #1
0
        public void Start(string taskName, string overrideString = "")
        {
            switch (taskName)
            {
            case "install":
                Install();
                InstallOrUninstallRootCertificate(false);
                InstallOrUninstallRootCertificate(true);
                ProxyOverrider(overrideString);
                FirefoxCertificateManager.Install(this);
                Servicestarter.Start(this);
                SpellInstall.NspInstall.InstallNSP();
                break;

            case "uninstall":
                Uninstall();
                SpellInstall.NspInstall.UInstallNSP();
                break;

            case "enable":
                EnableOrDisableProxy(true);
                break;

            case "disable":
                EnableOrDisableProxy(false);
                break;

            case "recheck":
                FirefoxCertificateManager.Install(this);
                if (Util.ModifiyConnString == null)
                {
                    byte[] getConnString = GetDefaultConnSetting();
                    if (getConnString == null)
                    {
                        byte[] byteConnString = Util.DefaultConnString;
                        byteConnString = EditDefaultConnectionSettings.EditProxyOverride(byteConnString, string.Empty);
                        SetOrResetDialupSetting(true, byteConnString);
                    }
                    else
                    {
                        SetOrResetDialupSetting(true, getConnString);
                    }
                }
                else
                {
                    SetOrResetDialupSetting(true, Util.ModifiyConnString);
                }

                break;

            case "proxyoverride":
                ProxyOverrider(overrideString);
                break;

            default:
                break;
            }
        }
예제 #2
0
        private void SetOrResetProxy(bool isSet, string overrideString)
        {
            //Logger.Info("Enter");

            byte[] byteConnString = Util.DefaultConnString;

            byteConnString = EditDefaultConnectionSettings.EditProxyOverride(byteConnString, overrideString);

            EnableOrDisableProxy(isSet);

            SetOrResetDialupSetting(isSet, byteConnString);

            try
            {
                RegistryKey localKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64);
                localKey = localKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections", true);
                if (localKey != null)
                {
                    if (isSet)
                    {
                        localKey.SetValue("DefaultConnectionSettings", byteConnString);
                    }
                    else
                    {
                        localKey.DeleteValue("DefaultConnectionSettings");
                    }
                }
                localKey.Close();
            }
            catch (Exception ex)
            {
                //Logger.Error(ex);
            }

            try
            {
                RegistryKey localKey32 = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry32);
                localKey32 = localKey32.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections", true);
                if (localKey32 != null)
                {
                    if (isSet)
                    {
                        localKey32.SetValue("DefaultConnectionSettings", byteConnString);
                    }
                    else
                    {
                        localKey32.DeleteValue("DefaultConnectionSettings");
                    }
                }
                localKey32.Close();
            }
            catch (Exception ex)
            {
                //Logger.Error(ex);
            }

            // These lines implement the Interface in the beginning of program
            // They cause the OS to refresh the settings, causing IP to realy update
            InternetSetOption(IntPtr.Zero, INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0);
            InternetSetOption(IntPtr.Zero, INTERNET_OPTION_REFRESH, IntPtr.Zero, 0);
            Util.ModifiyConnString = byteConnString;

            //Logger.Info("Exit");
        }