Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cdc83bc9d7 | ||
|
|
70feacd276 | ||
|
|
ece4572058 | ||
|
|
4d16a5e801 | ||
|
|
1493a8b03f | ||
|
|
d20791bf73 | ||
|
|
7bb91f57ac | ||
|
|
b7a6004830 | ||
|
|
dee5613f2f | ||
|
|
e58e0d6ac7 | ||
|
|
a2679e009d | ||
|
|
78d6bcd57a |
@@ -1,10 +1,13 @@
|
||||
using System.Drawing;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace v2rayN.Base
|
||||
{
|
||||
class ListViewFlickerFree : ListView
|
||||
{
|
||||
Action<int, int> _updateFunc;
|
||||
|
||||
public ListViewFlickerFree()
|
||||
{
|
||||
SetStyle(ControlStyles.OptimizedDoubleBuffer
|
||||
@@ -13,40 +16,82 @@ namespace v2rayN.Base
|
||||
UpdateStyles();
|
||||
}
|
||||
|
||||
|
||||
public void AutoResizeColumns()
|
||||
public void RegisterDragEvent(Action<int, int> _update)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.SuspendLayout();
|
||||
Graphics graphics = this.CreateGraphics();
|
||||
_updateFunc = _update;
|
||||
this.AllowDrop = true;
|
||||
|
||||
// 原生 ColumnHeaderAutoResizeStyle.ColumnContent 将忽略列头宽度
|
||||
this.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
|
||||
|
||||
for (int i = 0; i < this.Columns.Count; i++)
|
||||
{
|
||||
ColumnHeader c = this.Columns[i];
|
||||
int cWidth = c.Width;
|
||||
string MaxStr = "";
|
||||
Font font = this.Items[0].SubItems[0].Font;
|
||||
|
||||
foreach (ListViewItem item in this.Items)
|
||||
{
|
||||
// 整行视作相同字形,不单独计算每个单元格
|
||||
font = item.SubItems[i].Font;
|
||||
string str = item.SubItems[i].Text;
|
||||
if (str.Length > MaxStr.Length) // 未考虑非等宽问题
|
||||
MaxStr = str;
|
||||
}
|
||||
int strWidth = (int)graphics.MeasureString(MaxStr, font).Width;
|
||||
c.Width = System.Math.Max(cWidth, strWidth);
|
||||
}
|
||||
this.ResumeLayout();
|
||||
}
|
||||
catch { }
|
||||
this.ItemDrag += new ItemDragEventHandler(this.lv_ItemDrag);
|
||||
this.DragDrop += new DragEventHandler(this.lv_DragDrop);
|
||||
this.DragEnter += new DragEventHandler(this.lv_DragEnter);
|
||||
this.DragOver += new DragEventHandler(this.lv_DragOver);
|
||||
this.DragLeave += new EventHandler(this.lv_DragLeave);
|
||||
}
|
||||
|
||||
|
||||
private void lv_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
int targetIndex = this.InsertionMark.Index;
|
||||
if (targetIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this.InsertionMark.AppearsAfterItem)
|
||||
{
|
||||
targetIndex++;
|
||||
}
|
||||
|
||||
|
||||
if (this.SelectedIndices.Count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_updateFunc(this.SelectedIndices[0], targetIndex);
|
||||
|
||||
//ListViewItem draggedItem = (ListViewItem)e.Data.GetData(typeof(ListViewItem));
|
||||
//this.BeginUpdate();
|
||||
//this.Items.Insert(targetIndex, (ListViewItem)draggedItem.Clone());
|
||||
//this.Items.Remove(draggedItem);
|
||||
//this.EndUpdate();
|
||||
}
|
||||
|
||||
|
||||
private void lv_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
e.Effect = e.AllowedEffect;
|
||||
}
|
||||
|
||||
private void lv_DragLeave(object sender, EventArgs e)
|
||||
{
|
||||
this.InsertionMark.Index = -1;
|
||||
}
|
||||
|
||||
private void lv_DragOver(object sender, DragEventArgs e)
|
||||
{
|
||||
Point targetPoint = this.PointToClient(new Point(e.X, e.Y));
|
||||
int targetIndex = this.InsertionMark.NearestIndex(targetPoint);
|
||||
|
||||
if (targetIndex > -1)
|
||||
{
|
||||
Rectangle itemBounds = this.GetItemRect(targetIndex);
|
||||
this.EnsureVisible(targetIndex);
|
||||
|
||||
if (targetPoint.Y > itemBounds.Top + (itemBounds.Height / 2))
|
||||
{
|
||||
this.InsertionMark.AppearsAfterItem = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.InsertionMark.AppearsAfterItem = false;
|
||||
}
|
||||
}
|
||||
this.InsertionMark.Index = targetIndex;
|
||||
}
|
||||
|
||||
private void lv_ItemDrag(object sender, ItemDragEventArgs e)
|
||||
{
|
||||
this.DoDragDrop(e.Item, DragDropEffects.Move);
|
||||
this.InsertionMark.Index = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ namespace v2rayN.Forms
|
||||
{
|
||||
cmbCoreType.Items.AddRange(Global.coreTypes.ToArray());
|
||||
cmbCoreType.Items.Add("clash");
|
||||
cmbCoreType.Items.Add("hysteria");
|
||||
cmbCoreType.Items.Add(string.Empty);
|
||||
|
||||
txtAddress.ReadOnly = true;
|
||||
@@ -128,7 +129,7 @@ namespace v2rayN.Forms
|
||||
vmessItem.address = fileName;
|
||||
vmessItem.remarks = txtRemarks.Text;
|
||||
|
||||
if (ConfigHandler.AddCustomServer(ref config, vmessItem) == 0)
|
||||
if (ConfigHandler.AddCustomServer(ref config, vmessItem, false) == 0)
|
||||
{
|
||||
BindingServer();
|
||||
UI.Show(UIRes.I18N("SuccessfullyImportedCustomServer"));
|
||||
@@ -148,7 +149,7 @@ namespace v2rayN.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
address = Path.Combine(Utils.GetTempPath(), address);
|
||||
address = Path.Combine(Utils.GetConfigPath(), address);
|
||||
Process.Start(address);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,7 @@ namespace v2rayN.Forms
|
||||
private void AddServerForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.Text = (eConfigType).ToString();
|
||||
|
||||
cmbSecurity.Items.AddRange(Global.vmessSecuritys.ToArray());
|
||||
cmbSecurity3.Items.AddRange(config.GetShadowsocksSecuritys().ToArray());
|
||||
|
||||
cmbFlow5.Items.AddRange(Global.xtlsFlows.ToArray());
|
||||
cmbFlow6.Items.AddRange(Global.xtlsFlows.ToArray());
|
||||
|
||||
|
||||
cmbCoreType.Items.AddRange(Global.coreTypes.ToArray());
|
||||
cmbCoreType.Items.Add(string.Empty);
|
||||
|
||||
@@ -31,12 +25,16 @@ namespace v2rayN.Forms
|
||||
case EConfigType.Vmess:
|
||||
panVmess.Dock = DockStyle.Fill;
|
||||
panVmess.Visible = true;
|
||||
|
||||
cmbSecurity.Items.AddRange(Global.vmessSecuritys.ToArray());
|
||||
break;
|
||||
case EConfigType.Shadowsocks:
|
||||
panSs.Dock = DockStyle.Fill;
|
||||
panSs.Visible = true;
|
||||
panTran.Visible = false;
|
||||
this.Height = this.Height - panTran.Height;
|
||||
|
||||
cmbSecurity3.Items.AddRange(LazyConfig.Instance.GetShadowsocksSecuritys().ToArray());
|
||||
break;
|
||||
case EConfigType.Socks:
|
||||
panSocks.Dock = DockStyle.Fill;
|
||||
@@ -48,11 +46,15 @@ namespace v2rayN.Forms
|
||||
panVless.Dock = DockStyle.Fill;
|
||||
panVless.Visible = true;
|
||||
transportControl.AllowXtls = true;
|
||||
|
||||
cmbFlow5.Items.AddRange(Global.xtlsFlows.ToArray());
|
||||
break;
|
||||
case EConfigType.Trojan:
|
||||
panTrojan.Dock = DockStyle.Fill;
|
||||
panTrojan.Visible = true;
|
||||
transportControl.AllowXtls = true;
|
||||
|
||||
cmbFlow6.Items.AddRange(Global.xtlsFlows.ToArray());
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -225,6 +225,7 @@ namespace v2rayN.Forms
|
||||
lvServers.Scrollable = true;
|
||||
lvServers.MultiSelect = true;
|
||||
lvServers.HeaderStyle = ColumnHeaderStyle.Clickable;
|
||||
lvServers.RegisterDragEvent(UpdateDragEventHandler);
|
||||
|
||||
lvServers.Columns.Add("", 30);
|
||||
lvServers.Columns.Add(UIRes.I18N("LvServiceType"), 80);
|
||||
@@ -247,6 +248,18 @@ namespace v2rayN.Forms
|
||||
lvServers.EndUpdate();
|
||||
}
|
||||
|
||||
private void UpdateDragEventHandler(int index, int targetIndex)
|
||||
{
|
||||
if (index < 0 || targetIndex < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (ConfigHandler.MoveServer(ref config, ref lstVmess, index, EMove.Position, targetIndex) == 0)
|
||||
{
|
||||
RefreshServers();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 刷新服务器列表
|
||||
/// </summary>
|
||||
@@ -485,6 +498,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 +531,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 操作
|
||||
@@ -586,7 +639,7 @@ namespace v2rayN.Forms
|
||||
else
|
||||
{
|
||||
fm = new AddServerForm();
|
||||
}
|
||||
}
|
||||
fm.vmessItem = index >= 0 ? lstVmess[index] : null;
|
||||
fm.groupId = groupId;
|
||||
fm.eConfigType = configType;
|
||||
@@ -688,8 +741,7 @@ namespace v2rayN.Forms
|
||||
private void menuRemoveDuplicateServer_Click(object sender, EventArgs e)
|
||||
{
|
||||
int oldCount = lstVmess.Count;
|
||||
ConfigHandler.DedupServerList(ref config, ref lstVmess);
|
||||
int newCount = lstVmess.Count;
|
||||
int newCount = ConfigHandler.DedupServerList(ref config, ref lstVmess);
|
||||
RefreshServers();
|
||||
_ = LoadV2ray();
|
||||
UI.Show(string.Format(UIRes.I18N("RemoveDuplicateServerResult"), oldCount, newCount));
|
||||
@@ -721,11 +773,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)
|
||||
@@ -738,7 +790,7 @@ namespace v2rayN.Forms
|
||||
|
||||
//UI.Show(UIRes.I18N("SpeedServerTips"));
|
||||
|
||||
Speedtest("realping");
|
||||
Speedtest(ESpeedActionType.Realping);
|
||||
}
|
||||
|
||||
private void menuSpeedServer_Click(object sender, EventArgs e)
|
||||
@@ -751,13 +803,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)
|
||||
@@ -964,7 +1016,7 @@ namespace v2rayN.Forms
|
||||
private void menuAddServers_Click(object sender, EventArgs e)
|
||||
{
|
||||
string clipboardData = Utils.GetClipboardData();
|
||||
int ret = MainFormHandler.Instance.AddBatchServers(config, clipboardData, "", groupId);
|
||||
int ret = ConfigHandler.AddBatchServers(ref config, clipboardData, "", groupId);
|
||||
if (ret > 0)
|
||||
{
|
||||
RefreshServers();
|
||||
@@ -994,7 +1046,7 @@ namespace v2rayN.Forms
|
||||
}
|
||||
else
|
||||
{
|
||||
int ret = MainFormHandler.Instance.AddBatchServers(config, result, "", groupId);
|
||||
int ret = ConfigHandler.AddBatchServers(ref config, result, "", groupId);
|
||||
if (ret > 0)
|
||||
{
|
||||
RefreshServers();
|
||||
@@ -1281,7 +1333,9 @@ namespace v2rayN.Forms
|
||||
item.Selected = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void menuMoveToGroup_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 系统代理相关
|
||||
@@ -1338,15 +1392,15 @@ namespace v2rayN.Forms
|
||||
|
||||
private void tsbCheckUpdateCore_Click(object sender, EventArgs e)
|
||||
{
|
||||
CheckUpdateCore("v2fly");
|
||||
CheckUpdateCore(ECoreType.v2fly);
|
||||
}
|
||||
|
||||
private void tsbCheckUpdateXrayCore_Click(object sender, EventArgs e)
|
||||
{
|
||||
CheckUpdateCore("xray");
|
||||
CheckUpdateCore(ECoreType.Xray);
|
||||
}
|
||||
|
||||
private void CheckUpdateCore(string type)
|
||||
private void CheckUpdateCore(ECoreType type)
|
||||
{
|
||||
void _updateUI(bool success, string msg)
|
||||
{
|
||||
|
||||
@@ -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>
|
||||
@@ -146,7 +146,7 @@ namespace v2rayN.Forms
|
||||
config.coreTypeItem.Add(new CoreTypeItem()
|
||||
{
|
||||
configType = it,
|
||||
coreType = ECoreType.v2fly
|
||||
coreType = ECoreType.Xray
|
||||
});
|
||||
}
|
||||
for (int k = 1; k <= config.coreTypeItem.Count; k++)
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace v2rayN.Forms
|
||||
lvRoutings.View = View.Details;
|
||||
lvRoutings.MultiSelect = true;
|
||||
lvRoutings.HeaderStyle = ColumnHeaderStyle.Clickable;
|
||||
lvRoutings.RegisterDragEvent(UpdateDragEventHandler);
|
||||
|
||||
lvRoutings.Columns.Add("", 30);
|
||||
lvRoutings.Columns.Add("outboundTag", 80);
|
||||
@@ -61,11 +62,22 @@ namespace v2rayN.Forms
|
||||
lvRoutings.Columns.Add("protocol", 80);
|
||||
lvRoutings.Columns.Add("inboundTag", 80);
|
||||
lvRoutings.Columns.Add("domain", 160);
|
||||
lvRoutings.Columns.Add("ip", 160);
|
||||
lvRoutings.Columns.Add("ip", 160);
|
||||
lvRoutings.Columns.Add("enable", 60);
|
||||
|
||||
lvRoutings.EndUpdate();
|
||||
}
|
||||
private void UpdateDragEventHandler(int index, int targetIndex)
|
||||
{
|
||||
if (index < 0 || targetIndex < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (ConfigHandler.MoveRoutingRule(ref routingItem, index, EMove.Position, targetIndex) == 0)
|
||||
{
|
||||
RefreshRoutingsView();
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshRoutingsView()
|
||||
{
|
||||
@@ -353,6 +365,6 @@ namespace v2rayN.Forms
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,9 @@ namespace v2rayN
|
||||
public const string xrayCoreUrl = "https://github.com/XTLS/Xray-core/releases";
|
||||
public const string NUrl = @"https://github.com/2dust/v2rayN/releases";
|
||||
public const string clashCoreUrl = "https://github.com/Dreamacro/clash/releases";
|
||||
public const string hysteriaCoreUrl = "https://github.com/HyNetwork/hysteria/releases";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace v2rayN.Handler
|
||||
class ConfigHandler
|
||||
{
|
||||
private static string configRes = Global.ConfigFileName;
|
||||
private static object objLock = new object();
|
||||
|
||||
#region ConfigHandler
|
||||
|
||||
@@ -184,6 +185,31 @@ namespace v2rayN.Handler
|
||||
LazyConfig.Instance.SetConfig(ref config);
|
||||
return 0;
|
||||
}
|
||||
/// <summary>
|
||||
/// 保参数
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <returns></returns>
|
||||
public static int SaveConfig(ref Config config, bool reload = true)
|
||||
{
|
||||
Global.reloadV2ray = reload;
|
||||
|
||||
ToJsonFile(config);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 存储文件
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
private static void ToJsonFile(Config config)
|
||||
{
|
||||
lock (objLock)
|
||||
{
|
||||
Utils.ToJsonFile(config, Utils.GetPath(configRes));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -235,7 +261,7 @@ namespace v2rayN.Handler
|
||||
var index = config.FindIndexId(item.indexId);
|
||||
if (index >= 0)
|
||||
{
|
||||
config.vmess.RemoveAt(index);
|
||||
RemoveVmessItem(config, index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,29 +349,6 @@ namespace v2rayN.Handler
|
||||
return config.vmess[index];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保参数
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <returns></returns>
|
||||
public static int SaveConfig(ref Config config, bool reload = true)
|
||||
{
|
||||
Global.reloadV2ray = reload;
|
||||
|
||||
ToJsonFile(config);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 存储文件
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
private static void ToJsonFile(Config config)
|
||||
{
|
||||
Utils.ToJsonFile(config, Utils.GetPath(configRes));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移动服务器
|
||||
/// </summary>
|
||||
@@ -354,7 +357,7 @@ namespace v2rayN.Handler
|
||||
/// <param name="index"></param>
|
||||
/// <param name="eMove"></param>
|
||||
/// <returns></returns>
|
||||
public static int MoveServer(ref Config config, ref List<VmessItem> lstVmess, int index, EMove eMove)
|
||||
public static int MoveServer(ref Config config, ref List<VmessItem> lstVmess, int index, EMove eMove, int pos = -1)
|
||||
{
|
||||
int count = lstVmess.Count;
|
||||
if (index < 0 || index > lstVmess.Count - 1)
|
||||
@@ -410,6 +413,9 @@ namespace v2rayN.Handler
|
||||
|
||||
break;
|
||||
}
|
||||
case EMove.Position:
|
||||
lstVmess[index].sort = pos * 10 + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
ToJsonFile(config);
|
||||
@@ -423,7 +429,7 @@ namespace v2rayN.Handler
|
||||
/// <param name="config"></param>
|
||||
/// <param name="vmessItem"></param>
|
||||
/// <returns></returns>
|
||||
public static int AddCustomServer(ref Config config, VmessItem vmessItem)
|
||||
public static int AddCustomServer(ref Config config, VmessItem vmessItem, bool blDelete)
|
||||
{
|
||||
var fileName = vmessItem.address;
|
||||
if (!File.Exists(fileName))
|
||||
@@ -436,7 +442,11 @@ namespace v2rayN.Handler
|
||||
|
||||
try
|
||||
{
|
||||
File.Copy(fileName, Path.Combine(Utils.GetTempPath(), newFileName));
|
||||
File.Copy(fileName, Path.Combine(Utils.GetConfigPath(), newFileName));
|
||||
if (blDelete)
|
||||
{
|
||||
File.Delete(fileName);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -485,7 +495,7 @@ namespace v2rayN.Handler
|
||||
vmessItem.id = vmessItem.id.TrimEx();
|
||||
vmessItem.security = vmessItem.security.TrimEx();
|
||||
|
||||
if (!config.GetShadowsocksSecuritys().Contains(vmessItem.security))
|
||||
if (!LazyConfig.Instance.GetShadowsocksSecuritys().Contains(vmessItem.security))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -522,7 +532,6 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加服务器或编辑
|
||||
/// </summary>
|
||||
@@ -619,178 +628,6 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量添加服务器
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <param name="clipboardData"></param>
|
||||
/// <param name="subid"></param>
|
||||
/// <returns>成功导入的数量</returns>
|
||||
public static int AddBatchServers(ref Config config, string clipboardData, string subid, List<VmessItem> lstOriSub, string groupId)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(clipboardData))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
//copy sub items
|
||||
if (!Utils.IsNullOrEmpty(subid))
|
||||
{
|
||||
RemoveServerViaSubid(ref config, subid);
|
||||
}
|
||||
//if (clipboardData.IndexOf("vmess") >= 0 && clipboardData.IndexOf("vmess") == clipboardData.LastIndexOf("vmess"))
|
||||
//{
|
||||
// clipboardData = clipboardData.Replace("\r\n", "").Replace("\n", "");
|
||||
//}
|
||||
int countServers = 0;
|
||||
|
||||
//string[] arrData = clipboardData.Split(new string[] { "\r\n" }, StringSplitOptions.None);
|
||||
string[] arrData = clipboardData.Split(Environment.NewLine.ToCharArray());
|
||||
foreach (string str in arrData)
|
||||
{
|
||||
//maybe sub
|
||||
if (Utils.IsNullOrEmpty(subid) && (str.StartsWith(Global.httpsProtocol) || str.StartsWith(Global.httpProtocol)))
|
||||
{
|
||||
if (AddSubItem(ref config, str) == 0)
|
||||
{
|
||||
countServers++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
VmessItem vmessItem = ShareHandler.ImportFromClipboardConfig(str, out string msg);
|
||||
if (vmessItem == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//exist sub items
|
||||
if (!Utils.IsNullOrEmpty(subid))
|
||||
{
|
||||
var existItem = lstOriSub?.FirstOrDefault(t => CompareVmessItem(t, vmessItem, true));
|
||||
if (existItem != null)
|
||||
{
|
||||
vmessItem = existItem;
|
||||
}
|
||||
vmessItem.subid = subid;
|
||||
}
|
||||
|
||||
//groupId
|
||||
vmessItem.groupId = groupId;
|
||||
|
||||
if (vmessItem.configType == EConfigType.Vmess)
|
||||
{
|
||||
if (AddServer(ref config, vmessItem, false) == 0)
|
||||
{
|
||||
countServers++;
|
||||
}
|
||||
}
|
||||
else if (vmessItem.configType == EConfigType.Shadowsocks)
|
||||
{
|
||||
if (AddShadowsocksServer(ref config, vmessItem, false) == 0)
|
||||
{
|
||||
countServers++;
|
||||
}
|
||||
}
|
||||
else if (vmessItem.configType == EConfigType.Socks)
|
||||
{
|
||||
if (AddSocksServer(ref config, vmessItem, false) == 0)
|
||||
{
|
||||
countServers++;
|
||||
}
|
||||
}
|
||||
else if (vmessItem.configType == EConfigType.Trojan)
|
||||
{
|
||||
if (AddTrojanServer(ref config, vmessItem, false) == 0)
|
||||
{
|
||||
countServers++;
|
||||
}
|
||||
}
|
||||
else if (vmessItem.configType == EConfigType.VLESS)
|
||||
{
|
||||
if (AddVlessServer(ref config, vmessItem, false) == 0)
|
||||
{
|
||||
countServers++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ToJsonFile(config);
|
||||
return countServers;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// add sub
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <param name="url"></param>
|
||||
/// <returns></returns>
|
||||
public static int AddSubItem(ref Config config, string url)
|
||||
{
|
||||
//already exists
|
||||
if (config.subItem.FindIndex(e => e.url == url) >= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SubItem subItem = new SubItem
|
||||
{
|
||||
id = string.Empty,
|
||||
remarks = "import sub",
|
||||
url = url
|
||||
};
|
||||
config.subItem.Add(subItem);
|
||||
|
||||
return SaveSubItem(ref config);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// save sub
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <returns></returns>
|
||||
public static int SaveSubItem(ref Config config)
|
||||
{
|
||||
if (config.subItem == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
foreach (SubItem item in config.subItem)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(item.id))
|
||||
{
|
||||
item.id = Utils.GetGUID(false);
|
||||
}
|
||||
}
|
||||
|
||||
ToJsonFile(config);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除服务器
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <param name="subid"></param>
|
||||
/// <returns></returns>
|
||||
public static int RemoveServerViaSubid(ref Config config, string subid)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(subid) || config.vmess.Count <= 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
for (int k = config.vmess.Count - 1; k >= 0; k--)
|
||||
{
|
||||
if (config.vmess[k].subid.Equals(subid))
|
||||
{
|
||||
config.vmess.RemoveAt(k);
|
||||
}
|
||||
}
|
||||
|
||||
ToJsonFile(config);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int SortServers(ref Config config, ref List<VmessItem> lstVmess, EServerColName name, bool asc)
|
||||
{
|
||||
if (lstVmess.Count <= 0)
|
||||
@@ -884,14 +721,14 @@ namespace v2rayN.Handler
|
||||
var index = config.FindIndexId(item.indexId);
|
||||
if (index >= 0)
|
||||
{
|
||||
config.vmess.RemoveAt(index);
|
||||
RemoveVmessItem(config, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
//if (!keepOlder) list.Reverse();
|
||||
//config.vmess = list;
|
||||
|
||||
return 0;
|
||||
return list.Count;
|
||||
}
|
||||
|
||||
public static int AddServerCommon(ref Config config, VmessItem vmessItem)
|
||||
@@ -949,6 +786,300 @@ namespace v2rayN.Handler
|
||||
&& (remarks ? o.remarks == n.remarks : true);
|
||||
}
|
||||
|
||||
private static int RemoveVmessItem(Config config, int index)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (config.vmess[index].configType == EConfigType.Custom)
|
||||
{
|
||||
File.Delete(Utils.GetConfigPath(config.vmess[index].address));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utils.SaveLog("RemoveVmessItem", ex);
|
||||
}
|
||||
config.vmess.RemoveAt(index);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Batch add servers
|
||||
|
||||
/// <summary>
|
||||
/// 批量添加服务器
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <param name="clipboardData"></param>
|
||||
/// <param name="subid"></param>
|
||||
/// <returns>成功导入的数量</returns>
|
||||
private static int AddBatchServers(ref Config config, string clipboardData, string subid, List<VmessItem> lstOriSub, string groupId)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(clipboardData))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
//copy sub items
|
||||
if (!Utils.IsNullOrEmpty(subid))
|
||||
{
|
||||
RemoveServerViaSubid(ref config, subid);
|
||||
}
|
||||
//if (clipboardData.IndexOf("vmess") >= 0 && clipboardData.IndexOf("vmess") == clipboardData.LastIndexOf("vmess"))
|
||||
//{
|
||||
// clipboardData = clipboardData.Replace("\r\n", "").Replace("\n", "");
|
||||
//}
|
||||
int countServers = 0;
|
||||
|
||||
//string[] arrData = clipboardData.Split(new string[] { "\r\n" }, StringSplitOptions.None);
|
||||
string[] arrData = clipboardData.Split(Environment.NewLine.ToCharArray());
|
||||
foreach (string str in arrData)
|
||||
{
|
||||
//maybe sub
|
||||
if (Utils.IsNullOrEmpty(subid) && (str.StartsWith(Global.httpsProtocol) || str.StartsWith(Global.httpProtocol)))
|
||||
{
|
||||
if (AddSubItem(ref config, str) == 0)
|
||||
{
|
||||
countServers++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
VmessItem vmessItem = ShareHandler.ImportFromClipboardConfig(str, out string msg);
|
||||
if (vmessItem == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//exist sub items
|
||||
if (!Utils.IsNullOrEmpty(subid))
|
||||
{
|
||||
var existItem = lstOriSub?.FirstOrDefault(t => CompareVmessItem(t, vmessItem, true));
|
||||
if (existItem != null)
|
||||
{
|
||||
vmessItem = existItem;
|
||||
}
|
||||
vmessItem.subid = subid;
|
||||
}
|
||||
|
||||
//groupId
|
||||
vmessItem.groupId = groupId;
|
||||
|
||||
if (vmessItem.configType == EConfigType.Vmess)
|
||||
{
|
||||
if (AddServer(ref config, vmessItem, false) == 0)
|
||||
{
|
||||
countServers++;
|
||||
}
|
||||
}
|
||||
else if (vmessItem.configType == EConfigType.Shadowsocks)
|
||||
{
|
||||
if (AddShadowsocksServer(ref config, vmessItem, false) == 0)
|
||||
{
|
||||
countServers++;
|
||||
}
|
||||
}
|
||||
else if (vmessItem.configType == EConfigType.Socks)
|
||||
{
|
||||
if (AddSocksServer(ref config, vmessItem, false) == 0)
|
||||
{
|
||||
countServers++;
|
||||
}
|
||||
}
|
||||
else if (vmessItem.configType == EConfigType.Trojan)
|
||||
{
|
||||
if (AddTrojanServer(ref config, vmessItem, false) == 0)
|
||||
{
|
||||
countServers++;
|
||||
}
|
||||
}
|
||||
else if (vmessItem.configType == EConfigType.VLESS)
|
||||
{
|
||||
if (AddVlessServer(ref config, vmessItem, false) == 0)
|
||||
{
|
||||
countServers++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ToJsonFile(config);
|
||||
return countServers;
|
||||
}
|
||||
|
||||
private static int AddBatchServers4Custom(ref Config config, string clipboardData, string subid, List<VmessItem> lstOriSub, string groupId)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(clipboardData))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
VmessItem vmessItem = new VmessItem();
|
||||
//Is v2ray configuration
|
||||
V2rayConfig v2rayConfig = Utils.FromJson<V2rayConfig>(clipboardData);
|
||||
if (v2rayConfig != null
|
||||
&& v2rayConfig.inbounds != null
|
||||
&& v2rayConfig.inbounds.Count > 0
|
||||
&& v2rayConfig.outbounds != null
|
||||
&& v2rayConfig.outbounds.Count > 0)
|
||||
{
|
||||
var fileName = Utils.GetTempPath($"{Utils.GetGUID(false)}.json");
|
||||
File.WriteAllText(fileName, clipboardData);
|
||||
|
||||
vmessItem.coreType = ECoreType.Xray;
|
||||
vmessItem.address = fileName;
|
||||
vmessItem.remarks = "v2ray_custom";
|
||||
}
|
||||
//Is Clash configuration
|
||||
else if (clipboardData.IndexOf("port") >= 0
|
||||
&& clipboardData.IndexOf("socks-port") >= 0
|
||||
&& clipboardData.IndexOf("proxies") >= 0)
|
||||
{
|
||||
var fileName = Utils.GetTempPath($"{Utils.GetGUID(false)}.yaml");
|
||||
File.WriteAllText(fileName, clipboardData);
|
||||
|
||||
vmessItem.coreType = ECoreType.clash;
|
||||
vmessItem.address = fileName;
|
||||
vmessItem.remarks = "clash_custom";
|
||||
}
|
||||
//Is Other configuration
|
||||
else
|
||||
{
|
||||
var fileName = Utils.GetTempPath($"{Utils.GetGUID(false)}.txt");
|
||||
File.WriteAllText(fileName, clipboardData);
|
||||
|
||||
vmessItem.address = fileName;
|
||||
vmessItem.remarks = "other_custom";
|
||||
}
|
||||
|
||||
if (!Utils.IsNullOrEmpty(subid))
|
||||
{
|
||||
RemoveServerViaSubid(ref config, subid);
|
||||
}
|
||||
if (lstOriSub != null && lstOriSub.Count == 1)
|
||||
{
|
||||
vmessItem.indexId = lstOriSub[0].indexId;
|
||||
}
|
||||
vmessItem.subid = subid;
|
||||
vmessItem.groupId = groupId;
|
||||
|
||||
if (Utils.IsNullOrEmpty(vmessItem.address))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (AddCustomServer(ref config, vmessItem, true) == 0)
|
||||
{
|
||||
return 1;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public static int AddBatchServers(ref Config config, string clipboardData, string subid, string groupId)
|
||||
{
|
||||
List<VmessItem> lstOriSub = null;
|
||||
if (!Utils.IsNullOrEmpty(subid))
|
||||
{
|
||||
lstOriSub = config.vmess.Where(it => it.subid == subid).ToList();
|
||||
}
|
||||
|
||||
int counter = AddBatchServers(ref config, clipboardData, subid, lstOriSub, groupId);
|
||||
if (counter < 1)
|
||||
{
|
||||
counter = AddBatchServers(ref config, Utils.Base64Decode(clipboardData), subid, lstOriSub, groupId);
|
||||
}
|
||||
|
||||
//maybe other sub
|
||||
if (counter < 1)
|
||||
{
|
||||
counter = AddBatchServers4Custom(ref config, clipboardData, subid, lstOriSub, groupId);
|
||||
}
|
||||
|
||||
return counter;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Sub & Group
|
||||
|
||||
/// <summary>
|
||||
/// add sub
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <param name="url"></param>
|
||||
/// <returns></returns>
|
||||
public static int AddSubItem(ref Config config, string url)
|
||||
{
|
||||
//already exists
|
||||
if (config.subItem.FindIndex(e => e.url == url) >= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SubItem subItem = new SubItem
|
||||
{
|
||||
id = string.Empty,
|
||||
remarks = "import sub",
|
||||
url = url
|
||||
};
|
||||
config.subItem.Add(subItem);
|
||||
|
||||
return SaveSubItem(ref config);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// save sub
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <returns></returns>
|
||||
public static int SaveSubItem(ref Config config)
|
||||
{
|
||||
if (config.subItem == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
foreach (SubItem item in config.subItem)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(item.id))
|
||||
{
|
||||
item.id = Utils.GetGUID(false);
|
||||
}
|
||||
}
|
||||
|
||||
ToJsonFile(config);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除服务器
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <param name="subid"></param>
|
||||
/// <returns></returns>
|
||||
public static int RemoveServerViaSubid(ref Config config, string subid)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(subid) || config.vmess.Count <= 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
for (int k = config.vmess.Count - 1; k >= 0; k--)
|
||||
{
|
||||
if (config.vmess[k].subid.Equals(subid))
|
||||
{
|
||||
RemoveVmessItem(config, k);
|
||||
}
|
||||
}
|
||||
|
||||
ToJsonFile(config);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// save Group
|
||||
/// </summary>
|
||||
@@ -999,6 +1130,18 @@ namespace v2rayN.Handler
|
||||
ToJsonFile(config);
|
||||
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
|
||||
@@ -1131,7 +1274,7 @@ namespace v2rayN.Handler
|
||||
/// <param name="index"></param>
|
||||
/// <param name="eMove"></param>
|
||||
/// <returns></returns>
|
||||
public static int MoveRoutingRule(ref RoutingItem routingItem, int index, EMove eMove)
|
||||
public static int MoveRoutingRule(ref RoutingItem routingItem, int index, EMove eMove, int pos = -1)
|
||||
{
|
||||
int count = routingItem.rules.Count;
|
||||
if (index < 0 || index > routingItem.rules.Count - 1)
|
||||
@@ -1189,6 +1332,14 @@ namespace v2rayN.Handler
|
||||
|
||||
break;
|
||||
}
|
||||
case EMove.Position:
|
||||
{
|
||||
var removeItem = routingItem.rules[index];
|
||||
var item = Utils.DeepCopy(routingItem.rules[index]);
|
||||
routingItem.rules.Insert(pos, item);
|
||||
routingItem.rules.Remove(removeItem);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using v2rayN.Base;
|
||||
|
||||
namespace v2rayN.Handler
|
||||
@@ -139,6 +140,7 @@ namespace v2rayN.Handler
|
||||
Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().enableSecurityProtocolTls13);
|
||||
|
||||
WebClientEx ws = new WebClientEx();
|
||||
ws.Encoding = Encoding.UTF8;
|
||||
if (webProxy != null)
|
||||
{
|
||||
ws.Proxy = webProxy;
|
||||
@@ -197,7 +199,7 @@ namespace v2rayN.Handler
|
||||
Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().enableSecurityProtocolTls13);
|
||||
|
||||
WebClientEx ws = new WebClientEx();
|
||||
|
||||
ws.Encoding = Encoding.UTF8;
|
||||
return ws.DownloadString(new Uri(url));
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using v2rayN.Mode;
|
||||
using System.Linq;
|
||||
|
||||
namespace v2rayN.Handler
|
||||
{
|
||||
@@ -7,6 +9,7 @@ namespace v2rayN.Handler
|
||||
{
|
||||
private static readonly Lazy<LazyConfig> _instance = new Lazy<LazyConfig>(() => new LazyConfig());
|
||||
private Config _config;
|
||||
private List<CoreInfo> coreInfos;
|
||||
|
||||
public static LazyConfig Instance
|
||||
{
|
||||
@@ -20,5 +23,82 @@ namespace v2rayN.Handler
|
||||
{
|
||||
return _config;
|
||||
}
|
||||
|
||||
public List<string> GetShadowsocksSecuritys()
|
||||
{
|
||||
if (GetCoreType(null, EConfigType.Shadowsocks) == ECoreType.v2fly)
|
||||
{
|
||||
return Global.ssSecuritys;
|
||||
}
|
||||
|
||||
return Global.ssSecuritysInXray;
|
||||
}
|
||||
|
||||
public ECoreType GetCoreType(VmessItem vmessItem, EConfigType eConfigType)
|
||||
{
|
||||
if (vmessItem != null && vmessItem.coreType != null)
|
||||
{
|
||||
return (ECoreType)vmessItem.coreType;
|
||||
}
|
||||
|
||||
if (_config.coreTypeItem == null)
|
||||
{
|
||||
return ECoreType.Xray;
|
||||
}
|
||||
var item = _config.coreTypeItem.FirstOrDefault(it => it.configType == eConfigType);
|
||||
if (item == null)
|
||||
{
|
||||
return ECoreType.Xray;
|
||||
}
|
||||
return item.coreType;
|
||||
}
|
||||
|
||||
public CoreInfo GetCoreInfo(ECoreType coreType)
|
||||
{
|
||||
if (coreInfos == null)
|
||||
{
|
||||
InitCoreInfo();
|
||||
}
|
||||
return coreInfos.Where(t => t.coreType == coreType).FirstOrDefault();
|
||||
}
|
||||
|
||||
private void InitCoreInfo()
|
||||
{
|
||||
coreInfos = new List<CoreInfo>();
|
||||
|
||||
coreInfos.Add(new CoreInfo
|
||||
{
|
||||
coreType = ECoreType.v2fly,
|
||||
coreExes = new List<string> { "wv2ray", "v2ray" },
|
||||
arguments = "",
|
||||
coreUrl = Global.v2flyCoreUrl
|
||||
|
||||
});
|
||||
|
||||
coreInfos.Add(new CoreInfo
|
||||
{
|
||||
coreType = ECoreType.Xray,
|
||||
coreExes = new List<string> { "xray" },
|
||||
arguments = "",
|
||||
coreUrl = Global.xrayCoreUrl
|
||||
});
|
||||
|
||||
coreInfos.Add(new CoreInfo
|
||||
{
|
||||
coreType = ECoreType.clash,
|
||||
coreExes = new List<string> { "clash-windows-amd64", "clash-windows-386", "clash" },
|
||||
arguments = "-f config.json",
|
||||
coreUrl = Global.clashCoreUrl
|
||||
});
|
||||
|
||||
coreInfos.Add(new CoreInfo
|
||||
{
|
||||
coreType = ECoreType.hysteria,
|
||||
coreExes = new List<string> { "hysteria-tun-windows-6.0-amd64", "hysteria-tun-windows-6.0-386", "hysteria" },
|
||||
arguments = "",
|
||||
coreUrl = Global.hysteriaCoreUrl
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace v2rayN.Handler
|
||||
if (!Utils.IsNullOrEmpty(item.customIcon) && File.Exists(item.customIcon))
|
||||
{
|
||||
graphics.FillRectangle(drawBrush, new Rectangle(0, 0, width, height));
|
||||
graphics.DrawImage(new Bitmap(item.customIcon), 0, 0);
|
||||
graphics.DrawImage(new Bitmap(item.customIcon), 0, 0, width, height);
|
||||
customIcon = true;
|
||||
}
|
||||
}
|
||||
@@ -159,29 +159,12 @@ namespace v2rayN.Handler
|
||||
}
|
||||
}
|
||||
|
||||
public int AddBatchServers(Config config, string clipboardData, string subid, string groupId)
|
||||
{
|
||||
List<VmessItem> lstOriSub = null;
|
||||
if (!Utils.IsNullOrEmpty(subid))
|
||||
{
|
||||
lstOriSub = config.vmess.Where(it => it.subid == subid).ToList();
|
||||
}
|
||||
|
||||
int counter = ConfigHandler.AddBatchServers(ref config, clipboardData, subid, lstOriSub, groupId);
|
||||
if (counter < 1)
|
||||
{
|
||||
counter = ConfigHandler.AddBatchServers(ref config, Utils.Base64Decode(clipboardData), subid, lstOriSub, groupId);
|
||||
}
|
||||
|
||||
return counter;
|
||||
}
|
||||
|
||||
public void BackupGuiNConfig(Config config, bool auto = false)
|
||||
{
|
||||
string fileName = $"guiNConfig_{DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_fff")}.json";
|
||||
if (auto)
|
||||
{
|
||||
fileName = Utils.GetTempPath(fileName);
|
||||
fileName = Utils.GetBackupPath(fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -104,11 +104,11 @@ namespace v2rayN.Handler
|
||||
}
|
||||
};
|
||||
_updateFunc(false, string.Format(UIRes.I18N("MsgStartUpdating"), "v2rayN"));
|
||||
CheckUpdateAsync("v2rayN");
|
||||
CheckUpdateAsync(ECoreType.v2rayN);
|
||||
}
|
||||
|
||||
|
||||
public void CheckUpdateCore(string type, Config config, Action<bool, string> update)
|
||||
public void CheckUpdateCore(ECoreType type, Config config, Action<bool, string> update)
|
||||
{
|
||||
_config = config;
|
||||
_updateFunc = update;
|
||||
@@ -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;
|
||||
@@ -210,7 +210,7 @@ namespace v2rayN.Handler
|
||||
//ConfigHandler.RemoveServerViaSubid(ref config, id);
|
||||
//_updateFunc(false, $"{hashCode}{UIRes.I18N("MsgClearSubscription")}");
|
||||
// RefreshServers();
|
||||
int ret = MainFormHandler.Instance.AddBatchServers(config, result, id, groupId);
|
||||
int ret = ConfigHandler.AddBatchServers(ref config, result, id, groupId);
|
||||
if (ret > 0)
|
||||
{
|
||||
// RefreshServers();
|
||||
@@ -292,7 +292,7 @@ namespace v2rayN.Handler
|
||||
|
||||
#region private
|
||||
|
||||
private async void CheckUpdateAsync(string type)
|
||||
private async void CheckUpdateAsync(ECoreType type)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -310,15 +310,15 @@ namespace v2rayN.Handler
|
||||
HttpClient httpClient = new HttpClient(webRequestHandler);
|
||||
|
||||
string url;
|
||||
if (type == "v2fly")
|
||||
if (type == ECoreType.v2fly)
|
||||
{
|
||||
url = v2flyCoreLatestUrl;
|
||||
}
|
||||
else if (type == "xray")
|
||||
else if (type == ECoreType.Xray)
|
||||
{
|
||||
url = xrayCoreLatestUrl;
|
||||
}
|
||||
else if (type == "v2rayN")
|
||||
else if (type == ECoreType.v2rayN)
|
||||
{
|
||||
url = nLatestUrl;
|
||||
}
|
||||
@@ -347,18 +347,18 @@ namespace v2rayN.Handler
|
||||
/// <summary>
|
||||
/// 获取V2RayCore版本
|
||||
/// </summary>
|
||||
private string getCoreVersion(string type)
|
||||
private string getCoreVersion(ECoreType type)
|
||||
{
|
||||
try
|
||||
{
|
||||
var core = string.Empty;
|
||||
var match = string.Empty;
|
||||
if (type == "v2fly")
|
||||
if (type == ECoreType.v2fly)
|
||||
{
|
||||
core = "v2ray.exe";
|
||||
match = "V2Ray";
|
||||
}
|
||||
else if (type == "xray")
|
||||
else if (type == ECoreType.Xray)
|
||||
{
|
||||
core = "xray.exe";
|
||||
match = "Xray";
|
||||
@@ -392,7 +392,7 @@ namespace v2rayN.Handler
|
||||
return "";
|
||||
}
|
||||
}
|
||||
private void responseHandler(string type, string redirectUrl)
|
||||
private void responseHandler(ECoreType type, string redirectUrl)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -401,21 +401,21 @@ namespace v2rayN.Handler
|
||||
string curVersion;
|
||||
string message;
|
||||
string url;
|
||||
if (type == "v2fly")
|
||||
if (type == ECoreType.v2fly)
|
||||
{
|
||||
curVersion = "v" + getCoreVersion(type);
|
||||
message = string.Format(UIRes.I18N("IsLatestCore"), curVersion);
|
||||
string osBit = Environment.Is64BitProcess ? "64" : "32";
|
||||
url = string.Format(v2flyCoreUrl, version, osBit);
|
||||
}
|
||||
else if (type == "xray")
|
||||
else if (type == ECoreType.Xray)
|
||||
{
|
||||
curVersion = "v" + getCoreVersion(type);
|
||||
message = string.Format(UIRes.I18N("IsLatestCore"), curVersion);
|
||||
string osBit = Environment.Is64BitProcess ? "64" : "32";
|
||||
url = string.Format(xrayCoreUrl, version, osBit);
|
||||
}
|
||||
else if (type == "v2rayN")
|
||||
else if (type == ECoreType.v2rayN)
|
||||
{
|
||||
curVersion = FileVersionInfo.GetVersionInfo(Utils.GetExePath()).FileVersion.ToString();
|
||||
message = string.Format(UIRes.I18N("IsLatestN"), curVersion);
|
||||
|
||||
@@ -168,6 +168,7 @@ namespace v2rayN.Handler
|
||||
inbound2.protocol = Global.InboundHttp;
|
||||
inbound2.listen = inbound.listen;
|
||||
inbound2.settings.allowTransparent = false;
|
||||
inbound2.sniffing.enabled = inbound.sniffing.enabled;
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -400,7 +401,7 @@ namespace v2rayN.Handler
|
||||
serversItem.address = node.address;
|
||||
serversItem.port = node.port;
|
||||
serversItem.password = node.id;
|
||||
if (config.GetShadowsocksSecuritys().Contains(node.security))
|
||||
if (LazyConfig.Instance.GetShadowsocksSecuritys().Contains(node.security))
|
||||
{
|
||||
serversItem.method = node.security;
|
||||
}
|
||||
@@ -912,7 +913,7 @@ namespace v2rayN.Handler
|
||||
string addressFileName = node.address;
|
||||
if (!File.Exists(addressFileName))
|
||||
{
|
||||
addressFileName = Path.Combine(Utils.GetTempPath(), addressFileName);
|
||||
addressFileName = Path.Combine(Utils.GetConfigPath(), addressFileName);
|
||||
}
|
||||
if (!File.Exists(addressFileName))
|
||||
{
|
||||
@@ -921,10 +922,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,9 +21,7 @@ namespace v2rayN.Handler
|
||||
class V2rayHandler
|
||||
{
|
||||
private static string v2rayConfigRes = Global.v2rayConfigFileName;
|
||||
private List<string> lstV2ray;
|
||||
private string coreUrl;
|
||||
private string coreArguments;
|
||||
private CoreInfo coreInfo;
|
||||
public event ProcessDelegate ProcessEvent;
|
||||
//private int processId = 0;
|
||||
private Process _process;
|
||||
@@ -46,7 +44,11 @@ namespace v2rayN.Handler
|
||||
return;
|
||||
}
|
||||
|
||||
SetCore(config, item);
|
||||
if (SetCore(config, item) != 0)
|
||||
{
|
||||
ShowMsg(false, UIRes.I18N("CheckServerSettings"));
|
||||
return;
|
||||
}
|
||||
string fileName = Utils.GetPath(v2rayConfigRes);
|
||||
if (V2rayConfigHandler.GenerateClientConfig(item, fileName, false, out string msg) != 0)
|
||||
{
|
||||
@@ -106,7 +108,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (string vName in lstV2ray)
|
||||
foreach (string vName in coreInfo.coreExes)
|
||||
{
|
||||
Process[] existing = Process.GetProcessesByName(vName);
|
||||
foreach (Process p in existing)
|
||||
@@ -163,12 +165,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);
|
||||
@@ -180,7 +180,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
if (Utils.IsNullOrEmpty(fileName))
|
||||
{
|
||||
string msg = string.Format(UIRes.I18N("NotFoundCore"), coreUrl);
|
||||
string msg = string.Format(UIRes.I18N("NotFoundCore"), coreInfo.coreUrl);
|
||||
ShowMsg(false, msg);
|
||||
}
|
||||
return fileName;
|
||||
@@ -195,7 +195,7 @@ namespace v2rayN.Handler
|
||||
|
||||
try
|
||||
{
|
||||
string fileName = V2rayFindexe();
|
||||
string fileName = V2rayFindexe(coreInfo.coreExes);
|
||||
if (fileName == "") return;
|
||||
|
||||
Process p = new Process
|
||||
@@ -203,7 +203,7 @@ namespace v2rayN.Handler
|
||||
StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = fileName,
|
||||
Arguments = coreArguments,
|
||||
Arguments = coreInfo.arguments,
|
||||
WorkingDirectory = Utils.StartupPath(),
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true,
|
||||
@@ -249,7 +249,7 @@ namespace v2rayN.Handler
|
||||
|
||||
try
|
||||
{
|
||||
string fileName = V2rayFindexe();
|
||||
string fileName = V2rayFindexe(new List<string> { "xray" });
|
||||
if (fileName == "") return -1;
|
||||
|
||||
Process p = new Process
|
||||
@@ -326,48 +326,21 @@ namespace v2rayN.Handler
|
||||
}
|
||||
}
|
||||
|
||||
private void SetCore(Config config, VmessItem item)
|
||||
private int SetCore(Config config, VmessItem item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var coreType = config.GetCoreType(item.configType);
|
||||
if (item.coreType != null)
|
||||
{
|
||||
coreType = (ECoreType)item.coreType;
|
||||
return -1;
|
||||
}
|
||||
var coreType = LazyConfig.Instance.GetCoreType(item, item.configType);
|
||||
|
||||
if (coreType == ECoreType.v2fly)
|
||||
coreInfo = LazyConfig.Instance.GetCoreInfo(coreType);
|
||||
|
||||
if (coreInfo == null)
|
||||
{
|
||||
lstV2ray = new List<string>
|
||||
{
|
||||
"wv2ray",
|
||||
"v2ray"
|
||||
};
|
||||
coreUrl = Global.v2flyCoreUrl;
|
||||
coreArguments = string.Empty;
|
||||
}
|
||||
else if (coreType == ECoreType.Xray)
|
||||
{
|
||||
lstV2ray = new List<string>
|
||||
{
|
||||
"xray"
|
||||
};
|
||||
coreUrl = Global.xrayCoreUrl;
|
||||
coreArguments = string.Empty;
|
||||
}
|
||||
else if (coreType == ECoreType.clash)
|
||||
{
|
||||
lstV2ray = new List<string>
|
||||
{
|
||||
"clash-windows-amd64",
|
||||
"clash-windows-386",
|
||||
"clash"
|
||||
};
|
||||
coreUrl = Global.clashCoreUrl;
|
||||
coreArguments = "-f config.json";
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,16 +256,6 @@ namespace v2rayN.Mode
|
||||
return vmess.FirstOrDefault(it => it.indexId == id);
|
||||
}
|
||||
|
||||
public List<string> GetShadowsocksSecuritys()
|
||||
{
|
||||
if (GetCoreType(EConfigType.Shadowsocks) == ECoreType.v2fly)
|
||||
{
|
||||
return Global.ssSecuritys;
|
||||
}
|
||||
|
||||
return Global.ssSecuritysInXray;
|
||||
}
|
||||
|
||||
public bool IsActiveNode(VmessItem item)
|
||||
{
|
||||
if (!Utils.IsNullOrEmpty(item.indexId) && item.indexId == indexId)
|
||||
@@ -285,19 +275,6 @@ namespace v2rayN.Mode
|
||||
return groupItem.Where(it => it.id == groupId).FirstOrDefault()?.remarks;
|
||||
}
|
||||
|
||||
public ECoreType GetCoreType(EConfigType eConfigType)
|
||||
{
|
||||
if (coreTypeItem == null)
|
||||
{
|
||||
return ECoreType.v2fly;
|
||||
}
|
||||
var item = coreTypeItem.FirstOrDefault(it => it.configType == eConfigType);
|
||||
if (item == null)
|
||||
{
|
||||
return ECoreType.v2fly;
|
||||
}
|
||||
return item.coreType;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -358,7 +335,7 @@ namespace v2rayN.Mode
|
||||
break;
|
||||
default:
|
||||
summary += string.Format("{0}", remarks);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
return summary;
|
||||
}
|
||||
|
||||
17
v2rayN/v2rayN/Mode/CoreInfo.cs
Normal file
17
v2rayN/v2rayN/Mode/CoreInfo.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace v2rayN.Mode
|
||||
{
|
||||
[Serializable]
|
||||
public class CoreInfo
|
||||
{
|
||||
public ECoreType coreType { get; set; }
|
||||
|
||||
public List<string> coreExes { get; set; }
|
||||
|
||||
public string arguments { get; set; }
|
||||
|
||||
public string coreUrl { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ namespace v2rayN.Mode
|
||||
{
|
||||
v2fly = 1,
|
||||
Xray = 2,
|
||||
clash = 3
|
||||
clash = 11,
|
||||
hysteria = 21,
|
||||
v2rayN = 99
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace v2rayN.Mode
|
||||
Top = 1,
|
||||
Up = 2,
|
||||
Down = 3,
|
||||
Bottom = 4
|
||||
Bottom = 4,
|
||||
Position = 5
|
||||
}
|
||||
}
|
||||
|
||||
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.4")]
|
||||
[assembly: AssemblyFileVersion("5.8")]
|
||||
|
||||
2
v2rayN/v2rayN/Resx/ResUI.Designer.cs
generated
2
v2rayN/v2rayN/Resx/ResUI.Designer.cs
generated
@@ -115,7 +115,7 @@ namespace v2rayN.Resx {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Note that custom configuration relies entirely on your own configuration and does not work with all settings. The system agent is available when the socks port is equal to the port in the settings in the custom configuration inbound. 的本地化字符串。
|
||||
/// 查找类似 Note that custom configuration relies entirely on your own configuration and does not work with all settings. If you want to use the system proxy, please modify the listening port manually. 的本地化字符串。
|
||||
/// </summary>
|
||||
internal static string CustomServerTips {
|
||||
get {
|
||||
|
||||
@@ -130,7 +130,7 @@
|
||||
<value> configuration format is incorrect</value>
|
||||
</data>
|
||||
<data name="CustomServerTips" xml:space="preserve">
|
||||
<value>Note that custom configuration relies entirely on your own configuration and does not work with all settings. The system agent is available when the socks port is equal to the port in the settings in the custom configuration inbound.</value>
|
||||
<value>Note that custom configuration relies entirely on your own configuration and does not work with all settings. If you want to use the system proxy, please modify the listening port manually.</value>
|
||||
</data>
|
||||
<data name="Downloading" xml:space="preserve">
|
||||
<value>Downloading...</value>
|
||||
|
||||
@@ -130,7 +130,7 @@
|
||||
<value>配置格式不正确</value>
|
||||
</data>
|
||||
<data name="CustomServerTips" xml:space="preserve">
|
||||
<value>注意,自定义配置完全依赖您自己的配置,不能使用所有设置功能。在自定义配置inbound中有socks port等于设置中的port时,系统代理才可用</value>
|
||||
<value>注意,自定义配置完全依赖您自己的配置,不能使用所有设置功能。如需使用系统代理请手工修改监听端口。</value>
|
||||
</data>
|
||||
<data name="Downloading" xml:space="preserve">
|
||||
<value>下载开始...</value>
|
||||
|
||||
@@ -943,19 +943,21 @@ namespace v2rayN
|
||||
#region TempPath
|
||||
|
||||
// return path to store temporary files
|
||||
public static string GetTempPath()
|
||||
public static string GetTempPath(string filename = "")
|
||||
{
|
||||
string _tempPath = Path.Combine(StartupPath(), "v2ray_win_temp");
|
||||
if (!Directory.Exists(_tempPath))
|
||||
{
|
||||
Directory.CreateDirectory(_tempPath);
|
||||
}
|
||||
return _tempPath;
|
||||
}
|
||||
|
||||
public static string GetTempPath(string filename)
|
||||
{
|
||||
return Path.Combine(GetTempPath(), filename);
|
||||
if (string.IsNullOrEmpty(filename))
|
||||
{
|
||||
return _tempPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Path.Combine(_tempPath, filename);
|
||||
}
|
||||
}
|
||||
|
||||
public static string UnGzip(byte[] buf)
|
||||
@@ -970,6 +972,32 @@ namespace v2rayN
|
||||
return Encoding.UTF8.GetString(sb.ToArray());
|
||||
}
|
||||
|
||||
public static string GetBackupPath(string filename)
|
||||
{
|
||||
string _tempPath = Path.Combine(StartupPath(), "guiBackups");
|
||||
if (!Directory.Exists(_tempPath))
|
||||
{
|
||||
Directory.CreateDirectory(_tempPath);
|
||||
}
|
||||
return Path.Combine(_tempPath, filename);
|
||||
}
|
||||
public static string GetConfigPath(string filename = "")
|
||||
{
|
||||
string _tempPath = Path.Combine(StartupPath(), "guiConfigs");
|
||||
if (!Directory.Exists(_tempPath))
|
||||
{
|
||||
Directory.CreateDirectory(_tempPath);
|
||||
}
|
||||
if (string.IsNullOrEmpty(filename))
|
||||
{
|
||||
return _tempPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Path.Combine(_tempPath, filename);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Log
|
||||
|
||||
@@ -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" />
|
||||
@@ -207,6 +208,7 @@
|
||||
<Compile Include="Mode\RoutingItem.cs" />
|
||||
<Compile Include="Mode\RulesItem.cs" />
|
||||
<Compile Include="Mode\ServerStatistics.cs" />
|
||||
<Compile Include="Mode\CoreInfo.cs" />
|
||||
<Compile Include="Mode\SysproxyConfig.cs" />
|
||||
<Compile Include="Mode\EConfigType.cs" />
|
||||
<Compile Include="Mode\ServerTestItem.cs" />
|
||||
|
||||
Reference in New Issue
Block a user