Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
eebssk1 committed Jul 4, 2024
1 parent 9e3f03c commit 5daa2a2
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 35 deletions.
2 changes: 1 addition & 1 deletion InitTh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ internal void Do()
MiscData.haveExe = false;
}
}
if(MiscData.haveExe)
if (MiscData.haveExe)
{
MD5 md5 = MD5.Create();
var ehash = md5.ComputeHash(Properties.Resources.n2n_edge);
Expand Down
46 changes: 36 additions & 10 deletions Main.Designer.cs

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

16 changes: 12 additions & 4 deletions Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,29 @@ public GUI()
LblMDis.Text = "MTU探测";
Lblbroa.Text = "接受多播";
LblHeaderEn.Text = "加密头部";
LblNickname.Text = "昵称";
LblNickname.Text = "昵称(必须英文)";
LblTap.Text = "TAP网卡";
LblFwd.Text = "启用路由";
LblMt.Text = "设置跳数";
BtnStart.Text = "启动!";
BtnInsTAP.Text = "安装TAP";
BtnPer.Text = "显示对等方";
BtnAbout.Text = "关于";
BtnWd.Text = "打开工作文件夹";
CboxBroa.Text = StringRes.GetString(StringRes.StringT.Enable);
CboxHeaderEn.Text = StringRes.GetString(StringRes.StringT.Enable);
CboxMD.Text = StringRes.GetString(StringRes.StringT.Enable);
CboxRt.Text = StringRes.GetString(StringRes.StringT.Enable);
CboxMt.Text = StringRes.GetString(StringRes.StringT.Enable);
CboxTap.DataSource = MiscData.TAPs.ToList();
CboxTap.DisplayMember = "Value";
CboxTap.ValueMember = "Key";
}
}

private void GUI_Load(object sender, System.EventArgs e)
{
LblVersion.Text = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
CboxTap.DataSource = MiscData.TAPs.ToList();
CboxTap.DisplayMember = "Value";
CboxTap.ValueMember = "Key";
peerForm = new PeerForm();
if (!MiscData.haveExe) BtnStart.Enabled = false;
if (!MiscData.isAdmin) BtnInsTAP.Enabled = false;
Expand Down Expand Up @@ -206,6 +208,7 @@ await Task.Run(() =>
else
{
e.Cancel = true;
return;
}
}
closed = true;
Expand Down Expand Up @@ -442,5 +445,10 @@ private void BtnAbout_Click(object sender, EventArgs e)
"Inbuilt N2N exe md5 hash: " + MiscData.inbuiltN2NHash;
MessageBox.Show(s, "About");
}

