Example #1
0
        private async void Button_Start_Click(object sender, EventArgs e)
        {
            string mtLogin    = textBox_MtLogin.Text.Trim();
            string mtPassword = textBox_mtPassword.Text;

            string ftpLogin;
            string ftpPassword;

            if (checkBox1.Checked)
            {
                ftpLogin    = textBox_ftpLogin.Text.Trim();
                ftpPassword = textBox_ftpPassword.Text;
            }
            else
            {
                ftpLogin    = mtLogin;
                ftpPassword = mtPassword;
            }

            var config = new Core.ConfigClass
            {
                MikroTikAddress    = textBox_MtAddress.Text.Trim(),
                MikroTikPort       = int.Parse(textBox_mtPort.Text),
                MikroTikLogin      = mtLogin,
                MikroTikPassword   = mtPassword,
                FtpLogin           = ftpLogin,
                FtpPassword        = ftpPassword,
                DomainName         = textBox_domainName.Text.Trim(),
                Email              = textBox_email.Text.Trim(),
                WanIface           = textBox_wan.Text.Trim(),
                Force              = checkBox_force.Checked,
                LetsEncryptAddress = (Core.LeUri)(Uri) comboBox_lec.SelectedValue,
                SaveFile           = checkBox_saveFile.Checked,
                UseAlpn            = radioButton_alpn.Checked,
            };

            var program = new Core.Program(config);

            //AllocConsole();
            //AttachConsole(ATTACH_PARENT_PROCESS);

            button_start.Enabled = false;
            groupBox_mt.Enabled  = false;
            groupBox_ftp.Enabled = false;
            textBox_wan.Enabled  = false;
            groupBox_lec.Enabled = false;
            richTextBox1.Clear();
            try
            {
                await Task.Run(() => program.RunAsync(logToFile: true, logSink: new InMemorySinkLog(this)));
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                button_start.Enabled = true;
                groupBox_mt.Enabled  = true;
                groupBox_ftp.Enabled = true;
                textBox_wan.Enabled  = true;
                groupBox_lec.Enabled = true;
                //FreeConsole();
            }
        }
        public int PublicPort => 80; // Не менять.

        public HttpChallenge(ConfigClass config, string keyAuthString)
        {
            _keyAuthString = keyAuthString;
            _listener      = new SimpleHttpListener(config.ThisMachineIp);
        }
Example #3
0
        public Program(ConfigClass config)
        {
            Config = config ?? throw new ArgumentNullException(nameof(config));

            mikrotikAddress = config.MikroTikAddress ?? throw new ArgumentOutOfRangeException(nameof(config), "Должен быть задан адрес микротика");
        }