Skip to content

Commit

Permalink
增加客户端面板验证;修复新增条目不reload;
Browse files Browse the repository at this point in the history
  • Loading branch information
Cp0204 committed Dec 30, 2021
1 parent dac3ce3 commit 7ce746b
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 35 deletions.
8 changes: 8 additions & 0 deletions FrpClient-Win/DB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class ServerInfo
public string strToken = "";
public string strUser = "";
public int nAdminPort = 7400;
public string strAdminUser = "admin";
public string strAdminPwd = "admin";
}

class ItemInfo
Expand Down Expand Up @@ -48,6 +50,8 @@ class DB
private const string strServerToken = "token";
private const string strServerUser = "user";
private const string strAdminPort = "admin_port";
private const string strAdminUser = "admin_user";
private const string strAdminPwd = "admin_pwd";

private const string strFrpType = "type";
private const string strLocalPort = "local_port";
Expand Down Expand Up @@ -84,6 +88,8 @@ public bool ReadConfig()
cServerinfo.strToken = GetValue(strCommon, strServerToken);
cServerinfo.strUser = GetValue(strCommon, strServerUser);
cServerinfo.nAdminPort = Convert.ToInt32(GetValue(strCommon, strAdminPort));
cServerinfo.strAdminUser = GetValue(strCommon, strAdminUser);
cServerinfo.strAdminPwd = GetValue(strCommon, strAdminPwd);

//读取各个项
string[] arrSections = GetSectionNames(strFileName);
Expand Down Expand Up @@ -189,6 +195,8 @@ public bool SaveConfig()
WritePrivateProfileString(strCommon, strServerUser, cServerinfo.strUser, strFileName);
if(cServerinfo.nAdminPort!=0)
WritePrivateProfileString(strCommon, strAdminPort, cServerinfo.nAdminPort.ToString(), strFileName);
WritePrivateProfileString(strCommon, strAdminUser, cServerinfo.strAdminUser, strFileName);
WritePrivateProfileString(strCommon, strAdminPwd, cServerinfo.strAdminPwd, strFileName);

//写各个项
foreach (var info in listItems)
Expand Down
39 changes: 22 additions & 17 deletions FrpClient-Win/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions FrpClient-Win/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ public partial class MainForm : Form

// 32位的MD5加密
public static string MD5Encrypt32(string password) {
string cl = password;
string pwd = "";
MD5 md5 = MD5.Create();
byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(cl));
byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(password));
for(int i = 0; i < s.Length; i++) {
pwd = pwd + s[i].ToString("x");
}
Expand Down Expand Up @@ -257,6 +256,7 @@ private void AddItem_Click(object sender, EventArgs e)

//关闭之后刷新界面
InitList();
ReloadFrp();
}

private void UpdateStartButton()
Expand Down
2 changes: 1 addition & 1 deletion FrpClient-Win/RdpConfigDlg.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 1 addition & 9 deletions FrpClient-Win/RdpConfigDlg.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FrpClient_Win
{
namespace FrpClient_Win {
public partial class RdpConfigDlg : Form
{

Expand Down
54 changes: 50 additions & 4 deletions FrpClient-Win/ServerConfigDlg.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions FrpClient-Win/ServerConfigDlg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ private void SaveServerConfig_Click(object sender, EventArgs e)
DB.Instance().cServerinfo.strToken = FrpToken.Text;
DB.Instance().cServerinfo.strUser = FrpUser.Text;
DB.Instance().cServerinfo.nAdminPort = Convert.ToInt32(FrpAdminPort.Text);
DB.Instance().cServerinfo.strAdminUser = FrpAdminUser.Text;
DB.Instance().cServerinfo.strAdminPwd = FrpAdminPwd.Text;

DB.Instance().SaveConfig();
Close();
Expand All @@ -36,14 +38,23 @@ private void OnConfigDlgLoad(object sender, EventArgs e)
FrpToken.Text = DB.Instance().cServerinfo.strToken;
FrpUser.Text = DB.Instance().cServerinfo.strUser;
FrpAdminPort.Text = DB.Instance().cServerinfo.nAdminPort.ToString();
FrpAdminUser.Text = DB.Instance().cServerinfo.strAdminUser;
FrpAdminPwd.Text = DB.Instance().cServerinfo.strAdminPwd;
if(DB.Instance().cServerinfo.nAdminPort > 0) {
FrpAdminPort.Enabled = FrpAdmin.Checked = true;
FrpAdminUser.Enabled = FrpAdminPwd.Enabled = FrpAdminPort.Enabled = FrpAdmin.Checked = true;
}
}

private void FrpAdmin_CheckedChanged(object sender, EventArgs e) {
FrpAdminPort.Enabled = FrpAdmin.Checked;
FrpAdminUser.Enabled = FrpAdminPwd.Enabled = FrpAdminPort.Enabled = FrpAdmin.Checked;
FrpAdminPort.Text = FrpAdmin.Checked ? "7400" : "0";
if(FrpAdminUser.Text == "") {
FrpAdminUser.Text = "admin";
}
if(FrpAdminPwd.Text == "") {
Random rd = new Random();
FrpAdminPwd.Text = "admin" + rd.Next(100000,999999).ToString();
}
}
}
}

0 comments on commit 7ce746b

Please sign in to comment.