private void LblWd_Click(object sender, EventArgs e)
{
Process.Start("explorer.exe", MiscData.PWD);
}
}
}
26 changes: 18 additions & 8 deletions N2NHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ internal class N2NHandler
internal int trycount = 0;
private bool needworkdelay = false;
private Thread workThread;
private long pUP = 0;
private long pDN = 0;
private N2NHandler(GUI i)
{
Instance = this;
Expand Down Expand Up @@ -95,12 +97,17 @@ internal void Stop()
Thread.Sleep(80);
}
timeout += 1;
if (timeout >= 185)
if (timeout >= 160)
{
timeout = 0;
i.UpdateTxtBox("Too long... Request exit again...");
GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);
}
else if (timeout > 250)
{
i.UpdateTxtBox("Too long WTF... Kill!..");
process.Kill();
}
}
}
finally
Expand Down Expand Up @@ -152,6 +159,9 @@ internal void Do()
process.OutputDataReceived += addtxt;
process.ErrorDataReceived += addtxt;
process.Exited += handleExit;
var Int = NetworkInterface.GetAllNetworkInterfaces().SingleOrDefault(x => x.Id == MiscData.currentTAP.Id);
pDN = Int.GetIPStatistics().BytesReceived / 1024;
pUP = Int.GetIPStatistics().BytesSent / 1024;
process.Start();
PID = process.Id;
process.BeginOutputReadLine();
Expand All @@ -171,11 +181,11 @@ private void WorkTick()
{
if (Thread.Yield())
{
Thread.Sleep(50);
Thread.Sleep(70);
}
else
{
Thread.Sleep(100);
Thread.Sleep(120);
}
continue;
};
Expand All @@ -184,20 +194,20 @@ private void WorkTick()
needworkdelay = false;
if (Thread.Yield())
{
Thread.Sleep(1250);
Thread.Sleep(1300);
}
else
{
Thread.Sleep(1500);
Thread.Sleep(1600);
}
}
NetworkInterface Int = null;
if (i.WindowState != FormWindowState.Minimized)
{
Int = NetworkInterface.GetAllNetworkInterfaces().SingleOrDefault(x => x.Id == MiscData.currentTAP.Id);
var d = Int.GetIPStatistics().BytesReceived / 1024;
var u = Int.GetIPStatistics().BytesSent / 1024;
i.UpdateLabel(i.LblUD, "Up: " + u + Environment.NewLine + "Down: " + d);
var DN = Int.GetIPStatistics().BytesReceived / 1024;
var UP = Int.GetIPStatistics().BytesSent / 1024;
i.UpdateLabel(i.LblUD, "Up: " + (UP - pUP) + Environment.NewLine + "Down: " + (DN - pDN));
}
if (MiscData.isAdmin && !(trycount > 50))
{
Expand Down
11 changes: 5 additions & 6 deletions PeerForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ private void PeerForm_Load(object sender, EventArgs e)
table.PrimaryKey = null;
table.Columns.AddRange(cls);
source.DataSource = table;
dataGridView1.DataSource = source;
Action act = () => { dataGridView1.DataSource = source; };
dataGridView1.Invoke(act);
Thread t = new Thread(Do);
t.IsBackground = true;
t.Priority = ThreadPriority.BelowNormal;
Expand Down Expand Up @@ -158,19 +159,17 @@ private void Do()
{
foreach (DataRow dr in table.Rows)
{
if ((string)dr["Nick"] == d.Value<string>("desc"))
if (((string)dr["Nick"]).Equals(d.Value<string>("desc")))
{
Action act = () => { table.Rows.Remove(dr); };
dataGridView1.Invoke(act);
break;
}
}
}
table.Rows.Add(r);
}
Action act1 = () => { source.ResetBindings(false); };
if (table.Rows.Count != 0)
Action act1 = () => { table.Rows.Add(r); };
dataGridView1.Invoke(act1);
}
Thread.Yield();
Thread.Sleep(2550);
}
Expand Down
4 changes: 2 additions & 2 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ static void Main()
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
Application.ThreadException += handleException;
AppDomain.CurrentDomain.UnhandledException += handleException;
Application.ThreadException += handleException;
AppDomain.CurrentDomain.UnhandledException += handleException;
Directory.SetCurrentDirectory(MiscData.PWD);
Application.Run(new Spla());
if (!MiscData.isSplashExitAbornomal)
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.1.2")]
[assembly: AssemblyFileVersion("1.0.1.2")]
[assembly: AssemblyVersion("1.0.2.1")]
[assembly: AssemblyFileVersion("1.0.2.1")]
4 changes: 2 additions & 2 deletions StringRes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ private static void InitString()
"This will make your computer trust EBK's unsecure Digital Signature!";
lower0[StringT.ITDone] = "安装完成。请重新启动程序。";
lower1[StringT.ITDone] = "Install Done. Pls restarted the program.";
lower0[StringT.NEnotMatch] = "n2n可执行文件与内嵌版本哈希不匹配!你可能正在使用旧(新?)版或自定义n2n文件!";
lower1[StringT.NEnotMatch] = "N2N exe Hash does not match with the inbuilt one! You are probably using a old(new?) or custom one!";
lower0[StringT.NEnotMatch] = "n2n可执行文件与内嵌版本哈希不匹配!你可能正在使用旧(新?)版或自定义n2n文件!" + Environment.NewLine + "你可以打开工作文件夹删除n2n文件后重新打开程序以重新释放。";
lower1[StringT.NEnotMatch] = "N2N exe Hash does not match with the inbuilt one! You are probably using a old(new?) or custom one!" + Environment.NewLine + "You can open the working directory to delete the n2n file. Then restart the application to release file again.";
}
}
}

0 comments on commit 5daa2a2

Please sign in to comment.