예제 #1
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            var type    = ProxyTypeComboBox.SelectedIndex;
            var proxy   = ProxyServerTextBox.Text;
            var port    = 0;
            var timeout = 3;

            if (UseProxyCheckBox.Checked)
            {
                try
                {
                    port = int.Parse(ProxyPortTextBox.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show(I18N.GetString("Illegal port number format"));
                    ProxyPortTextBox.Clear();
                    return;
                }

                try
                {
                    timeout = int.Parse(ProxyTimeoutTextBox.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show(I18N.GetString("Illegal timeout format"));
                    ProxyTimeoutTextBox.Clear();
                    return;
                }

                try
                {
                    Configuration.CheckServer(proxy);
                    Configuration.CheckPort(port);
                    Configuration.CheckTimeout(timeout, ProxyConfig.MaxProxyTimeoutSec);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }

                controller.EnableProxy(type, proxy, port);
            }
            else
            {
                controller.DisableProxy();
            }

            _modifiedConfiguration.useProxy     = UseProxyCheckBox.Checked;
            _modifiedConfiguration.proxyType    = type;
            _modifiedConfiguration.proxyServer  = proxy;
            _modifiedConfiguration.proxyPort    = port;
            _modifiedConfiguration.proxyTimeout = timeout;
            controller.SaveProxyConfig(_modifiedConfiguration);

            this.Close();
        }
 private void UpdateEnabled()
 {
     if (UseProxyCheckBox.Checked)
     {
         ProxyServerTextBox.Enabled = true;
         ProxyPortTextBox.Enabled   = true;
     }
     else
     {
         ProxyServerTextBox.Clear();
         ProxyPortTextBox.Clear();
         ProxyServerTextBox.Enabled = false;
         ProxyPortTextBox.Enabled   = false;
     }
 }
예제 #3
0
        private void InitializeDataBindings()
        {
            ProxyTypeComboBox.DataBindings.Clear();
            HttpProxyHostTextBox.DataBindings.Clear();
            ProxyPortTextBox.DataBindings.Clear();
            HttpProxyUsernameTextBox.DataBindings.Clear();
            HttpProxyPasswordTextBox.DataBindings.Clear();

            if (_httpProxySettings == null)
            {
                return;
            }

            ProxyTypeComboBox.SetSelectedItemDataBinding(_httpProxySettings, nameof(_httpProxySettings.ProxyMode));
            HttpProxyHostTextBox.SetTextDataBinding(_httpProxySettings, nameof(_httpProxySettings.ProxyHost));
            ProxyPortTextBox.SetTextDataBinding(_httpProxySettings, nameof(_httpProxySettings.ProxyPort));
            HttpProxyUsernameTextBox.SetTextDataBinding(_httpProxySettings, nameof(_httpProxySettings.UserName));
            HttpProxyPasswordTextBox.SetTextDataBinding(_httpProxySettings, nameof(_httpProxySettings.Password));
        }
        private void OKLinkLabel_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            if (0 == HostnameComboBox.Text.Length)
            {
                MessageBox.Show("Please enter a hostname.", "Missing information");
                HostnameComboBox.Focus();
            }
            else if (0 == PortTextBox.Text.Length)
            {
                MessageBox.Show("Please enter a port.", "Missing information");
                PortTextBox.Text = "443";
                PortTextBox.Focus();
            }
            else if (0 == EndpointTextBox.Text.Length)
            {
                MessageBox.Show("Please enter a endpoint (default of /iControl/iControlPortal.cgi).", "Missing information");
                EndpointTextBox.Text = "/iControl/iControlPortal.cgi";
                EndpointTextBox.Focus();
            }
            else if (0 == UsernameTextBox.Text.Length)
            {
                MessageBox.Show("Please enter a username.", "Missing information");
                UsernameTextBox.Focus();
            }
            else if (0 == PasswordTextBox.Text.Length)
            {
                MessageBox.Show("Please enter a password.", "Missing information");
                PasswordTextBox.Focus();
            }
            else if (UseProxyCheckBox.Checked && (ProxyAddressTextBox.Text.Length == 0))
            {
                MessageBox.Show("If you are using a proxy server, please specify the address");
                ProxyAddressTextBox.Focus();
            }
            else if (UseProxyCheckBox.Checked && (ProxyPortTextBox.Text.Length == 0))
            {
                MessageBox.Show("If you are using a proxy server, please specify the port");
                ProxyPortTextBox.Focus();
            }
            else
            {
                bool bInitialized = false;
                Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

                m_ci.setEndpoint(HostnameComboBox.Text, Convert.ToInt32(PortTextBox.Text), EndpointTextBox.Text);
                m_ci.setCredentials(UsernameTextBox.Text, PasswordTextBox.Text);

                // Now verify if we can connect to the host
                if (null == m_interfaces)
                {
                    m_interfaces = new iControl.Interfaces();
                }

                if (UseProxyCheckBox.Checked)
                {
                    bInitialized = m_interfaces.initialize(HostnameComboBox.Text, Convert.ToUInt32(PortTextBox.Text), UsernameTextBox.Text, PasswordTextBox.Text, ProxyAddressTextBox.Text, Convert.ToInt32(ProxyPortTextBox.Text), ProxyUserTextBox.Text, ProxyPassTextBox.Text, m_ci.useHttps);
                }
                else
                {
                    bInitialized = m_interfaces.initialize(HostnameComboBox.Text, Convert.ToUInt32(PortTextBox.Text), UsernameTextBox.Text, PasswordTextBox.Text, m_ci.useHttps);
                }

                if (bInitialized)
                {
                    try
                    {
                        //sysInfo.Url = m_ci.buildURL();
                        iControl.SystemProductInformation prodInfo = m_interfaces.SystemSystemInfo.get_product_information();
                        if (null != prodInfo.product_code)
                        {
                            m_ci.setHostType(prodInfo.product_code);
                        }

                        // Check for GTM Support
                        bool bGTMLicensed = false;
                        for (int i = 0; i < prodInfo.product_features.Length; i++)
                        {
                            if (prodInfo.product_features[i].Equals("GTM Rules"))
                            {
                                bGTMLicensed = true;
                                break;
                            }
                        }
                        m_ci.setGTMLicensed(bGTMLicensed);

                        //sysInfo.Dispose();
                        Cursor.Current    = System.Windows.Forms.Cursors.Default;
                        this.DialogResult = DialogResult.OK;

                        // Update proxy info in connection info class
                        if (UseProxyCheckBox.Checked)
                        {
                            m_ci.setWebProxy(ProxyAddressTextBox.Text, Convert.ToInt32(ProxyPortTextBox.Text),
                                             ProxyUserTextBox.Text, ProxyPortTextBox.Text);
                        }

                        if (SaveConfigCheckBox.Checked)
                        {
                            m_ci.saveToRegistry(HostnameComboBox.Text);
                        }

                        if (UseProxyCheckBox.Checked)
                        {
                            m_ci.setWebProxy(ProxyAddressTextBox.Text, Convert.ToInt32(ProxyPortTextBox.Text), ProxyUserTextBox.Text, ProxyPassTextBox.Text);
                        }

                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    catch (System.Net.WebException)
                    {
                        MessageBox.Show(this, "Connection could not be established to specified host", "Error");
                    }
                    catch (System.UriFormatException)
                    {
                        MessageBox.Show(this, "Connection could not be established to specified host", "Error");
                    }
                }
                else
                {
                    MessageBox.Show(this, "Invalid Connection Information...", "Error");
                }

                //sysInfo.Dispose();
                Cursor.Current = System.Windows.Forms.Cursors.Default;
            }
        }
예제 #5
0
        private void AccountListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (AccountListView.SelectedItem == null)
            {
                return;
            }
            string accountName = AccountListView.SelectedItem.ToString();

            lock (_bot)
            {
                if (_bot.AccountManager.Accounts.ContainsKey(accountName))
                {
                    Account account = _bot.AccountManager.Accounts[accountName];
                    UsernameTextBox.Text = account.Name;
                    if (account.Password == null)
                    {
                        PasswordTextBox.Clear();
                    }
                    else
                    {
                        PasswordTextBox.Password = account.Password;
                    }
                    if (account.Server == "YELLOW")
                    {
                        ServerComboBox.SelectedIndex = 2;
                    }
                    else if (account.Server == "BLUE")
                    {
                        ServerComboBox.SelectedIndex = 1;
                    }
                    else
                    {
                        ServerComboBox.SelectedIndex = 0;
                    }
                    if (account.MacAddress != null)
                    {
                        MacRandomCheckBox.IsChecked = false;
                        MacAddressTextBox.Text      = account.MacAddress;
                    }
                    else
                    {
                        MacRandomCheckBox.IsChecked = true;
                    }
                    if (account.Socks.Version != SocksVersion.None || account.Socks.Username != null || account.Socks.Password != null ||
                        account.Socks.Host != null || account.Socks.Port != -1)
                    {
                        ProxyCheckBox.IsChecked = true;
                    }
                    else
                    {
                        ProxyCheckBox.IsChecked = false;
                    }
                    if (account.Socks.Version == SocksVersion.Socks4)
                    {
                        ProxyVersion = 4;
                    }
                    else if (account.Socks.Version == SocksVersion.Socks5)
                    {
                        ProxyVersion = 5;
                    }
                    if (account.Socks.Host == null)
                    {
                        ProxyHostTextBox.Clear();
                    }
                    else
                    {
                        ProxyHostTextBox.Text = account.Socks.Host;
                    }
                    if (account.Socks.Port == -1)
                    {
                        ProxyPortTextBox.Clear();
                    }
                    else
                    {
                        ProxyPortTextBox.Text = account.Socks.Port.ToString();
                    }
                    if (account.Socks.Username != null || account.Socks.Password != null)
                    {
                        AnonymousCheckBox.IsChecked = false;
                    }
                    else
                    {
                        AnonymousCheckBox.IsChecked = true;
                    }
                    if (account.Socks.Username == null)
                    {
                        ProxyUsernameTextBox.Clear();
                    }
                    else
                    {
                        ProxyUsernameTextBox.Text = account.Socks.Username;
                    }
                    if (account.Socks.Password == null)
                    {
                        ProxyPasswordTextBox.Clear();
                    }
                    else
                    {
                        ProxyPasswordTextBox.Password = account.Socks.Password;
                    }
                }
            }
        }