mirror of
https://github.com/netchx/netch.git
synced 2026-03-14 17:43:18 +08:00
:sparkles:添加修改订阅链接及备注功能
:bug:修复错误的Base64Url加解密 :bug:修复其他bug
This commit is contained in:
@@ -26,7 +26,7 @@ namespace Netch.Controllers
|
||||
|
||||
public const string Name = @"Netch";
|
||||
public const string Copyright = @"Copyright © 2019 - 2020";
|
||||
public const string Version = @"1.4.2";
|
||||
public const string Version = @"1.4.2.2";
|
||||
|
||||
public async void Check(bool notifyNoFound, bool isPreRelease)
|
||||
{
|
||||
|
||||
@@ -95,10 +95,16 @@ namespace Netch.Forms
|
||||
|
||||
public void TestServer()
|
||||
{
|
||||
Parallel.ForEach(Global.Settings.Server, new ParallelOptions { MaxDegreeOfParallelism = 16 }, server =>
|
||||
try
|
||||
{
|
||||
server.Test();
|
||||
});
|
||||
Parallel.ForEach(Global.Settings.Server, new ParallelOptions { MaxDegreeOfParallelism = 16 }, server =>
|
||||
{
|
||||
server.Test();
|
||||
});
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void InitServer()
|
||||
@@ -502,6 +508,9 @@ namespace Netch.Forms
|
||||
|
||||
private void UpdateServersFromSubscribeLinksToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Global.Settings.UseProxyToUpdateSubscription && ServerComboBox.SelectedIndex == -1)
|
||||
Global.Settings.UseProxyToUpdateSubscription = false;
|
||||
|
||||
if (Global.Settings.UseProxyToUpdateSubscription)
|
||||
{
|
||||
// 当前 ServerComboBox 中至少有一项
|
||||
@@ -570,6 +579,7 @@ namespace Netch.Forms
|
||||
foreach (var x in result)
|
||||
{
|
||||
x.Group = item.Remark;
|
||||
x.Remark = "[" + item.Remark + "] " + x.Remark;
|
||||
}
|
||||
Global.Settings.Server.AddRange(result);
|
||||
NotifyIcon.ShowBalloonTip(5,
|
||||
@@ -956,6 +966,8 @@ namespace Netch.Forms
|
||||
reinstallTapDriverToolStripMenuItem.Enabled = true;
|
||||
ServerComboBox.Enabled = true;
|
||||
ModeComboBox.Enabled = true;
|
||||
//隐藏NTT测试
|
||||
NatTypeStatusLabel.Visible = false;
|
||||
|
||||
ControlButton.Text = Utils.i18N.Translate("Start");
|
||||
StatusLabel.Text = $"{Utils.i18N.Translate("Status")}{Utils.i18N.Translate(": ")}{Utils.i18N.Translate("Start failed")}";
|
||||
@@ -1000,6 +1012,8 @@ namespace Netch.Forms
|
||||
reinstallTapDriverToolStripMenuItem.Enabled = true;
|
||||
ServerComboBox.Enabled = true;
|
||||
ModeComboBox.Enabled = true;
|
||||
//隐藏NTT测试
|
||||
NatTypeStatusLabel.Visible = false;
|
||||
|
||||
ControlButton.Text = Utils.i18N.Translate("Start");
|
||||
StatusLabel.Text = $"{Utils.i18N.Translate("Status")}{Utils.i18N.Translate(": ")}{Utils.i18N.Translate("Stopped")}";
|
||||
@@ -1340,6 +1354,7 @@ namespace Netch.Forms
|
||||
}
|
||||
public void NatTypeStatusText(string text)
|
||||
{
|
||||
NatTypeStatusLabel.Visible = true;
|
||||
if (!string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
NatTypeStatusLabel.Text = "NAT" + Utils.i18N.Translate(": ") + text;
|
||||
|
||||
10
Netch/Forms/SubscribeForm.Designer.cs
generated
10
Netch/Forms/SubscribeForm.Designer.cs
generated
@@ -62,7 +62,7 @@
|
||||
this.AddSubscriptionBox.Controls.Add(this.RemarkLabel);
|
||||
this.AddSubscriptionBox.Location = new System.Drawing.Point(12, 226);
|
||||
this.AddSubscriptionBox.Name = "AddSubscriptionBox";
|
||||
this.AddSubscriptionBox.Size = new System.Drawing.Size(660, 132);
|
||||
this.AddSubscriptionBox.Size = new System.Drawing.Size(660, 135);
|
||||
this.AddSubscriptionBox.TabIndex = 1;
|
||||
this.AddSubscriptionBox.TabStop = false;
|
||||
//
|
||||
@@ -75,11 +75,11 @@
|
||||
//
|
||||
// AddButton
|
||||
//
|
||||
this.AddButton.Location = new System.Drawing.Point(579, 103);
|
||||
this.AddButton.Location = new System.Drawing.Point(541, 103);
|
||||
this.AddButton.Name = "AddButton";
|
||||
this.AddButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.AddButton.Size = new System.Drawing.Size(113, 26);
|
||||
this.AddButton.TabIndex = 7;
|
||||
this.AddButton.Text = "Add";
|
||||
this.AddButton.Text = "Add / Modify";
|
||||
this.AddButton.UseVisualStyleBackColor = true;
|
||||
this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
|
||||
//
|
||||
@@ -192,7 +192,7 @@
|
||||
// UseSelectedServerCheckBox
|
||||
//
|
||||
this.UseSelectedServerCheckBox.AutoSize = true;
|
||||
this.UseSelectedServerCheckBox.Location = new System.Drawing.Point(12, 364);
|
||||
this.UseSelectedServerCheckBox.Location = new System.Drawing.Point(12, 396);
|
||||
this.UseSelectedServerCheckBox.Name = "UseSelectedServerCheckBox";
|
||||
this.UseSelectedServerCheckBox.Size = new System.Drawing.Size(285, 21);
|
||||
this.UseSelectedServerCheckBox.TabIndex = 9;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using Netch.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Netch.Forms
|
||||
@@ -54,7 +56,8 @@ namespace Netch.Forms
|
||||
UseSelectedServerCheckBox.Enabled = true;
|
||||
UseSelectedServerCheckBox.Checked = Global.Settings.UseProxyToUpdateSubscription;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
UseSelectedServerCheckBox.Checked = false;
|
||||
UseSelectedServerCheckBox.Enabled = false;
|
||||
}
|
||||
@@ -84,26 +87,33 @@ namespace Netch.Forms
|
||||
{
|
||||
if (SubscribeLinkListView.SelectedItems.Count > 0)
|
||||
{
|
||||
for (var i = SubscribeLinkListView.SelectedItems.Count - 1; i >= 0; i--)
|
||||
DeleteSubscribe();
|
||||
}
|
||||
}
|
||||
}
|
||||
public void DeleteSubscribe()
|
||||
{
|
||||
if (SubscribeLinkListView.SelectedItems.Count > 0)
|
||||
{
|
||||
for (var i = SubscribeLinkListView.SelectedItems.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var item = SubscribeLinkListView.SelectedItems[i];
|
||||
var link = Global.Settings.SubscribeLink[item.Index];
|
||||
|
||||
var list = new List<Models.Server>();
|
||||
foreach (var server in Global.Settings.Server)
|
||||
{
|
||||
var item = SubscribeLinkListView.SelectedItems[i];
|
||||
var link = Global.Settings.SubscribeLink[item.Index];
|
||||
|
||||
var list = new List<Models.Server>();
|
||||
foreach (var server in Global.Settings.Server)
|
||||
if (server.Group != link.Remark)
|
||||
{
|
||||
if (server.Group != link.Remark)
|
||||
{
|
||||
list.Add(server);
|
||||
}
|
||||
list.Add(server);
|
||||
}
|
||||
|
||||
Global.Settings.Server = list;
|
||||
Global.Settings.SubscribeLink.RemoveAt(item.Index);
|
||||
SubscribeLinkListView.Items.Remove(item);
|
||||
|
||||
Global.MainForm.InitServer();
|
||||
}
|
||||
|
||||
Global.Settings.Server = list;
|
||||
Global.Settings.SubscribeLink.RemoveAt(item.Index);
|
||||
SubscribeLinkListView.Items.Remove(item);
|
||||
|
||||
Global.MainForm.InitServer();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -116,12 +126,57 @@ namespace Netch.Forms
|
||||
{
|
||||
if (LinkTextBox.Text.StartsWith("HTTP://", StringComparison.OrdinalIgnoreCase) || LinkTextBox.Text.StartsWith("HTTPS://", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Global.Settings.SubscribeLink.Add(new Models.SubscribeLink
|
||||
//是否为新增订阅
|
||||
var saveFlag = true;
|
||||
Global.Settings.SubscribeLink.ForEach((subitem) =>
|
||||
{
|
||||
Remark = RemarkTextBox.Text,
|
||||
Link = LinkTextBox.Text,
|
||||
UserAgent = UserAgentTextBox.Text
|
||||
if (subitem.Link.Equals(LinkTextBox.Text))
|
||||
{
|
||||
if (!subitem.Remark.Equals(RemarkTextBox.Text))
|
||||
{
|
||||
//修改了订阅备注,删除旧订阅服务器
|
||||
Global.Settings.Server.ForEach((serverItem) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
//当前服务器组群组为订阅群组时批量修改备注
|
||||
if (serverItem.Group == subitem.Remark)
|
||||
{
|
||||
string OldServerRemark = "[" + serverItem.Group + "] ";
|
||||
Logging.Info(serverItem.Remark.Split(OldServerRemark.ToCharArray())[1]);
|
||||
serverItem.Remark = "[" + RemarkTextBox.Text + "] " + serverItem.Remark.Split(new string[] { OldServerRemark }, StringSplitOptions.None)[1];
|
||||
serverItem.Group = RemarkTextBox.Text;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
});
|
||||
|
||||
subitem.Remark = RemarkTextBox.Text;
|
||||
Global.MainForm.InitServer();
|
||||
}
|
||||
|
||||
subitem.UserAgent = UserAgentTextBox.Text;
|
||||
saveFlag = false;
|
||||
|
||||
Utils.Configuration.Save();
|
||||
Global.Settings.UseProxyToUpdateSubscription = UseSelectedServerCheckBox.Checked;
|
||||
MessageBox.Show(Utils.i18N.Translate("Successfully saved"), Utils.i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
if (saveFlag)
|
||||
{
|
||||
Global.Settings.SubscribeLink.Add(new Models.SubscribeLink
|
||||
{
|
||||
Remark = RemarkTextBox.Text,
|
||||
Link = LinkTextBox.Text,
|
||||
UserAgent = UserAgentTextBox.Text
|
||||
});
|
||||
}
|
||||
|
||||
RemarkTextBox.Text = string.Empty;
|
||||
LinkTextBox.Text = string.Empty;
|
||||
@@ -160,7 +215,12 @@ namespace Netch.Forms
|
||||
/// <param name="e"></param>
|
||||
private void SubscribeLinkListView_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
//MessageBox.Show(SubscribeLinkListView.SelectedItems + "", Utils.i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
if (SubscribeLinkListView.SelectedItems.Count > 0)
|
||||
{
|
||||
RemarkTextBox.Text = SubscribeLinkListView.SelectedItems[0].SubItems[0].Text;
|
||||
LinkTextBox.Text = SubscribeLinkListView.SelectedItems[0].SubItems[1].Text;
|
||||
UserAgentTextBox.Text = SubscribeLinkListView.SelectedItems[0].SubItems[2].Text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,6 +123,7 @@
|
||||
"Add": "添加",
|
||||
"Scan": "扫描",
|
||||
"Save": "保存",
|
||||
"Add / Modify": "保存/修改",
|
||||
"Select a folder": "选择一个目录",
|
||||
"Please enter an process name (xxx.exe)": "请输入一个进程名(xxx.exe)",
|
||||
"Scan completed": "扫描完成",
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Netch.Utils
|
||||
/// <returns>加密后的字符串</returns>
|
||||
public static string URLSafeBase64Encode(string text)
|
||||
{
|
||||
return Convert.ToBase64String(Encoding.UTF8.GetBytes(text)).Replace("-", "+").Replace("_", "/").PadRight(text.Length + (4 - text.Length % 4) % 4, '=');
|
||||
return Convert.ToBase64String(Encoding.UTF8.GetBytes(text)).Replace("+", "-").Replace("/", "_").Replace("=", "");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user