Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
685baa576b | ||
|
|
7cdead8cb1 | ||
|
|
f220825b80 | ||
|
|
2b00490dd6 | ||
|
|
d361afa3f3 | ||
|
|
8d5bd5a80c | ||
|
|
002283899f | ||
|
|
206b440966 | ||
|
|
b5b5eb25a1 | ||
|
|
f84e538b6a | ||
|
|
5b9cdec156 |
7
v2rayN/v2rayN/Forms/AddServer3Form.Designer.cs
generated
7
v2rayN/v2rayN/Forms/AddServer3Form.Designer.cs
generated
@@ -83,13 +83,6 @@
|
||||
//
|
||||
this.cmbSecurity.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbSecurity.FormattingEnabled = true;
|
||||
this.cmbSecurity.Items.AddRange(new object[] {
|
||||
resources.GetString("cmbSecurity.Items"),
|
||||
resources.GetString("cmbSecurity.Items1"),
|
||||
resources.GetString("cmbSecurity.Items2"),
|
||||
resources.GetString("cmbSecurity.Items3"),
|
||||
resources.GetString("cmbSecurity.Items4"),
|
||||
resources.GetString("cmbSecurity.Items5")});
|
||||
resources.ApplyResources(this.cmbSecurity, "cmbSecurity");
|
||||
this.cmbSecurity.Name = "cmbSecurity";
|
||||
//
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace v2rayN.Forms
|
||||
|
||||
private void AddServer3Form_Load(object sender, EventArgs e)
|
||||
{
|
||||
cmbSecurity.Items.AddRange(Global.ssSecuritys.ToArray());
|
||||
if (EditIndex >= 0)
|
||||
{
|
||||
vmessItem = config.vmess[EditIndex];
|
||||
|
||||
@@ -174,24 +174,6 @@
|
||||
<data name=">>label13.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="cmbSecurity.Items" xml:space="preserve">
|
||||
<value>aes-256-gcm</value>
|
||||
</data>
|
||||
<data name="cmbSecurity.Items1" xml:space="preserve">
|
||||
<value>aes-128-gcm</value>
|
||||
</data>
|
||||
<data name="cmbSecurity.Items2" xml:space="preserve">
|
||||
<value>chacha20-poly1305</value>
|
||||
</data>
|
||||
<data name="cmbSecurity.Items3" xml:space="preserve">
|
||||
<value>chacha20-ietf-poly1305</value>
|
||||
</data>
|
||||
<data name="cmbSecurity.Items4" xml:space="preserve">
|
||||
<value>none</value>
|
||||
</data>
|
||||
<data name="cmbSecurity.Items5" xml:space="preserve">
|
||||
<value>plain</value>
|
||||
</data>
|
||||
<data name="cmbSecurity.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>127, 123</value>
|
||||
</data>
|
||||
|
||||
6
v2rayN/v2rayN/Forms/AddServer5Form.Designer.cs
generated
6
v2rayN/v2rayN/Forms/AddServer5Form.Designer.cs
generated
@@ -88,12 +88,6 @@
|
||||
// cmbFlow
|
||||
//
|
||||
this.cmbFlow.FormattingEnabled = true;
|
||||
this.cmbFlow.Items.AddRange(new object[] {
|
||||
resources.GetString("cmbFlow.Items"),
|
||||
resources.GetString("cmbFlow.Items1"),
|
||||
resources.GetString("cmbFlow.Items2"),
|
||||
resources.GetString("cmbFlow.Items3"),
|
||||
resources.GetString("cmbFlow.Items4")});
|
||||
resources.ApplyResources(this.cmbFlow, "cmbFlow");
|
||||
this.cmbFlow.Name = "cmbFlow";
|
||||
//
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace v2rayN.Forms
|
||||
|
||||
private void AddServer5Form_Load(object sender, EventArgs e)
|
||||
{
|
||||
cmbFlow.Items.AddRange(Global.xtlsFlows.ToArray());
|
||||
transportControl.AllowXtls = true;
|
||||
if (EditIndex >= 0)
|
||||
{
|
||||
|
||||
@@ -143,21 +143,6 @@
|
||||
<data name=">>btnClose.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="cmbFlow.Items" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="cmbFlow.Items1" xml:space="preserve">
|
||||
<value>xtls-rprx-origin</value>
|
||||
</data>
|
||||
<data name="cmbFlow.Items2" xml:space="preserve">
|
||||
<value>xtls-rprx-origin-udp443</value>
|
||||
</data>
|
||||
<data name="cmbFlow.Items3" xml:space="preserve">
|
||||
<value>xtls-rprx-direct</value>
|
||||
</data>
|
||||
<data name="cmbFlow.Items4" xml:space="preserve">
|
||||
<value>xtls-rprx-direct-udp443</value>
|
||||
</data>
|
||||
<data name="cmbFlow.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>127, 123</value>
|
||||
</data>
|
||||
|
||||
6
v2rayN/v2rayN/Forms/AddServer6Form.Designer.cs
generated
6
v2rayN/v2rayN/Forms/AddServer6Form.Designer.cs
generated
@@ -80,12 +80,6 @@
|
||||
// cmbFlow
|
||||
//
|
||||
this.cmbFlow.FormattingEnabled = true;
|
||||
this.cmbFlow.Items.AddRange(new object[] {
|
||||
resources.GetString("cmbFlow.Items"),
|
||||
resources.GetString("cmbFlow.Items1"),
|
||||
resources.GetString("cmbFlow.Items2"),
|
||||
resources.GetString("cmbFlow.Items3"),
|
||||
resources.GetString("cmbFlow.Items4")});
|
||||
resources.ApplyResources(this.cmbFlow, "cmbFlow");
|
||||
this.cmbFlow.Name = "cmbFlow";
|
||||
//
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace v2rayN.Forms
|
||||
|
||||
private void AddServer6Form_Load(object sender, EventArgs e)
|
||||
{
|
||||
cmbFlow.Items.AddRange(Global.xtlsFlows.ToArray());
|
||||
transportControl.AllowXtls = true;
|
||||
if (EditIndex >= 0)
|
||||
{
|
||||
|
||||
@@ -147,21 +147,6 @@
|
||||
<data name=">>btnClose.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="cmbFlow.Items" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="cmbFlow.Items1" xml:space="preserve">
|
||||
<value>xtls-rprx-origin</value>
|
||||
</data>
|
||||
<data name="cmbFlow.Items2" xml:space="preserve">
|
||||
<value>xtls-rprx-origin-udp443</value>
|
||||
</data>
|
||||
<data name="cmbFlow.Items3" xml:space="preserve">
|
||||
<value>xtls-rprx-direct</value>
|
||||
</data>
|
||||
<data name="cmbFlow.Items4" xml:space="preserve">
|
||||
<value>xtls-rprx-direct-udp443</value>
|
||||
</data>
|
||||
<data name="cmbFlow.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>127, 123</value>
|
||||
</data>
|
||||
|
||||
6
v2rayN/v2rayN/Forms/AddServerForm.Designer.cs
generated
6
v2rayN/v2rayN/Forms/AddServerForm.Designer.cs
generated
@@ -113,12 +113,6 @@
|
||||
//
|
||||
this.cmbSecurity.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbSecurity.FormattingEnabled = true;
|
||||
this.cmbSecurity.Items.AddRange(new object[] {
|
||||
resources.GetString("cmbSecurity.Items"),
|
||||
resources.GetString("cmbSecurity.Items1"),
|
||||
resources.GetString("cmbSecurity.Items2"),
|
||||
resources.GetString("cmbSecurity.Items3"),
|
||||
resources.GetString("cmbSecurity.Items4")});
|
||||
resources.ApplyResources(this.cmbSecurity, "cmbSecurity");
|
||||
this.cmbSecurity.Name = "cmbSecurity";
|
||||
//
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace v2rayN.Forms
|
||||
|
||||
private void AddServerForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
cmbSecurity.Items.AddRange(Global.vmessSecuritys.ToArray());
|
||||
if (EditIndex >= 0)
|
||||
{
|
||||
vmessItem = config.vmess[EditIndex];
|
||||
@@ -82,11 +83,6 @@ namespace v2rayN.Forms
|
||||
UI.Show(UIRes.I18N("FillUUID"));
|
||||
return;
|
||||
}
|
||||
if (Utils.IsNullOrEmpty(alterId) || !Utils.IsNumberic(alterId))
|
||||
{
|
||||
UI.Show(UIRes.I18N("FillCorrectAlterId"));
|
||||
return;
|
||||
}
|
||||
|
||||
transportControl.EndBindingServer();
|
||||
|
||||
|
||||
@@ -221,21 +221,6 @@
|
||||
<data name=">>label8.ZOrder" xml:space="preserve">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name="cmbSecurity.Items" xml:space="preserve">
|
||||
<value>aes-128-gcm</value>
|
||||
</data>
|
||||
<data name="cmbSecurity.Items1" xml:space="preserve">
|
||||
<value>chacha20-poly1305</value>
|
||||
</data>
|
||||
<data name="cmbSecurity.Items2" xml:space="preserve">
|
||||
<value>auto</value>
|
||||
</data>
|
||||
<data name="cmbSecurity.Items3" xml:space="preserve">
|
||||
<value>none</value>
|
||||
</data>
|
||||
<data name="cmbSecurity.Items4" xml:space="preserve">
|
||||
<value>zero</value>
|
||||
</data>
|
||||
<data name="cmbSecurity.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>195, 143</value>
|
||||
</data>
|
||||
|
||||
@@ -196,7 +196,9 @@ namespace v2rayN
|
||||
|
||||
public const string RoutingRuleComma = "<COMMA>";
|
||||
|
||||
public static readonly IEnumerable<string> ssSecuritys = new HashSet<string> { "aes-256-gcm", "aes-128-gcm", "chacha20-poly1305", "chacha20-ietf-poly1305", "none", "plain" };
|
||||
public static readonly List<string> vmessSecuritys = new List<string> { "aes-128-gcm", "chacha20-poly1305", "auto", "none", "zero" };
|
||||
public static readonly List<string> ssSecuritys = new List<string> { "aes-256-gcm", "aes-128-gcm", "chacha20-poly1305", "chacha20-ietf-poly1305", "none", "plain" };
|
||||
public static readonly List<string> xtlsFlows = new List<string> { "", "xtls-rprx-origin", "xtls-rprx-origin-udp443", "xtls-rprx-direct", "xtls-rprx-direct-udp443" };
|
||||
|
||||
public const string GrpcgunMode = "gun";
|
||||
public const string GrpcmultiMode = "multi";
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace v2rayN.Handler
|
||||
config = Utils.FromJson<Config>(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
if (File.Exists(Utils.GetPath(configRes)))
|
||||
{
|
||||
Utils.SaveLog("LoadConfig Exception");
|
||||
@@ -172,6 +172,11 @@ namespace v2rayN.Handler
|
||||
{
|
||||
VmessItem vmessItem = config.vmess[i];
|
||||
UpgradeServerVersion(ref vmessItem);
|
||||
|
||||
if (string.IsNullOrEmpty(vmessItem.indexId))
|
||||
{
|
||||
vmessItem.indexId = Utils.GetGUID(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +196,6 @@ namespace v2rayN.Handler
|
||||
/// <returns></returns>
|
||||
public static int AddServer(ref Config config, VmessItem vmessItem, int index, bool toFile = true)
|
||||
{
|
||||
vmessItem.configVersion = 2;
|
||||
vmessItem.configType = (int)EConfigType.Vmess;
|
||||
|
||||
vmessItem.address = vmessItem.address.TrimEx();
|
||||
@@ -203,6 +207,11 @@ namespace v2rayN.Handler
|
||||
vmessItem.path = vmessItem.path.TrimEx();
|
||||
vmessItem.streamSecurity = vmessItem.streamSecurity.TrimEx();
|
||||
|
||||
if (!Global.vmessSecuritys.Contains(vmessItem.security))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (index >= 0)
|
||||
{
|
||||
//修改
|
||||
@@ -214,17 +223,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
else
|
||||
{
|
||||
//添加
|
||||
if (Utils.IsNullOrEmpty(vmessItem.allowInsecure))
|
||||
{
|
||||
vmessItem.allowInsecure = config.defAllowInsecure.ToString();
|
||||
}
|
||||
config.vmess.Add(vmessItem);
|
||||
if (config.vmess.Count == 1)
|
||||
{
|
||||
config.index = 0;
|
||||
Global.reloadV2ray = true;
|
||||
}
|
||||
AddServerCommon(ref config, vmessItem);
|
||||
}
|
||||
|
||||
if (toFile)
|
||||
@@ -242,7 +241,7 @@ namespace v2rayN.Handler
|
||||
/// <returns></returns>
|
||||
public static int RemoveServer(ref Config config, List<int> indexs)
|
||||
{
|
||||
var itemId = config.getItemId();
|
||||
var indexId = config.indexId();
|
||||
|
||||
for (int k = indexs.Count - 1; k >= 0; k--)
|
||||
{
|
||||
@@ -255,23 +254,7 @@ namespace v2rayN.Handler
|
||||
config.vmess.RemoveAt(index);
|
||||
}
|
||||
|
||||
var index_ = config.vmess.FindIndex(it => it.getItemId() == itemId);
|
||||
if (index_ >= 0)
|
||||
{
|
||||
config.index = index_;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (config.vmess.Count > 0)
|
||||
{
|
||||
config.index = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
config.index = -1;
|
||||
}
|
||||
}
|
||||
Global.reloadV2ray = true;
|
||||
SetIndex(ref config, indexId);
|
||||
|
||||
ToJsonFile(config);
|
||||
|
||||
@@ -546,7 +529,6 @@ namespace v2rayN.Handler
|
||||
/// <returns></returns>
|
||||
public static int AddShadowsocksServer(ref Config config, VmessItem vmessItem, int index, bool toFile = true)
|
||||
{
|
||||
vmessItem.configVersion = 2;
|
||||
vmessItem.configType = (int)EConfigType.Shadowsocks;
|
||||
|
||||
vmessItem.address = vmessItem.address.TrimEx();
|
||||
@@ -569,13 +551,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
else
|
||||
{
|
||||
//添加
|
||||
config.vmess.Add(vmessItem);
|
||||
if (config.vmess.Count == 1)
|
||||
{
|
||||
config.index = 0;
|
||||
Global.reloadV2ray = true;
|
||||
}
|
||||
AddServerCommon(ref config, vmessItem);
|
||||
}
|
||||
|
||||
if (toFile)
|
||||
@@ -595,7 +571,6 @@ namespace v2rayN.Handler
|
||||
/// <returns></returns>
|
||||
public static int AddSocksServer(ref Config config, VmessItem vmessItem, int index, bool toFile = true)
|
||||
{
|
||||
vmessItem.configVersion = 2;
|
||||
vmessItem.configType = (int)EConfigType.Socks;
|
||||
|
||||
vmessItem.address = vmessItem.address.TrimEx();
|
||||
@@ -611,13 +586,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
else
|
||||
{
|
||||
//添加
|
||||
config.vmess.Add(vmessItem);
|
||||
if (config.vmess.Count == 1)
|
||||
{
|
||||
config.index = 0;
|
||||
Global.reloadV2ray = true;
|
||||
}
|
||||
AddServerCommon(ref config, vmessItem);
|
||||
}
|
||||
|
||||
if (toFile)
|
||||
@@ -638,7 +607,6 @@ namespace v2rayN.Handler
|
||||
/// <returns></returns>
|
||||
public static int AddTrojanServer(ref Config config, VmessItem vmessItem, int index, bool toFile = true)
|
||||
{
|
||||
vmessItem.configVersion = 2;
|
||||
vmessItem.configType = (int)EConfigType.Trojan;
|
||||
|
||||
vmessItem.address = vmessItem.address.TrimEx();
|
||||
@@ -663,13 +631,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
else
|
||||
{
|
||||
//添加
|
||||
config.vmess.Add(vmessItem);
|
||||
if (config.vmess.Count == 1)
|
||||
{
|
||||
config.index = 0;
|
||||
Global.reloadV2ray = true;
|
||||
}
|
||||
AddServerCommon(ref config, vmessItem);
|
||||
}
|
||||
|
||||
if (toFile)
|
||||
@@ -867,7 +829,7 @@ namespace v2rayN.Handler
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(sub.id))
|
||||
{
|
||||
sub.id = Utils.GetGUID();
|
||||
sub.id = Utils.GetGUID(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -883,6 +845,7 @@ namespace v2rayN.Handler
|
||||
/// <returns></returns>
|
||||
public static int RemoveServerViaSubid(ref Config config, string subid)
|
||||
{
|
||||
var indexId = config.indexId();
|
||||
if (Utils.IsNullOrEmpty(subid) || config.vmess.Count <= 0)
|
||||
{
|
||||
return -1;
|
||||
@@ -895,6 +858,8 @@ namespace v2rayN.Handler
|
||||
}
|
||||
}
|
||||
|
||||
SetIndex(ref config, indexId);
|
||||
|
||||
ToJsonFile(config);
|
||||
return 0;
|
||||
}
|
||||
@@ -924,7 +889,8 @@ namespace v2rayN.Handler
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
string itemId = config.getItemId();
|
||||
|
||||
var indexId = config.indexId();
|
||||
var items = config.vmess.AsQueryable();
|
||||
|
||||
if (asc)
|
||||
@@ -936,11 +902,7 @@ namespace v2rayN.Handler
|
||||
config.vmess = items.OrderByDescending(propertyName).ToList();
|
||||
}
|
||||
|
||||
var index_ = config.vmess.FindIndex(it => it.getItemId() == itemId);
|
||||
if (index_ >= 0)
|
||||
{
|
||||
config.index = index_;
|
||||
}
|
||||
SetIndex(ref config, indexId);
|
||||
|
||||
ToJsonFile(config);
|
||||
return 0;
|
||||
@@ -955,7 +917,6 @@ namespace v2rayN.Handler
|
||||
/// <returns></returns>
|
||||
public static int AddVlessServer(ref Config config, VmessItem vmessItem, int index, bool toFile = true)
|
||||
{
|
||||
vmessItem.configVersion = 2;
|
||||
vmessItem.configType = (int)EConfigType.VLESS;
|
||||
|
||||
vmessItem.address = vmessItem.address.TrimEx();
|
||||
@@ -978,17 +939,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
else
|
||||
{
|
||||
//添加
|
||||
if (Utils.IsNullOrEmpty(vmessItem.allowInsecure))
|
||||
{
|
||||
vmessItem.allowInsecure = config.defAllowInsecure.ToString();
|
||||
}
|
||||
config.vmess.Add(vmessItem);
|
||||
if (config.vmess.Count == 1)
|
||||
{
|
||||
config.index = 0;
|
||||
Global.reloadV2ray = true;
|
||||
}
|
||||
AddServerCommon(ref config, vmessItem);
|
||||
}
|
||||
|
||||
if (toFile)
|
||||
@@ -1001,8 +952,8 @@ namespace v2rayN.Handler
|
||||
|
||||
public static int DedupServerList(ref Config config)
|
||||
{
|
||||
var itemId = config.getItemId();
|
||||
|
||||
var indexId = config.indexId();
|
||||
|
||||
List<Mode.VmessItem> source = config.vmess;
|
||||
bool keepOlder = config.keepOlderDedupl;
|
||||
|
||||
@@ -1035,8 +986,38 @@ namespace v2rayN.Handler
|
||||
if (!keepOlder) list.Reverse();
|
||||
config.vmess = list;
|
||||
|
||||
var index_ = config.vmess.FindIndex(it => it.getItemId() == itemId);
|
||||
if (index_ >= 0)
|
||||
SetIndex(ref config, indexId);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int AddServerCommon(ref Config config, VmessItem vmessItem)
|
||||
{
|
||||
vmessItem.indexId = Utils.GetGUID(false);
|
||||
vmessItem.configVersion = 2;
|
||||
if (Utils.IsNullOrEmpty(vmessItem.allowInsecure))
|
||||
{
|
||||
vmessItem.allowInsecure = config.defAllowInsecure.ToString();
|
||||
}
|
||||
|
||||
config.vmess.Add(vmessItem);
|
||||
if (config.vmess.Count == 1)
|
||||
{
|
||||
config.index = 0;
|
||||
Global.reloadV2ray = true;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int SetIndex(ref Config config, string indexId)
|
||||
{
|
||||
var index_ = config.FindIndexId(indexId);
|
||||
|
||||
if (config.index == index_)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (index_ >= 0)
|
||||
{
|
||||
config.index = index_;
|
||||
}
|
||||
@@ -1052,7 +1033,6 @@ namespace v2rayN.Handler
|
||||
}
|
||||
}
|
||||
Global.reloadV2ray = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1135,6 +1115,13 @@ namespace v2rayN.Handler
|
||||
else
|
||||
{
|
||||
config.routings.Add(item);
|
||||
int indexLocked = config.routings.FindIndex(it => it.locked == true);
|
||||
if (indexLocked != -1)
|
||||
{
|
||||
var itemLocked = Utils.DeepCopy(config.routings[indexLocked]);
|
||||
config.routings.RemoveAt(indexLocked);
|
||||
config.routings.Add(itemLocked);
|
||||
}
|
||||
}
|
||||
ToJsonFile(config);
|
||||
|
||||
|
||||
@@ -185,15 +185,16 @@ namespace v2rayN.Handler
|
||||
|
||||
public void BackupGuiNConfig(Config config, bool auto = false)
|
||||
{
|
||||
string fileName = string.Empty;
|
||||
string fileName = $"guiNConfig_{DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_fff")}.json";
|
||||
if (auto)
|
||||
{
|
||||
fileName = Utils.GetTempPath($"guiNConfig{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.json");
|
||||
fileName = Utils.GetTempPath(fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
SaveFileDialog fileDialog = new SaveFileDialog
|
||||
{
|
||||
FileName = fileName,
|
||||
Filter = "guiNConfig|*.json",
|
||||
FilterIndex = 2,
|
||||
RestoreDirectory = true
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace v2rayN.Handler
|
||||
add = item.address,
|
||||
port = item.port.ToString(),
|
||||
id = item.id,
|
||||
aid = item.alterId.ToString(),
|
||||
aid = "0",
|
||||
scy = item.security,
|
||||
net = item.network,
|
||||
type = item.headerType,
|
||||
@@ -96,15 +96,15 @@ namespace v2rayN.Handler
|
||||
{
|
||||
remark = "#" + Utils.UrlEncode(item.remarks);
|
||||
}
|
||||
url = string.Format("{0}:{1}@{2}:{3}",
|
||||
item.security,
|
||||
item.id,
|
||||
item.address,
|
||||
item.port);
|
||||
url = Utils.Base64Encode(url);
|
||||
//new
|
||||
//var pw = Utils.Base64Encode($"{item.security}:{item.id}");
|
||||
//url = $"{pw}@{item.address}:{ item.port}";
|
||||
//url = string.Format("{0}:{1}@{2}:{3}",
|
||||
// item.security,
|
||||
// item.id,
|
||||
// item.address,
|
||||
// item.port);
|
||||
//url = Utils.Base64Encode(url);
|
||||
//new Sip002
|
||||
var pw = Utils.Base64Encode($"{item.security}:{item.id}");
|
||||
url = $"{pw}@{GetIpv6(item.address)}:{ item.port}";
|
||||
url = string.Format("{0}{1}{2}", Global.ssProtocol, url, remark);
|
||||
return url;
|
||||
}
|
||||
@@ -117,12 +117,15 @@ namespace v2rayN.Handler
|
||||
{
|
||||
remark = "#" + Utils.UrlEncode(item.remarks);
|
||||
}
|
||||
url = string.Format("{0}:{1}@{2}:{3}",
|
||||
item.security,
|
||||
item.id,
|
||||
item.address,
|
||||
item.port);
|
||||
url = Utils.Base64Encode(url);
|
||||
//url = string.Format("{0}:{1}@{2}:{3}",
|
||||
// item.security,
|
||||
// item.id,
|
||||
// item.address,
|
||||
// item.port);
|
||||
//url = Utils.Base64Encode(url);
|
||||
//new
|
||||
var pw = Utils.Base64Encode($"{item.security}:{item.id}");
|
||||
url = $"{pw}@{GetIpv6(item.address)}:{ item.port}";
|
||||
url = string.Format("{0}{1}{2}", Global.socksProtocol, url, remark);
|
||||
return url;
|
||||
}
|
||||
@@ -135,15 +138,14 @@ namespace v2rayN.Handler
|
||||
{
|
||||
remark = "#" + Utils.UrlEncode(item.remarks);
|
||||
}
|
||||
string query = string.Empty;
|
||||
if (!Utils.IsNullOrEmpty(item.sni))
|
||||
{
|
||||
query = string.Format("?sni={0}", Utils.UrlEncode(item.sni));
|
||||
}
|
||||
var dicQuery = new Dictionary<string, string>();
|
||||
GetStdTransport(item, null, ref dicQuery);
|
||||
string query = "?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray());
|
||||
|
||||
url = string.Format("{0}@{1}:{2}",
|
||||
item.id,
|
||||
GetIpv6(item.address),
|
||||
item.port);
|
||||
item.id,
|
||||
GetIpv6(item.address),
|
||||
item.port);
|
||||
url = string.Format("{0}{1}{2}{3}", Global.trojanProtocol, url, query, remark);
|
||||
return url;
|
||||
}
|
||||
@@ -157,10 +159,6 @@ namespace v2rayN.Handler
|
||||
remark = "#" + Utils.UrlEncode(item.remarks);
|
||||
}
|
||||
var dicQuery = new Dictionary<string, string>();
|
||||
if (!Utils.IsNullOrEmpty(item.flow))
|
||||
{
|
||||
dicQuery.Add("flow", item.flow);
|
||||
}
|
||||
if (!Utils.IsNullOrEmpty(item.security))
|
||||
{
|
||||
dicQuery.Add("encryption", item.security);
|
||||
@@ -169,13 +167,38 @@ namespace v2rayN.Handler
|
||||
{
|
||||
dicQuery.Add("encryption", "none");
|
||||
}
|
||||
GetStdTransport(item, "none", ref dicQuery);
|
||||
string query = "?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray());
|
||||
|
||||
url = string.Format("{0}@{1}:{2}",
|
||||
item.id,
|
||||
GetIpv6(item.address),
|
||||
item.port);
|
||||
url = string.Format("{0}{1}{2}{3}", Global.vlessProtocol, url, query, remark);
|
||||
return url;
|
||||
}
|
||||
private static string GetIpv6(string address)
|
||||
{
|
||||
return Utils.IsIpv6(address) ? $"[{address}]" : address;
|
||||
}
|
||||
|
||||
private static int GetStdTransport(VmessItem item, string securityDef, ref Dictionary<string, string> dicQuery)
|
||||
{
|
||||
if (!Utils.IsNullOrEmpty(item.flow))
|
||||
{
|
||||
dicQuery.Add("flow", item.flow);
|
||||
}
|
||||
|
||||
if (!Utils.IsNullOrEmpty(item.streamSecurity))
|
||||
{
|
||||
dicQuery.Add("security", item.streamSecurity);
|
||||
}
|
||||
else
|
||||
{
|
||||
dicQuery.Add("security", "none");
|
||||
if (securityDef != null)
|
||||
{
|
||||
dicQuery.Add("security", securityDef);
|
||||
}
|
||||
}
|
||||
if (!Utils.IsNullOrEmpty(item.sni))
|
||||
{
|
||||
@@ -272,19 +295,9 @@ namespace v2rayN.Handler
|
||||
}
|
||||
break;
|
||||
}
|
||||
string query = "?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray());
|
||||
|
||||
url = string.Format("{0}@{1}:{2}",
|
||||
item.id,
|
||||
GetIpv6(item.address),
|
||||
item.port);
|
||||
url = string.Format("{0}{1}{2}{3}", Global.vlessProtocol, url, query, remark);
|
||||
return url;
|
||||
}
|
||||
private static string GetIpv6(string address)
|
||||
{
|
||||
return Utils.IsIpv6(address) ? $"[{address}]" : address;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ImportShareUrl
|
||||
@@ -349,7 +362,21 @@ namespace v2rayN.Handler
|
||||
{
|
||||
msg = UIRes.I18N("ConfigurationFormatIncorrect");
|
||||
|
||||
vmessItem = ResolveSocks(result);
|
||||
vmessItem = ResolveSocksNew(result);
|
||||
if (vmessItem == null)
|
||||
{
|
||||
vmessItem = ResolveSocks(result);
|
||||
}
|
||||
if (vmessItem == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (vmessItem.address.Length == 0 || vmessItem.port == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
vmessItem.configType = (int)EConfigType.Socks;
|
||||
}
|
||||
else if (result.StartsWith(Global.trojanProtocol))
|
||||
{
|
||||
@@ -403,7 +430,6 @@ namespace v2rayN.Handler
|
||||
vmessItem.address = Utils.ToString(vmessQRCode.add);
|
||||
vmessItem.port = Utils.ToInt(vmessQRCode.port);
|
||||
vmessItem.id = Utils.ToString(vmessQRCode.id);
|
||||
vmessItem.alterId = Utils.ToInt(vmessQRCode.aid);
|
||||
vmessItem.security = Utils.ToString(vmessQRCode.scy);
|
||||
|
||||
if (!Utils.IsNullOrEmpty(vmessQRCode.scy))
|
||||
@@ -429,7 +455,7 @@ namespace v2rayN.Handler
|
||||
vmessItem.sni = Utils.ToString(vmessQRCode.sni);
|
||||
vmessItem.alpn = Utils.String2List(vmessQRCode.alpn);
|
||||
|
||||
return vmessItem;
|
||||
return vmessItem;
|
||||
}
|
||||
|
||||
private static VmessItem ResolveVmess4Kitsunebi(string result)
|
||||
@@ -466,7 +492,6 @@ namespace v2rayN.Handler
|
||||
vmessItem.network = Global.DefaultNetwork;
|
||||
vmessItem.headerType = Global.None;
|
||||
vmessItem.remarks = "Alien";
|
||||
vmessItem.alterId = 0;
|
||||
|
||||
return vmessItem;
|
||||
}
|
||||
@@ -490,11 +515,6 @@ namespace v2rayN.Handler
|
||||
if (!m.Success) return null;
|
||||
|
||||
i.id = m.Groups["id"].Value;
|
||||
if (!int.TryParse(m.Groups["alterId"].Value, out int aid))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
i.alterId = aid;
|
||||
|
||||
if (m.Groups["streamSecurity"].Success)
|
||||
{
|
||||
@@ -577,17 +597,7 @@ namespace v2rayN.Handler
|
||||
|
||||
// parse base64 UserInfo
|
||||
string rawUserInfo = parsedUrl.GetComponents(UriComponents.UserInfo, UriFormat.Unescaped);
|
||||
string base64 = rawUserInfo.Replace('-', '+').Replace('_', '/'); // Web-safe base64 to normal base64
|
||||
string userInfo;
|
||||
try
|
||||
{
|
||||
userInfo = Encoding.UTF8.GetString(Convert.FromBase64String(
|
||||
base64.PadRight(base64.Length + (4 - base64.Length % 4) % 4, '=')));
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string userInfo = Utils.Base64Decode(rawUserInfo);
|
||||
string[] userInfoParts = userInfo.Split(new char[] { ':' }, 2);
|
||||
if (userInfoParts.Length != 2)
|
||||
{
|
||||
@@ -624,8 +634,7 @@ namespace v2rayN.Handler
|
||||
Match details;
|
||||
try
|
||||
{
|
||||
details = DetailsParser.Match(Encoding.UTF8.GetString(Convert.FromBase64String(
|
||||
base64.PadRight(base64.Length + (4 - base64.Length % 4) % 4, '='))));
|
||||
details = DetailsParser.Match(Utils.Base64Decode(base64));
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
@@ -642,7 +651,7 @@ namespace v2rayN.Handler
|
||||
|
||||
|
||||
private static readonly Regex StdVmessUserInfo = new Regex(
|
||||
@"^(?<network>[a-z]+)(\+(?<streamSecurity>[a-z]+))?:(?<id>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})-(?<alterId>[0-9]+)$");
|
||||
@"^(?<network>[a-z]+)(\+(?<streamSecurity>[a-z]+))?:(?<id>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$");
|
||||
|
||||
private static VmessItem ResolveSocks(string result)
|
||||
{
|
||||
@@ -690,30 +699,55 @@ namespace v2rayN.Handler
|
||||
return vmessItem;
|
||||
}
|
||||
|
||||
private static VmessItem ResolveSocksNew(string result)
|
||||
{
|
||||
Uri parsedUrl;
|
||||
try
|
||||
{
|
||||
parsedUrl = new Uri(result);
|
||||
}
|
||||
catch (UriFormatException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
VmessItem server = new VmessItem
|
||||
{
|
||||
remarks = Utils.UrlDecode(parsedUrl.GetComponents(UriComponents.Fragment, UriFormat.Unescaped)),
|
||||
address = parsedUrl.IdnHost,
|
||||
port = parsedUrl.Port,
|
||||
};
|
||||
|
||||
// parse base64 UserInfo
|
||||
string rawUserInfo = parsedUrl.GetComponents(UriComponents.UserInfo, UriFormat.Unescaped);
|
||||
string userInfo = Utils.Base64Decode(rawUserInfo);
|
||||
string[] userInfoParts = userInfo.Split(new char[] { ':' }, 2);
|
||||
if (userInfoParts.Length == 2)
|
||||
{
|
||||
server.security = userInfoParts[0];
|
||||
server.id = userInfoParts[1];
|
||||
}
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
private static VmessItem ResolveTrojan(string result)
|
||||
{
|
||||
VmessItem vmessItem = new VmessItem();
|
||||
|
||||
vmessItem.configType = (int)EConfigType.Trojan;
|
||||
|
||||
Uri uri = new Uri(result);
|
||||
vmessItem.address = uri.IdnHost;
|
||||
vmessItem.port = uri.Port;
|
||||
vmessItem.id = uri.UserInfo;
|
||||
|
||||
var qurery = HttpUtility.ParseQueryString(uri.Query);
|
||||
vmessItem.sni = qurery["sni"] ?? "";
|
||||
|
||||
var remarks = uri.Fragment.Replace("#", "");
|
||||
if (Utils.IsNullOrEmpty(remarks))
|
||||
VmessItem item = new VmessItem
|
||||
{
|
||||
vmessItem.remarks = "NONE";
|
||||
}
|
||||
else
|
||||
{
|
||||
vmessItem.remarks = Utils.UrlDecode(remarks);
|
||||
}
|
||||
return vmessItem;
|
||||
configType = (int)EConfigType.Trojan
|
||||
};
|
||||
|
||||
Uri url = new Uri(result);
|
||||
|
||||
item.address = url.IdnHost;
|
||||
item.port = url.Port;
|
||||
item.remarks = Utils.UrlDecode(url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped));
|
||||
item.id = url.UserInfo;
|
||||
|
||||
var query = HttpUtility.ParseQueryString(url.Query);
|
||||
ResolveStdTransport(query, ref item);
|
||||
|
||||
return item;
|
||||
}
|
||||
private static VmessItem ResolveStdVLESS(string result)
|
||||
{
|
||||
@@ -731,10 +765,17 @@ namespace v2rayN.Handler
|
||||
item.id = url.UserInfo;
|
||||
|
||||
var query = HttpUtility.ParseQueryString(url.Query);
|
||||
|
||||
item.flow = query["flow"] ?? "";
|
||||
item.security = query["encryption"] ?? "none";
|
||||
item.streamSecurity = query["security"] ?? "";
|
||||
ResolveStdTransport(query, ref item);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
private static int ResolveStdTransport(NameValueCollection query, ref VmessItem item)
|
||||
{
|
||||
item.flow = query["flow"] ?? "";
|
||||
item.streamSecurity = query["security"] ?? "";
|
||||
item.sni = query["sni"] ?? "";
|
||||
item.alpn = Utils.String2List(Utils.UrlDecode(query["alpn"] ?? ""));
|
||||
item.network = query["type"] ?? "tcp";
|
||||
@@ -772,10 +813,9 @@ namespace v2rayN.Handler
|
||||
item.headerType = Utils.UrlDecode(query["mode"] ?? Global.GrpcgunMode);
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
}
|
||||
|
||||
return item;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace v2rayN.Handler
|
||||
{
|
||||
private Config _config;
|
||||
private V2rayHandler _v2rayHandler;
|
||||
private List<int> _selecteds;
|
||||
private List<ServerTestItem> _selecteds;
|
||||
Action<int, string> _updateFunc;
|
||||
|
||||
public SpeedtestHandler(ref Config config)
|
||||
@@ -25,9 +25,22 @@ namespace v2rayN.Handler
|
||||
{
|
||||
_config = config;
|
||||
_v2rayHandler = v2rayHandler;
|
||||
_selecteds = Utils.DeepCopy(selecteds);
|
||||
//_selecteds = Utils.DeepCopy(selecteds);
|
||||
_updateFunc = update;
|
||||
|
||||
_selecteds = new List<ServerTestItem>();
|
||||
foreach (var it in selecteds)
|
||||
{
|
||||
_selecteds.Add(new ServerTestItem()
|
||||
{
|
||||
selected = it,
|
||||
indexId = config.vmess[it].indexId,
|
||||
address = config.vmess[it].address,
|
||||
port = config.vmess[it].port,
|
||||
configType = config.vmess[it].configType
|
||||
});
|
||||
}
|
||||
|
||||
if (actionType == "ping")
|
||||
{
|
||||
Task.Run(() => RunPing());
|
||||
@@ -46,19 +59,19 @@ namespace v2rayN.Handler
|
||||
}
|
||||
}
|
||||
|
||||
private void RunPingSub(Action<int> updateFun)
|
||||
private void RunPingSub(Action<ServerTestItem> updateFun)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (int index in _selecteds)
|
||||
foreach (var it in _selecteds)
|
||||
{
|
||||
if (_config.vmess[index].configType == (int)EConfigType.Custom)
|
||||
if (it.configType == (int)EConfigType.Custom)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
try
|
||||
{
|
||||
updateFun(index);
|
||||
updateFun(it);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -77,18 +90,22 @@ namespace v2rayN.Handler
|
||||
|
||||
private void RunPing()
|
||||
{
|
||||
RunPingSub((int index) =>
|
||||
RunPingSub((ServerTestItem it) =>
|
||||
{
|
||||
long time = Utils.Ping(_config.vmess[index].address);
|
||||
long time = Utils.Ping(it.address);
|
||||
var index = _config.FindIndexId(it.indexId);
|
||||
if (index < 0) return;
|
||||
_updateFunc(index, FormatOut(time, "ms"));
|
||||
});
|
||||
}
|
||||
|
||||
private void RunTcping()
|
||||
{
|
||||
RunPingSub((int index) =>
|
||||
RunPingSub((ServerTestItem it) =>
|
||||
{
|
||||
int time = GetTcpingTime(_config.vmess[index].address, _config.vmess[index].port);
|
||||
int time = GetTcpingTime(it.address, it.port);
|
||||
var index = _config.FindIndexId(it.indexId);
|
||||
if (index < 0) return;
|
||||
_updateFunc(index, FormatOut(time, "ms"));
|
||||
});
|
||||
}
|
||||
@@ -103,16 +120,19 @@ namespace v2rayN.Handler
|
||||
pid = _v2rayHandler.LoadV2rayConfigString(_config, _selecteds);
|
||||
if (pid < 0)
|
||||
{
|
||||
_updateFunc(_selecteds[0], UIRes.I18N("OperationFailed"));
|
||||
_updateFunc(_selecteds[0].selected, UIRes.I18N("OperationFailed"));
|
||||
return;
|
||||
}
|
||||
|
||||
//Thread.Sleep(5000);
|
||||
int httpPort = _config.GetLocalPort("speedtest");
|
||||
List<Task> tasks = new List<Task>();
|
||||
foreach (int itemIndex in _selecteds)
|
||||
foreach (var it in _selecteds)
|
||||
{
|
||||
if (_config.vmess[itemIndex].configType == (int)EConfigType.Custom)
|
||||
if (it.configType == (int)EConfigType.Custom)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (it.port <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -120,11 +140,13 @@ namespace v2rayN.Handler
|
||||
{
|
||||
try
|
||||
{
|
||||
WebProxy webProxy = new WebProxy(Global.Loopback, httpPort + itemIndex);
|
||||
WebProxy webProxy = new WebProxy(Global.Loopback, it.port);
|
||||
int responseTime = -1;
|
||||
string status = GetRealPingTime(_config.constItem.speedPingTestUrl, webProxy, out responseTime);
|
||||
string output = Utils.IsNullOrEmpty(status) ? FormatOut(responseTime, "ms") : FormatOut(status, "");
|
||||
_updateFunc(itemIndex, output);
|
||||
string output = Utils.IsNullOrEmpty(status) ? FormatOut(responseTime, "ms") : status;
|
||||
var index = _config.FindIndexId(it.indexId);
|
||||
if (index < 0) return;
|
||||
_updateFunc(index, output);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -178,7 +200,7 @@ namespace v2rayN.Handler
|
||||
|
||||
private void RunSpeedTest()
|
||||
{
|
||||
int testCounter = 0;
|
||||
string testIndexId = string.Empty;
|
||||
int pid = -1;
|
||||
|
||||
if (_config.vmess.Count <= 0)
|
||||
@@ -189,7 +211,7 @@ namespace v2rayN.Handler
|
||||
pid = _v2rayHandler.LoadV2rayConfigString(_config, _selecteds);
|
||||
if (pid < 0)
|
||||
{
|
||||
_updateFunc(_selecteds[0], UIRes.I18N("OperationFailed"));
|
||||
_updateFunc(_selecteds[0].selected, UIRes.I18N("OperationFailed"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -197,29 +219,32 @@ namespace v2rayN.Handler
|
||||
DownloadHandle downloadHandle2 = new DownloadHandle();
|
||||
downloadHandle2.UpdateCompleted += (sender2, args) =>
|
||||
{
|
||||
_updateFunc(testCounter, args.Msg);
|
||||
var index = _config.FindIndexId(testIndexId);
|
||||
if (index < 0) return;
|
||||
_updateFunc(index, args.Msg);
|
||||
};
|
||||
downloadHandle2.Error += (sender2, args) =>
|
||||
{
|
||||
_updateFunc(testCounter, args.GetException().Message);
|
||||
var index = _config.FindIndexId(testIndexId);
|
||||
if (index < 0) return;
|
||||
_updateFunc(index, args.GetException().Message);
|
||||
};
|
||||
|
||||
var timeout = 10;
|
||||
foreach (int itemIndex in _selecteds)
|
||||
foreach (var it in _selecteds)
|
||||
{
|
||||
if (itemIndex >= _config.vmess.Count)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (_config.vmess[itemIndex].configType == (int)EConfigType.Custom)
|
||||
if (it.configType == (int)EConfigType.Custom)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
testCounter = itemIndex;
|
||||
int httpPort = _config.GetLocalPort("speedtest");
|
||||
|
||||
WebProxy webProxy = new WebProxy(Global.Loopback, httpPort + itemIndex);
|
||||
if (it.port <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
testIndexId = it.indexId;
|
||||
if (_config.FindIndexId(it.indexId) < 0) continue;
|
||||
|
||||
WebProxy webProxy = new WebProxy(Global.Loopback, it.port);
|
||||
var ws = downloadHandle2.DownloadDataAsync(url, webProxy, timeout - 2);
|
||||
|
||||
Thread.Sleep(1000 * timeout);
|
||||
|
||||
@@ -365,7 +365,14 @@ namespace v2rayN.Handler
|
||||
usersItem.id = config.id();
|
||||
usersItem.alterId = config.alterId();
|
||||
usersItem.email = Global.userEMail;
|
||||
usersItem.security = config.security();
|
||||
if (Global.vmessSecuritys.Contains(config.security()))
|
||||
{
|
||||
usersItem.security = config.security();
|
||||
}
|
||||
else
|
||||
{
|
||||
usersItem.security = Global.DefaultSecurity;
|
||||
}
|
||||
|
||||
//Mux
|
||||
outbound.mux.enabled = config.muxEnabled;
|
||||
@@ -479,7 +486,6 @@ namespace v2rayN.Handler
|
||||
}
|
||||
//远程服务器用户ID
|
||||
usersItem.id = config.id();
|
||||
usersItem.alterId = 0;
|
||||
usersItem.flow = string.Empty;
|
||||
usersItem.email = Global.userEMail;
|
||||
usersItem.encryption = config.security();
|
||||
@@ -497,7 +503,7 @@ namespace v2rayN.Handler
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(config.flow()))
|
||||
{
|
||||
usersItem.flow = "xtls-rprx-origin";
|
||||
usersItem.flow = Global.xtlsFlows[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -537,7 +543,7 @@ namespace v2rayN.Handler
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(config.flow()))
|
||||
{
|
||||
serversItem.flow = "xtls-rprx-origin";
|
||||
serversItem.flow = Global.xtlsFlows[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1031,7 +1037,6 @@ namespace v2rayN.Handler
|
||||
else if (config.configType() == (int)EConfigType.VLESS)
|
||||
{
|
||||
inbound.protocol = Global.vlessProtocolLite;
|
||||
usersItem.alterId = 0;
|
||||
usersItem.flow = config.flow();
|
||||
inbound.settings.decryption = config.security();
|
||||
}
|
||||
@@ -1389,7 +1394,7 @@ namespace v2rayN.Handler
|
||||
#region Gen speedtest config
|
||||
|
||||
|
||||
public static string GenerateClientSpeedtestConfigString(Config config, List<int> selecteds, out string msg)
|
||||
public static string GenerateClientSpeedtestConfigString(Config config, List<ServerTestItem> selecteds, out string msg)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1435,21 +1440,26 @@ namespace v2rayN.Handler
|
||||
|
||||
int httpPort = configCopy.GetLocalPort("speedtest");
|
||||
|
||||
foreach (int index in selecteds)
|
||||
foreach (var it in selecteds)
|
||||
{
|
||||
if (configCopy.vmess[index].configType == (int)EConfigType.Custom)
|
||||
if (it.configType == (int)EConfigType.Custom)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (it.port <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
configCopy.index = index;
|
||||
var port = httpPort + index;
|
||||
configCopy.index = it.selected;
|
||||
var port = httpPort + it.selected;
|
||||
|
||||
//Port In Used
|
||||
if (lstIpEndPoints != null && lstIpEndPoints.FindIndex(_it => _it.Port == port) >= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
it.port = port;
|
||||
|
||||
Inbounds inbound = new Inbounds
|
||||
{
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace v2rayN.Handler
|
||||
/// 新建进程,载入V2ray配置文件字符串
|
||||
/// 返回新进程pid。
|
||||
/// </summary>
|
||||
public int LoadV2rayConfigString(Config config, List<int> _selecteds)
|
||||
public int LoadV2rayConfigString(Config config, List<ServerTestItem> _selecteds)
|
||||
{
|
||||
int pid = -1;
|
||||
string configStr = V2rayConfigHandler.GenerateClientSpeedtestConfigString(config, _selecteds, out string msg);
|
||||
|
||||
@@ -375,6 +375,22 @@ namespace v2rayN.Mode
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public string indexId()
|
||||
{
|
||||
if (index < 0)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
return vmess[index].indexId.TrimEx();
|
||||
}
|
||||
public int FindIndexId(string indexId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(indexId))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return vmess.FindIndex(it => it.indexId == indexId);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -384,6 +400,7 @@ namespace v2rayN.Mode
|
||||
{
|
||||
public VmessItem()
|
||||
{
|
||||
indexId = string.Empty;
|
||||
configVersion = 1;
|
||||
address = string.Empty;
|
||||
port = 0;
|
||||
@@ -470,6 +487,10 @@ namespace v2rayN.Mode
|
||||
itemId = Utils.Base64Encode(itemId);
|
||||
return itemId;
|
||||
}
|
||||
public string indexId
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 版本(现在=2)
|
||||
|
||||
29
v2rayN/v2rayN/Mode/ServerTestItem.cs
Normal file
29
v2rayN/v2rayN/Mode/ServerTestItem.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
|
||||
namespace v2rayN.Mode
|
||||
{
|
||||
[Serializable]
|
||||
class ServerTestItem
|
||||
{
|
||||
public int selected
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public string indexId
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public string address
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public int port
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public int configType
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,4 +32,4 @@ using System.Runtime.InteropServices;
|
||||
// 方法是按如下所示使用“*”:
|
||||
//[assembly: AssemblyVersion("1.0.*")]
|
||||
//[assembly: AssemblyVersion("1.0.0")]
|
||||
[assembly: AssemblyFileVersion("4.29")]
|
||||
[assembly: AssemblyFileVersion("4.30")]
|
||||
|
||||
9
v2rayN/v2rayN/Resx/ResUI.Designer.cs
generated
9
v2rayN/v2rayN/Resx/ResUI.Designer.cs
generated
@@ -186,15 +186,6 @@ namespace v2rayN.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Please fill in the correct format extra ID 的本地化字符串。
|
||||
/// </summary>
|
||||
internal static string FillCorrectAlterId {
|
||||
get {
|
||||
return ResourceManager.GetString("FillCorrectAlterId", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Please fill in the correct custom DNS 的本地化字符串。
|
||||
/// </summary>
|
||||
|
||||
@@ -156,9 +156,6 @@
|
||||
<data name="FailedReadConfiguration" xml:space="preserve">
|
||||
<value>Failed to read configuration file</value>
|
||||
</data>
|
||||
<data name="FillCorrectAlterId" xml:space="preserve">
|
||||
<value>Please fill in the correct format extra ID</value>
|
||||
</data>
|
||||
<data name="FillCorrectServerPort" xml:space="preserve">
|
||||
<value>Please fill in the correct format server port</value>
|
||||
</data>
|
||||
|
||||
@@ -156,9 +156,6 @@
|
||||
<data name="FailedReadConfiguration" xml:space="preserve">
|
||||
<value>读取配置文件失败</value>
|
||||
</data>
|
||||
<data name="FillCorrectAlterId" xml:space="preserve">
|
||||
<value>请填写正确格式额外ID</value>
|
||||
</data>
|
||||
<data name="FillCorrectServerPort" xml:space="preserve">
|
||||
<value>请填写正确格式服务器端口</value>
|
||||
</data>
|
||||
|
||||
@@ -47,7 +47,6 @@
|
||||
"port": 10086,
|
||||
"users": [{
|
||||
"id": "a3482e88-686a-4a58-8126-99c9df64b7bf",
|
||||
"alterId": 64,
|
||||
"security": "auto"
|
||||
}]
|
||||
}],
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
"clients": [{
|
||||
"id": "23ad6b10-8d1a-40f7-8ad0-e3e35cd38297",
|
||||
"level": 1,
|
||||
"alterId": 64,
|
||||
"email": "t@t.tt"
|
||||
}]
|
||||
},
|
||||
|
||||
@@ -844,11 +844,18 @@ namespace v2rayN
|
||||
/// 取得GUID
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GetGUID()
|
||||
public static string GetGUID(bool full = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Guid.NewGuid().ToString("D");
|
||||
if (full)
|
||||
{
|
||||
return Guid.NewGuid().ToString("D");
|
||||
}
|
||||
else
|
||||
{
|
||||
return BitConverter.ToInt64(Guid.NewGuid().ToByteArray(), 0).ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -214,6 +214,7 @@
|
||||
<Compile Include="Mode\ServerStatistics.cs" />
|
||||
<Compile Include="Mode\SysproxyConfig.cs" />
|
||||
<Compile Include="Mode\EConfigType.cs" />
|
||||
<Compile Include="Mode\ServerTestItem.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
|
||||
Reference in New Issue
Block a user