Fixed pre-hashing of password when starting to listen

This commit is contained in:
MaxXor 2015-08-27 22:59:53 +02:00
parent a9e8eca086
commit f516d6010f
1 changed files with 20 additions and 7 deletions

View File

@ -53,6 +53,7 @@ private ushort GetPortSafe()
private void btnListen_Click(object sender, EventArgs e) private void btnListen_Click(object sender, EventArgs e)
{ {
ushort port = GetPortSafe(); ushort port = GetPortSafe();
string password = txtPassword.Text;
if (port == 0) if (port == 0)
{ {
@ -61,14 +62,19 @@ private void btnListen_Click(object sender, EventArgs e)
return; return;
} }
var newPassword = txtPassword.Text; if (password.Length < 3)
if (newPassword != Settings.Password) {
AES.PreHashKey(newPassword); MessageBox.Show("Please enter a secure password with more than 3 characters.",
"Please enter a secure password", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (btnListen.Text == "Start listening" && !_listenServer.Listening) if (btnListen.Text == "Start listening" && !_listenServer.Listening)
{ {
try try
{ {
AES.PreHashKey(password);
if (chkUseUpnp.Checked) if (chkUseUpnp.Checked)
{ {
if (!UPnP.IsDeviceFound) if (!UPnP.IsDeviceFound)
@ -117,6 +123,7 @@ private void btnListen_Click(object sender, EventArgs e)
private void btnSave_Click(object sender, EventArgs e) private void btnSave_Click(object sender, EventArgs e)
{ {
ushort port = GetPortSafe(); ushort port = GetPortSafe();
string password = txtPassword.Text;
if (port == 0) if (port == 0)
{ {
@ -125,13 +132,19 @@ private void btnSave_Click(object sender, EventArgs e)
return; return;
} }
if (password.Length < 3)
{
MessageBox.Show("Please enter a secure password with more than 3 characters.",
"Please enter a secure password", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
Settings.ListenPort = port; Settings.ListenPort = port;
Settings.AutoListen = chkAutoListen.Checked; Settings.AutoListen = chkAutoListen.Checked;
Settings.ShowPopup = chkPopup.Checked; Settings.ShowPopup = chkPopup.Checked;
var newPassword = txtPassword.Text; if (password != Settings.Password)
if (newPassword != Settings.Password) AES.PreHashKey(password);
AES.PreHashKey(newPassword); Settings.Password = password;
Settings.Password = newPassword;
Settings.UseUPnP = chkUseUpnp.Checked; Settings.UseUPnP = chkUseUpnp.Checked;
Settings.ShowToolTip = chkShowTooltip.Checked; Settings.ShowToolTip = chkShowTooltip.Checked;
Settings.EnableNoIPUpdater = chkNoIPIntegration.Checked; Settings.EnableNoIPUpdater = chkNoIPIntegration.Checked;