示例#1
0
 private void button_Click(object sender, RoutedEventArgs e)
 {
     if (txtUsername.Text.Length < 1 || txtPassword.Password.Length < 1 || txtServer.Text.Length < 1 || txtLocal.Text.Length < 1 || txtRemote.Text.Length < 1 || txtDelay.Text.Length < 1)
     {
         lblWarn.Content = "Fill all fields!";
     }
     else
     {
         int local, remote, delay = 0;
         if (int.TryParse(txtLocal.Text, out local) && int.TryParse(txtRemote.Text, out remote) && int.TryParse(txtDelay.Text, out delay))
         {
             if (local >= 1024 && local <= 65535 && remote >= 1024 && remote <= 65535)
             {
                 Properties.Settings.Default.username     = txtUsername.Text;
                 Properties.Settings.Default.remoteServer = txtServer.Text;
                 Properties.Settings.Default.localPort    = local;
                 Properties.Settings.Default.remotePort   = remote;
                 Properties.Settings.Default.delay        = delay;
                 Properties.Settings.Default.password     = ObfuscatePW.EncryptString(txtPassword.SecurePassword);
                 this.DialogResult = true;
             }
             else
             {
                 lblWarn.Content = "Ports between 1024 and 65535";
             }
         }
         else
         {
             lblWarn.Content = "Local, remote, delay only numbers";
         }
     }
 }
示例#2
0
        public Settings()
        {
            InitializeComponent();

            txtUsername.Text     = Properties.Settings.Default.username;
            txtPassword.Password = ObfuscatePW.ToInsecureString(ObfuscatePW.DecryptString(Properties.Settings.Default.password));
            txtServer.Text       = Properties.Settings.Default.remoteServer;
            txtLocal.Text        = Properties.Settings.Default.localPort.ToString();
            txtRemote.Text       = Properties.Settings.Default.remotePort.ToString();
            txtDelay.Text        = Properties.Settings.Default.delay.ToString();
        }
示例#3
0
 private void btnOK_Click(object sender, RoutedEventArgs e)
 {
     if (txtUsername.Text.Length < 1 || txtPassword.Password.Length < 1)
     {
         lblWarn.Content = "FILL ALL FIELDS!";
     }
     else
     {
         Properties.Settings.Default.username = txtUsername.Text;
         Properties.Settings.Default.password = ObfuscatePW.EncryptString(txtPassword.SecurePassword);
         this.DialogResult = true;
     }
 }
示例#4
0
 private bool LoginSendPacket(string packet)
 {
     if (sessionKey == string.Empty)
     {
         // Login if not logged in yet
         WriteLog("LOGIN...");
         string s = $"AUTH user={Properties.Settings.Default.username}&pass={ObfuscatePW.ToInsecureString(ObfuscatePW.DecryptString(Properties.Settings.Default.password))}&protover=3&client=lxanidb&clientver=2";
         if (!SendPacket(s))
         {
             return(false);
         }
         logoutTimer.Start();
     }
     return(SendPacket($"{packet}&s={sessionKey}"));
 }