Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d20791bf73 | ||
|
|
7bb91f57ac | ||
|
|
b7a6004830 | ||
|
|
dee5613f2f |
26
v2rayN/v2rayN/Forms/MainForm.Designer.cs
generated
26
v2rayN/v2rayN/Forms/MainForm.Designer.cs
generated
@@ -47,6 +47,7 @@
|
||||
this.menuCopyServer = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuSetDefaultServer = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.menuMoveToGroup = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuMoveTop = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuMoveUp = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuMoveDown = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@@ -64,9 +65,9 @@
|
||||
this.menuExport2ServerConfig = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuExport2ShareUrl = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuExport2SubContent = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.tsbServer = new System.Windows.Forms.ToolStripDropDownButton();
|
||||
this.tabGroup = new System.Windows.Forms.TabControl();
|
||||
this.qrCodeControl = new v2rayN.Forms.QRCodeControl();
|
||||
this.tsbServer = new System.Windows.Forms.ToolStripDropDownButton();
|
||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.gbMsgTitle = new System.Windows.Forms.GroupBox();
|
||||
@@ -208,6 +209,7 @@
|
||||
this.menuCopyServer,
|
||||
this.menuSetDefaultServer,
|
||||
this.toolStripSeparator3,
|
||||
this.menuMoveToGroup,
|
||||
this.menuMoveTop,
|
||||
this.menuMoveUp,
|
||||
this.menuMoveDown,
|
||||
@@ -226,6 +228,7 @@
|
||||
this.menuExport2ShareUrl,
|
||||
this.menuExport2SubContent});
|
||||
this.cmsLv.Name = "cmsLv";
|
||||
this.cmsLv.OwnerItem = this.tsbServer;
|
||||
resources.ApplyResources(this.cmsLv, "cmsLv");
|
||||
//
|
||||
// menuAddVmessServer
|
||||
@@ -310,6 +313,12 @@
|
||||
this.toolStripSeparator3.Name = "toolStripSeparator3";
|
||||
resources.ApplyResources(this.toolStripSeparator3, "toolStripSeparator3");
|
||||
//
|
||||
// menuMoveToGroup
|
||||
//
|
||||
this.menuMoveToGroup.Name = "menuMoveToGroup";
|
||||
resources.ApplyResources(this.menuMoveToGroup, "menuMoveToGroup");
|
||||
this.menuMoveToGroup.Click += new System.EventHandler(this.menuMoveToGroup_Click);
|
||||
//
|
||||
// menuMoveTop
|
||||
//
|
||||
this.menuMoveTop.Name = "menuMoveTop";
|
||||
@@ -410,6 +419,13 @@
|
||||
resources.ApplyResources(this.menuExport2SubContent, "menuExport2SubContent");
|
||||
this.menuExport2SubContent.Click += new System.EventHandler(this.menuExport2SubContent_Click);
|
||||
//
|
||||
// tsbServer
|
||||
//
|
||||
this.tsbServer.DropDown = this.cmsLv;
|
||||
this.tsbServer.Image = global::v2rayN.Properties.Resources.server;
|
||||
resources.ApplyResources(this.tsbServer, "tsbServer");
|
||||
this.tsbServer.Name = "tsbServer";
|
||||
//
|
||||
// tabGroup
|
||||
//
|
||||
resources.ApplyResources(this.tabGroup, "tabGroup");
|
||||
@@ -422,13 +438,6 @@
|
||||
resources.ApplyResources(this.qrCodeControl, "qrCodeControl");
|
||||
this.qrCodeControl.Name = "qrCodeControl";
|
||||
//
|
||||
// tsbServer
|
||||
//
|
||||
this.tsbServer.DropDown = this.cmsLv;
|
||||
this.tsbServer.Image = global::v2rayN.Properties.Resources.server;
|
||||
resources.ApplyResources(this.tsbServer, "tsbServer");
|
||||
this.tsbServer.Name = "tsbServer";
|
||||
//
|
||||
// splitContainer1
|
||||
//
|
||||
resources.ApplyResources(this.splitContainer1, "splitContainer1");
|
||||
@@ -1076,6 +1085,7 @@
|
||||
private System.Windows.Forms.ToolStripMenuItem tsbGlobalHotkeySetting;
|
||||
private System.Windows.Forms.TabControl tabGroup;
|
||||
private System.Windows.Forms.ToolStripMenuItem tsbGroupSetting;
|
||||
private System.Windows.Forms.ToolStripMenuItem menuMoveToGroup;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -485,6 +485,23 @@ namespace v2rayN.Forms
|
||||
}
|
||||
|
||||
tabGroup.SelectedIndex = 0;
|
||||
|
||||
//menuMoveToGroup
|
||||
menuMoveToGroup.DropDownItems.Clear();
|
||||
|
||||
List<ToolStripMenuItem> lst = new List<ToolStripMenuItem>();
|
||||
foreach (var item in config.groupItem)
|
||||
{
|
||||
string name = item.remarks;
|
||||
|
||||
ToolStripMenuItem ts = new ToolStripMenuItem(name)
|
||||
{
|
||||
Tag = item.id,
|
||||
};
|
||||
ts.Click += new EventHandler(ts_Group_Click);
|
||||
lst.Add(ts);
|
||||
}
|
||||
menuMoveToGroup.DropDownItems.AddRange(lst.ToArray());
|
||||
}
|
||||
|
||||
private void tabGroup_SelectedIndexChanged(object sender, EventArgs e)
|
||||
@@ -501,6 +518,29 @@ namespace v2rayN.Forms
|
||||
|
||||
lvServers.Focus();
|
||||
}
|
||||
|
||||
private void ts_Group_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
ToolStripItem ts = (ToolStripItem)sender;
|
||||
var groupIdSelected = Utils.ToString(ts.Tag);
|
||||
|
||||
int index = GetLvSelectedIndex();
|
||||
if (index < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ConfigHandler.MoveServerToGroup(config, lstSelecteds, groupIdSelected) == 0)
|
||||
{
|
||||
RefreshServers();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region v2ray 操作
|
||||
@@ -688,7 +728,7 @@ namespace v2rayN.Forms
|
||||
private void menuRemoveDuplicateServer_Click(object sender, EventArgs e)
|
||||
{
|
||||
int oldCount = lstVmess.Count;
|
||||
int newCount = ConfigHandler.DedupServerList(ref config, ref lstVmess);
|
||||
int newCount = ConfigHandler.DedupServerList(ref config, ref lstVmess);
|
||||
RefreshServers();
|
||||
_ = LoadV2ray();
|
||||
UI.Show(string.Format(UIRes.I18N("RemoveDuplicateServerResult"), oldCount, newCount));
|
||||
@@ -720,11 +760,11 @@ namespace v2rayN.Forms
|
||||
|
||||
private void menuPingServer_Click(object sender, EventArgs e)
|
||||
{
|
||||
Speedtest("ping");
|
||||
Speedtest(ESpeedActionType.Ping);
|
||||
}
|
||||
private void menuTcpingServer_Click(object sender, EventArgs e)
|
||||
{
|
||||
Speedtest("tcping");
|
||||
Speedtest(ESpeedActionType.Tcping);
|
||||
}
|
||||
|
||||
private void menuRealPingServer_Click(object sender, EventArgs e)
|
||||
@@ -737,7 +777,7 @@ namespace v2rayN.Forms
|
||||
|
||||
//UI.Show(UIRes.I18N("SpeedServerTips"));
|
||||
|
||||
Speedtest("realping");
|
||||
Speedtest(ESpeedActionType.Realping);
|
||||
}
|
||||
|
||||
private void menuSpeedServer_Click(object sender, EventArgs e)
|
||||
@@ -750,13 +790,13 @@ namespace v2rayN.Forms
|
||||
|
||||
//UI.Show(UIRes.I18N("SpeedServerTips"));
|
||||
|
||||
Speedtest("speedtest");
|
||||
Speedtest(ESpeedActionType.Speedtest);
|
||||
}
|
||||
private void Speedtest(string actionType)
|
||||
private void Speedtest(ESpeedActionType actionType)
|
||||
{
|
||||
if (GetLvSelectedIndex() < 0) return;
|
||||
ClearTestResult();
|
||||
SpeedtestHandler statistics = new SpeedtestHandler(ref config, ref v2rayHandler, lstSelecteds, actionType, UpdateSpeedtestHandler);
|
||||
SpeedtestHandler statistics = new SpeedtestHandler(ref config, v2rayHandler, lstSelecteds, actionType, UpdateSpeedtestHandler);
|
||||
}
|
||||
|
||||
private void tsbTestMe_Click(object sender, EventArgs e)
|
||||
@@ -1280,7 +1320,9 @@ namespace v2rayN.Forms
|
||||
item.Selected = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void menuMoveToGroup_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 系统代理相关
|
||||
|
||||
@@ -206,6 +206,12 @@
|
||||
<data name="toolStripSeparator3.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>352, 6</value>
|
||||
</data>
|
||||
<data name="menuMoveToGroup.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>355, 22</value>
|
||||
</data>
|
||||
<data name="menuMoveToGroup.Text" xml:space="preserve">
|
||||
<value>Move to Group</value>
|
||||
</data>
|
||||
<data name="menuMoveTop.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>355, 22</value>
|
||||
</data>
|
||||
@@ -302,8 +308,20 @@
|
||||
<data name="menuExport2SubContent.Text" xml:space="preserve">
|
||||
<value>Export subscription (base64) share to clipboard</value>
|
||||
</data>
|
||||
<data name="tsbServer.ImageTransparentColor" type="System.Drawing.Color, System.Drawing">
|
||||
<value>Magenta</value>
|
||||
</data>
|
||||
<data name="tsbServer.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>64, 53</value>
|
||||
</data>
|
||||
<data name="tsbServer.Text" xml:space="preserve">
|
||||
<value>Servers</value>
|
||||
</data>
|
||||
<data name="tsbServer.TextImageRelation" type="System.Windows.Forms.TextImageRelation, System.Windows.Forms">
|
||||
<value>ImageAboveText</value>
|
||||
</data>
|
||||
<data name="cmsLv.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>356, 622</value>
|
||||
<value>356, 666</value>
|
||||
</data>
|
||||
<data name=">>cmsLv.Name" xml:space="preserve">
|
||||
<value>cmsLv</value>
|
||||
@@ -452,18 +470,6 @@
|
||||
<data name=">>scMain.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="tsbServer.ImageTransparentColor" type="System.Drawing.Color, System.Drawing">
|
||||
<value>Magenta</value>
|
||||
</data>
|
||||
<data name="tsbServer.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>64, 53</value>
|
||||
</data>
|
||||
<data name="tsbServer.Text" xml:space="preserve">
|
||||
<value>Servers</value>
|
||||
</data>
|
||||
<data name="tsbServer.TextImageRelation" type="System.Windows.Forms.TextImageRelation, System.Windows.Forms">
|
||||
<value>ImageAboveText</value>
|
||||
</data>
|
||||
<data name="splitContainer1.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
|
||||
<value>Fill</value>
|
||||
</data>
|
||||
@@ -549,7 +555,7 @@
|
||||
<value>Set message filters</value>
|
||||
</data>
|
||||
<data name="cmsMsgBox.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>228, 158</value>
|
||||
<value>228, 136</value>
|
||||
</data>
|
||||
<data name=">>cmsMsgBox.Name" xml:space="preserve">
|
||||
<value>cmsMsgBox</value>
|
||||
@@ -1205,6 +1211,12 @@
|
||||
<data name=">>toolStripSeparator3.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.ToolStripSeparator, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>menuMoveToGroup.Name" xml:space="preserve">
|
||||
<value>menuMoveToGroup</value>
|
||||
</data>
|
||||
<data name=">>menuMoveToGroup.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>menuMoveTop.Name" xml:space="preserve">
|
||||
<value>menuMoveTop</value>
|
||||
</data>
|
||||
|
||||
@@ -573,4 +573,7 @@
|
||||
<data name="tsbClose.Text" xml:space="preserve">
|
||||
<value> 关闭窗口 </value>
|
||||
</data>
|
||||
<data name="menuMoveToGroup.Text" xml:space="preserve">
|
||||
<value>移至分组</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1115,7 +1115,17 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int MoveServerToGroup(Config config, List<VmessItem> indexs, string groupId)
|
||||
{
|
||||
foreach (var item in indexs)
|
||||
{
|
||||
item.groupId = groupId;
|
||||
}
|
||||
|
||||
ToJsonFile(config);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region UI
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace v2rayN.Handler
|
||||
_config = config;
|
||||
}
|
||||
|
||||
public SpeedtestHandler(ref Config config, ref V2rayHandler v2rayHandler, List<VmessItem> selecteds, string actionType, Action<string, string> update)
|
||||
public SpeedtestHandler(ref Config config, V2rayHandler v2rayHandler, List<VmessItem> selecteds, ESpeedActionType actionType, Action<string, string> update)
|
||||
{
|
||||
_config = config;
|
||||
_v2rayHandler = v2rayHandler;
|
||||
@@ -40,19 +40,19 @@ namespace v2rayN.Handler
|
||||
});
|
||||
}
|
||||
|
||||
if (actionType == "ping")
|
||||
if (actionType == ESpeedActionType.Ping)
|
||||
{
|
||||
Task.Run(() => RunPing());
|
||||
}
|
||||
if (actionType == "tcping")
|
||||
else if (actionType == ESpeedActionType.Tcping)
|
||||
{
|
||||
Task.Run(() => RunTcping());
|
||||
}
|
||||
else if (actionType == "realping")
|
||||
else if (actionType == ESpeedActionType.Realping)
|
||||
{
|
||||
Task.Run(() => RunRealPing());
|
||||
}
|
||||
else if (actionType == "speedtest")
|
||||
else if (actionType == ESpeedActionType.Speedtest)
|
||||
{
|
||||
Task.Run(() => RunSpeedTest());
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ namespace v2rayN.Handler
|
||||
string url = config.subItem[k - 1].url.TrimEx();
|
||||
string userAgent = config.subItem[k - 1].userAgent.TrimEx();
|
||||
string groupId = config.subItem[k - 1].groupId.TrimEx();
|
||||
string hashCode = $"{k}->";
|
||||
string hashCode = $"{k}){config.subItem[k - 1].remarks}->";
|
||||
if (config.subItem[k - 1].enabled == false)
|
||||
{
|
||||
continue;
|
||||
|
||||
@@ -921,10 +921,33 @@ namespace v2rayN.Handler
|
||||
}
|
||||
File.Copy(addressFileName, fileName);
|
||||
|
||||
//check again
|
||||
if (!File.Exists(fileName))
|
||||
{
|
||||
msg = UIRes.I18N("FailedGenDefaultConfiguration");
|
||||
return -1;
|
||||
}
|
||||
|
||||
//overwrite port
|
||||
var fileContent = File.ReadAllLines(fileName).ToList();
|
||||
var coreType = LazyConfig.Instance.GetCoreType(node, node.configType);
|
||||
switch (coreType)
|
||||
{
|
||||
case ECoreType.v2fly:
|
||||
case ECoreType.Xray:
|
||||
break;
|
||||
case ECoreType.clash:
|
||||
fileContent.Add($"port: {LazyConfig.Instance.GetConfig().GetLocalPort(Global.InboundHttp)}");
|
||||
fileContent.Add($"socks-port: {LazyConfig.Instance.GetConfig().GetLocalPort(Global.InboundSocks)}");
|
||||
break;
|
||||
}
|
||||
File.WriteAllLines(fileName, fileContent);
|
||||
|
||||
msg = string.Format(UIRes.I18N("SuccessfulConfiguration"), $"[{LazyConfig.Instance.GetConfig().GetGroupRemarks(node.groupId)}] {node.GetSummary()}");
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utils.SaveLog("GenerateClientCustomConfig", ex);
|
||||
msg = UIRes.I18N("FailedGenDefaultConfiguration");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace v2rayN.Handler
|
||||
class V2rayHandler
|
||||
{
|
||||
private static string v2rayConfigRes = Global.v2rayConfigFileName;
|
||||
private List<string> lstV2ray;
|
||||
private List<string> lstCore;
|
||||
private string coreUrl;
|
||||
private string coreArguments;
|
||||
public event ProcessDelegate ProcessEvent;
|
||||
@@ -106,7 +106,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (string vName in lstV2ray)
|
||||
foreach (string vName in lstCore)
|
||||
{
|
||||
Process[] existing = Process.GetProcessesByName(vName);
|
||||
foreach (Process p in existing)
|
||||
@@ -163,12 +163,10 @@ namespace v2rayN.Handler
|
||||
}
|
||||
}
|
||||
|
||||
private string V2rayFindexe()
|
||||
private string V2rayFindexe(List<string> lstCoreTemp)
|
||||
{
|
||||
//查找v2ray文件是否存在
|
||||
string fileName = string.Empty;
|
||||
//lstV2ray.Reverse();
|
||||
foreach (string name in lstV2ray)
|
||||
foreach (string name in lstCoreTemp)
|
||||
{
|
||||
string vName = string.Format("{0}.exe", name);
|
||||
vName = Utils.GetPath(vName);
|
||||
@@ -195,7 +193,7 @@ namespace v2rayN.Handler
|
||||
|
||||
try
|
||||
{
|
||||
string fileName = V2rayFindexe();
|
||||
string fileName = V2rayFindexe(lstCore);
|
||||
if (fileName == "") return;
|
||||
|
||||
Process p = new Process
|
||||
@@ -249,7 +247,8 @@ namespace v2rayN.Handler
|
||||
|
||||
try
|
||||
{
|
||||
string fileName = V2rayFindexe();
|
||||
coreUrl = Global.xrayCoreUrl;
|
||||
string fileName = V2rayFindexe(new List<string> { "xray" });
|
||||
if (fileName == "") return -1;
|
||||
|
||||
Process p = new Process
|
||||
@@ -336,7 +335,7 @@ namespace v2rayN.Handler
|
||||
|
||||
if (coreType == ECoreType.v2fly)
|
||||
{
|
||||
lstV2ray = new List<string>
|
||||
lstCore = new List<string>
|
||||
{
|
||||
"wv2ray",
|
||||
"v2ray"
|
||||
@@ -346,7 +345,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
else if (coreType == ECoreType.Xray)
|
||||
{
|
||||
lstV2ray = new List<string>
|
||||
lstCore = new List<string>
|
||||
{
|
||||
"xray"
|
||||
};
|
||||
@@ -355,7 +354,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
else if (coreType == ECoreType.clash)
|
||||
{
|
||||
lstV2ray = new List<string>
|
||||
lstCore = new List<string>
|
||||
{
|
||||
"clash-windows-amd64",
|
||||
"clash-windows-386",
|
||||
|
||||
11
v2rayN/v2rayN/Mode/ESpeedActionType.cs
Normal file
11
v2rayN/v2rayN/Mode/ESpeedActionType.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
namespace v2rayN.Mode
|
||||
{
|
||||
public enum ESpeedActionType
|
||||
{
|
||||
Ping,
|
||||
Tcping,
|
||||
Realping,
|
||||
Speedtest
|
||||
}
|
||||
}
|
||||
@@ -32,4 +32,4 @@ using System.Runtime.InteropServices;
|
||||
// 方法是按如下所示使用“*”:
|
||||
//[assembly: AssemblyVersion("1.0.*")]
|
||||
//[assembly: AssemblyVersion("1.0.0")]
|
||||
[assembly: AssemblyFileVersion("5.5")]
|
||||
[assembly: AssemblyFileVersion("5.6")]
|
||||
|
||||
@@ -199,6 +199,7 @@
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Handler\SysProxyHandle.cs" />
|
||||
<Compile Include="Mode\ESpeedActionType.cs" />
|
||||
<Compile Include="Mode\EGlobalHotkey.cs" />
|
||||
<Compile Include="Mode\ECoreType.cs" />
|
||||
<Compile Include="Mode\ESysProxyType.cs" />
|
||||
|
||||
Reference in New Issue
Block a user