diff --git a/Server/Forms/FrmSettings.cs b/Server/Forms/FrmSettings.cs index 50c9b867..f1fdd6c9 100644 --- a/Server/Forms/FrmSettings.cs +++ b/Server/Forms/FrmSettings.cs @@ -53,6 +53,7 @@ private ushort GetPortSafe() private void btnListen_Click(object sender, EventArgs e) { ushort port = GetPortSafe(); + string password = txtPassword.Text; if (port == 0) { @@ -61,14 +62,19 @@ private void btnListen_Click(object sender, EventArgs e) return; } - var newPassword = txtPassword.Text; - if (newPassword != Settings.Password) - AES.PreHashKey(newPassword); + 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; + } if (btnListen.Text == "Start listening" && !_listenServer.Listening) { try { + AES.PreHashKey(password); + if (chkUseUpnp.Checked) { if (!UPnP.IsDeviceFound) @@ -117,6 +123,7 @@ private void btnListen_Click(object sender, EventArgs e) private void btnSave_Click(object sender, EventArgs e) { ushort port = GetPortSafe(); + string password = txtPassword.Text; if (port == 0) { @@ -125,13 +132,19 @@ private void btnSave_Click(object sender, EventArgs e) 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.AutoListen = chkAutoListen.Checked; Settings.ShowPopup = chkPopup.Checked; - var newPassword = txtPassword.Text; - if (newPassword != Settings.Password) - AES.PreHashKey(newPassword); - Settings.Password = newPassword; + if (password != Settings.Password) + AES.PreHashKey(password); + Settings.Password = password; Settings.UseUPnP = chkUseUpnp.Checked; Settings.ShowToolTip = chkShowTooltip.Checked; Settings.EnableNoIPUpdater = chkNoIPIntegration.Checked;