pull/2148/head
2dust 2022-03-19 07:53:48 +08:00
parent c3971bda05
commit 539b6aafd9
10 changed files with 64 additions and 82 deletions

View File

@ -15,7 +15,7 @@ namespace v2rayN.Forms
private void AddServerForm_Load(object sender, EventArgs e) private void AddServerForm_Load(object sender, EventArgs e)
{ {
this.Text = ((EConfigType)eConfigType).ToString(); this.Text = (eConfigType).ToString();
cmbSecurity.Items.AddRange(Global.vmessSecuritys.ToArray()); cmbSecurity.Items.AddRange(Global.vmessSecuritys.ToArray());
cmbSecurity3.Items.AddRange(config.GetShadowsocksSecuritys().ToArray()); cmbSecurity3.Items.AddRange(config.GetShadowsocksSecuritys().ToArray());

View File

@ -284,7 +284,7 @@ namespace v2rayN.Forms
} }
} }
ListViewItem lvItem = new ListViewItem(def); ListViewItem lvItem = new ListViewItem(def);
Utils.AddSubItem(lvItem, EServerColName.configType.ToString(), ((EConfigType)item.configType).ToString()); Utils.AddSubItem(lvItem, EServerColName.configType.ToString(), (item.configType).ToString());
Utils.AddSubItem(lvItem, EServerColName.remarks.ToString(), item.remarks); Utils.AddSubItem(lvItem, EServerColName.remarks.ToString(), item.remarks);
Utils.AddSubItem(lvItem, EServerColName.address.ToString(), item.address); Utils.AddSubItem(lvItem, EServerColName.address.ToString(), item.address);
Utils.AddSubItem(lvItem, EServerColName.port.ToString(), item.port.ToString()); Utils.AddSubItem(lvItem, EServerColName.port.ToString(), item.port.ToString());
@ -576,10 +576,10 @@ namespace v2rayN.Forms
} }
ShowServerForm(lstVmess[index].configType, index); ShowServerForm(lstVmess[index].configType, index);
} }
private void ShowServerForm(int configType, int index) private void ShowServerForm(EConfigType configType, int index)
{ {
BaseServerForm fm; BaseServerForm fm;
if (configType == (int)EConfigType.Custom) if (configType == EConfigType.Custom)
{ {
fm = new AddServer2Form(); fm = new AddServer2Form();
} }
@ -589,7 +589,7 @@ namespace v2rayN.Forms
} }
fm.vmessItem = index >= 0 ? lstVmess[index] : null; fm.vmessItem = index >= 0 ? lstVmess[index] : null;
fm.groupId = groupId; fm.groupId = groupId;
fm.eConfigType = (EConfigType)configType; fm.eConfigType = configType;
if (fm.ShowDialog() == DialogResult.OK) if (fm.ShowDialog() == DialogResult.OK)
{ {
RefreshServers(); RefreshServers();
@ -658,12 +658,12 @@ namespace v2rayN.Forms
private void menuAddVmessServer_Click(object sender, EventArgs e) private void menuAddVmessServer_Click(object sender, EventArgs e)
{ {
ShowServerForm((int)EConfigType.Vmess, -1); ShowServerForm(EConfigType.Vmess, -1);
} }
private void menuAddVlessServer_Click(object sender, EventArgs e) private void menuAddVlessServer_Click(object sender, EventArgs e)
{ {
ShowServerForm((int)EConfigType.VLESS, -1); ShowServerForm(EConfigType.VLESS, -1);
} }
private void menuRemoveServer_Click(object sender, EventArgs e) private void menuRemoveServer_Click(object sender, EventArgs e)
@ -940,24 +940,24 @@ namespace v2rayN.Forms
private void menuAddCustomServer_Click(object sender, EventArgs e) private void menuAddCustomServer_Click(object sender, EventArgs e)
{ {
ShowServerForm((int)EConfigType.Custom, -1); ShowServerForm(EConfigType.Custom, -1);
} }
private void menuAddShadowsocksServer_Click(object sender, EventArgs e) private void menuAddShadowsocksServer_Click(object sender, EventArgs e)
{ {
ShowServerForm((int)EConfigType.Shadowsocks, -1); ShowServerForm(EConfigType.Shadowsocks, -1);
ShowForm(); ShowForm();
} }
private void menuAddSocksServer_Click(object sender, EventArgs e) private void menuAddSocksServer_Click(object sender, EventArgs e)
{ {
ShowServerForm((int)EConfigType.Socks, -1); ShowServerForm(EConfigType.Socks, -1);
ShowForm(); ShowForm();
} }
private void menuAddTrojanServer_Click(object sender, EventArgs e) private void menuAddTrojanServer_Click(object sender, EventArgs e)
{ {
ShowServerForm((int)EConfigType.Trojan, -1); ShowServerForm(EConfigType.Trojan, -1);
ShowForm(); ShowForm();
} }

View File

@ -197,7 +197,7 @@ namespace v2rayN.Handler
/// <returns></returns> /// <returns></returns>
public static int AddServer(ref Config config, VmessItem vmessItem, bool toFile = true) public static int AddServer(ref Config config, VmessItem vmessItem, bool toFile = true)
{ {
vmessItem.configType = (int)EConfigType.Vmess; vmessItem.configType = EConfigType.Vmess;
vmessItem.address = vmessItem.address.TrimEx(); vmessItem.address = vmessItem.address.TrimEx();
vmessItem.id = vmessItem.id.TrimEx(); vmessItem.id = vmessItem.id.TrimEx();
@ -439,7 +439,7 @@ namespace v2rayN.Handler
} }
vmessItem.address = newFileName; vmessItem.address = newFileName;
vmessItem.configType = (int)EConfigType.Custom; vmessItem.configType = EConfigType.Custom;
if (Utils.IsNullOrEmpty(vmessItem.remarks)) if (Utils.IsNullOrEmpty(vmessItem.remarks))
{ {
vmessItem.remarks = string.Format("import custom@{0}", DateTime.Now.ToShortDateString()); vmessItem.remarks = string.Format("import custom@{0}", DateTime.Now.ToShortDateString());
@ -474,7 +474,7 @@ namespace v2rayN.Handler
/// <returns></returns> /// <returns></returns>
public static int AddShadowsocksServer(ref Config config, VmessItem vmessItem, bool toFile = true) public static int AddShadowsocksServer(ref Config config, VmessItem vmessItem, bool toFile = true)
{ {
vmessItem.configType = (int)EConfigType.Shadowsocks; vmessItem.configType = EConfigType.Shadowsocks;
vmessItem.address = vmessItem.address.TrimEx(); vmessItem.address = vmessItem.address.TrimEx();
vmessItem.id = vmessItem.id.TrimEx(); vmessItem.id = vmessItem.id.TrimEx();
@ -503,7 +503,7 @@ namespace v2rayN.Handler
/// <returns></returns> /// <returns></returns>
public static int AddSocksServer(ref Config config, VmessItem vmessItem, bool toFile = true) public static int AddSocksServer(ref Config config, VmessItem vmessItem, bool toFile = true)
{ {
vmessItem.configType = (int)EConfigType.Socks; vmessItem.configType = EConfigType.Socks;
vmessItem.address = vmessItem.address.TrimEx(); vmessItem.address = vmessItem.address.TrimEx();
@ -526,7 +526,7 @@ namespace v2rayN.Handler
/// <returns></returns> /// <returns></returns>
public static int AddTrojanServer(ref Config config, VmessItem vmessItem, bool toFile = true) public static int AddTrojanServer(ref Config config, VmessItem vmessItem, bool toFile = true)
{ {
vmessItem.configType = (int)EConfigType.Trojan; vmessItem.configType = EConfigType.Trojan;
vmessItem.address = vmessItem.address.TrimEx(); vmessItem.address = vmessItem.address.TrimEx();
vmessItem.id = vmessItem.id.TrimEx(); vmessItem.id = vmessItem.id.TrimEx();
@ -563,7 +563,7 @@ namespace v2rayN.Handler
{ {
return 0; return 0;
} }
if (vmessItem.configType == (int)EConfigType.Vmess) if (vmessItem.configType == EConfigType.Vmess)
{ {
string path = ""; string path = "";
string host = ""; string host = "";
@ -672,35 +672,35 @@ namespace v2rayN.Handler
//groupId //groupId
vmessItem.groupId = groupId; vmessItem.groupId = groupId;
if (vmessItem.configType == (int)EConfigType.Vmess) if (vmessItem.configType == EConfigType.Vmess)
{ {
if (AddServer(ref config, vmessItem, false) == 0) if (AddServer(ref config, vmessItem, false) == 0)
{ {
countServers++; countServers++;
} }
} }
else if (vmessItem.configType == (int)EConfigType.Shadowsocks) else if (vmessItem.configType == EConfigType.Shadowsocks)
{ {
if (AddShadowsocksServer(ref config, vmessItem, false) == 0) if (AddShadowsocksServer(ref config, vmessItem, false) == 0)
{ {
countServers++; countServers++;
} }
} }
else if (vmessItem.configType == (int)EConfigType.Socks) else if (vmessItem.configType == EConfigType.Socks)
{ {
if (AddSocksServer(ref config, vmessItem, false) == 0) if (AddSocksServer(ref config, vmessItem, false) == 0)
{ {
countServers++; countServers++;
} }
} }
else if (vmessItem.configType == (int)EConfigType.Trojan) else if (vmessItem.configType == EConfigType.Trojan)
{ {
if (AddTrojanServer(ref config, vmessItem, false) == 0) if (AddTrojanServer(ref config, vmessItem, false) == 0)
{ {
countServers++; countServers++;
} }
} }
else if (vmessItem.configType == (int)EConfigType.VLESS) else if (vmessItem.configType == EConfigType.VLESS)
{ {
if (AddVlessServer(ref config, vmessItem, false) == 0) if (AddVlessServer(ref config, vmessItem, false) == 0)
{ {
@ -839,7 +839,7 @@ namespace v2rayN.Handler
/// <returns></returns> /// <returns></returns>
public static int AddVlessServer(ref Config config, VmessItem vmessItem, bool toFile = true) public static int AddVlessServer(ref Config config, VmessItem vmessItem, bool toFile = true)
{ {
vmessItem.configType = (int)EConfigType.VLESS; vmessItem.configType = EConfigType.VLESS;
vmessItem.address = vmessItem.address.TrimEx(); vmessItem.address = vmessItem.address.TrimEx();
vmessItem.id = vmessItem.id.TrimEx(); vmessItem.id = vmessItem.id.TrimEx();

View File

@ -85,8 +85,8 @@ namespace v2rayN.Handler
{ {
return; return;
} }
if (item.configType != (int)EConfigType.Vmess if (item.configType != EConfigType.Vmess
&& item.configType != (int)EConfigType.VLESS) && item.configType != EConfigType.VLESS)
{ {
UI.Show(UIRes.I18N("NonVmessService")); UI.Show(UIRes.I18N("NonVmessService"));
return; return;
@ -125,8 +125,8 @@ namespace v2rayN.Handler
{ {
return; return;
} }
if (item.configType != (int)EConfigType.Vmess if (item.configType != EConfigType.Vmess
&& item.configType != (int)EConfigType.VLESS) && item.configType != EConfigType.VLESS)
{ {
UI.Show(UIRes.I18N("NonVmessService")); UI.Show(UIRes.I18N("NonVmessService"));
return; return;

View File

@ -30,19 +30,19 @@ namespace v2rayN.Handler
switch (item.configType) switch (item.configType)
{ {
case (int)EConfigType.Vmess: case EConfigType.Vmess:
url = ShareVmess(item); url = ShareVmess(item);
break; break;
case (int)EConfigType.Shadowsocks: case EConfigType.Shadowsocks:
url = ShareShadowsocks(item); url = ShareShadowsocks(item);
break; break;
case (int)EConfigType.Socks: case EConfigType.Socks:
url = ShareSocks(item); url = ShareSocks(item);
break; break;
case (int)EConfigType.Trojan: case EConfigType.Trojan:
url = ShareTrojan(item); url = ShareTrojan(item);
break; break;
case (int)EConfigType.VLESS: case EConfigType.VLESS:
url = ShareVLESS(item); url = ShareVLESS(item);
break; break;
default: default:
@ -354,7 +354,7 @@ namespace v2rayN.Handler
return null; return null;
} }
vmessItem.configType = (int)EConfigType.Shadowsocks; vmessItem.configType = EConfigType.Shadowsocks;
} }
else if (result.StartsWith(Global.socksProtocol)) else if (result.StartsWith(Global.socksProtocol))
{ {
@ -374,7 +374,7 @@ namespace v2rayN.Handler
return null; return null;
} }
vmessItem.configType = (int)EConfigType.Socks; vmessItem.configType = EConfigType.Socks;
} }
else if (result.StartsWith(Global.trojanProtocol)) else if (result.StartsWith(Global.trojanProtocol))
{ {
@ -408,7 +408,7 @@ namespace v2rayN.Handler
msg = string.Empty; msg = string.Empty;
VmessItem vmessItem = new VmessItem(); VmessItem vmessItem = new VmessItem();
vmessItem.configType = (int)EConfigType.Vmess; vmessItem.configType = EConfigType.Vmess;
result = result.Substring(Global.vmessProtocol.Length); result = result.Substring(Global.vmessProtocol.Length);
result = Utils.Base64Decode(result); result = Utils.Base64Decode(result);
@ -461,7 +461,7 @@ namespace v2rayN.Handler
{ {
VmessItem vmessItem = new VmessItem VmessItem vmessItem = new VmessItem
{ {
configType = (int)EConfigType.Vmess configType = EConfigType.Vmess
}; };
result = result.Substring(Global.vmessProtocol.Length); result = result.Substring(Global.vmessProtocol.Length);
int indexSplit = result.IndexOf("?"); int indexSplit = result.IndexOf("?");
@ -499,7 +499,7 @@ namespace v2rayN.Handler
{ {
VmessItem i = new VmessItem VmessItem i = new VmessItem
{ {
configType = (int)EConfigType.Vmess, configType = EConfigType.Vmess,
security = "auto" security = "auto"
}; };
@ -655,7 +655,7 @@ namespace v2rayN.Handler
private static VmessItem ResolveSocks(string result) private static VmessItem ResolveSocks(string result)
{ {
VmessItem vmessItem = new VmessItem(); VmessItem vmessItem = new VmessItem();
vmessItem.configType = (int)EConfigType.Socks; vmessItem.configType = EConfigType.Socks;
result = result.Substring(Global.socksProtocol.Length); result = result.Substring(Global.socksProtocol.Length);
//remark //remark
int indexRemark = result.IndexOf("#"); int indexRemark = result.IndexOf("#");
@ -733,7 +733,7 @@ namespace v2rayN.Handler
{ {
VmessItem item = new VmessItem VmessItem item = new VmessItem
{ {
configType = (int)EConfigType.Trojan configType = EConfigType.Trojan
}; };
Uri url = new Uri(result); Uri url = new Uri(result);
@ -752,7 +752,7 @@ namespace v2rayN.Handler
{ {
VmessItem item = new VmessItem VmessItem item = new VmessItem
{ {
configType = (int)EConfigType.VLESS, configType = EConfigType.VLESS,
security = "none" security = "none"
}; };

View File

@ -64,7 +64,7 @@ namespace v2rayN.Handler
{ {
foreach (var it in _selecteds) foreach (var it in _selecteds)
{ {
if (it.configType == (int)EConfigType.Custom) if (it.configType == EConfigType.Custom)
{ {
continue; continue;
} }
@ -129,7 +129,7 @@ namespace v2rayN.Handler
{ {
continue; continue;
} }
if (it.configType == (int)EConfigType.Custom) if (it.configType == EConfigType.Custom)
{ {
continue; continue;
} }
@ -226,7 +226,7 @@ namespace v2rayN.Handler
{ {
continue; continue;
} }
if (it.configType == (int)EConfigType.Custom) if (it.configType == EConfigType.Custom)
{ {
continue; continue;
} }

View File

@ -37,7 +37,7 @@ namespace v2rayN.Handler
} }
msg = UIRes.I18N("InitialConfiguration"); msg = UIRes.I18N("InitialConfiguration");
if (node.configType == (int)EConfigType.Custom) if (node.configType == EConfigType.Custom)
{ {
return GenerateClientCustomConfig(node, fileName, out msg); return GenerateClientCustomConfig(node, fileName, out msg);
} }
@ -334,7 +334,7 @@ namespace v2rayN.Handler
{ {
var config = LazyConfig.Instance.GetConfig(); var config = LazyConfig.Instance.GetConfig();
Outbounds outbound = v2rayConfig.outbounds[0]; Outbounds outbound = v2rayConfig.outbounds[0];
if (node.configType == (int)EConfigType.Vmess) if (node.configType == EConfigType.Vmess)
{ {
VnextItem vnextItem; VnextItem vnextItem;
if (outbound.settings.vnext.Count <= 0) if (outbound.settings.vnext.Count <= 0)
@ -384,7 +384,7 @@ namespace v2rayN.Handler
outbound.protocol = Global.vmessProtocolLite; outbound.protocol = Global.vmessProtocolLite;
outbound.settings.servers = null; outbound.settings.servers = null;
} }
else if (node.configType == (int)EConfigType.Shadowsocks) else if (node.configType == EConfigType.Shadowsocks)
{ {
ServersItem serversItem; ServersItem serversItem;
if (outbound.settings.servers.Count <= 0) if (outbound.settings.servers.Count <= 0)
@ -420,7 +420,7 @@ namespace v2rayN.Handler
outbound.protocol = Global.ssProtocolLite; outbound.protocol = Global.ssProtocolLite;
outbound.settings.vnext = null; outbound.settings.vnext = null;
} }
else if (node.configType == (int)EConfigType.Socks) else if (node.configType == EConfigType.Socks)
{ {
ServersItem serversItem; ServersItem serversItem;
if (outbound.settings.servers.Count <= 0) if (outbound.settings.servers.Count <= 0)
@ -457,7 +457,7 @@ namespace v2rayN.Handler
outbound.protocol = Global.socksProtocolLite; outbound.protocol = Global.socksProtocolLite;
outbound.settings.vnext = null; outbound.settings.vnext = null;
} }
else if (node.configType == (int)EConfigType.VLESS) else if (node.configType == EConfigType.VLESS)
{ {
VnextItem vnextItem; VnextItem vnextItem;
if (outbound.settings.vnext.Count <= 0) if (outbound.settings.vnext.Count <= 0)
@ -516,7 +516,7 @@ namespace v2rayN.Handler
outbound.protocol = Global.vlessProtocolLite; outbound.protocol = Global.vlessProtocolLite;
outbound.settings.servers = null; outbound.settings.servers = null;
} }
else if (node.configType == (int)EConfigType.Trojan) else if (node.configType == EConfigType.Trojan)
{ {
ServersItem serversItem; ServersItem serversItem;
if (outbound.settings.servers.Count <= 0) if (outbound.settings.servers.Count <= 0)
@ -1022,13 +1022,13 @@ namespace v2rayN.Handler
usersItem.id = node.id; usersItem.id = node.id;
usersItem.email = Global.userEMail; usersItem.email = Global.userEMail;
if (node.configType == (int)EConfigType.Vmess) if (node.configType == EConfigType.Vmess)
{ {
inbound.protocol = Global.vmessProtocolLite; inbound.protocol = Global.vmessProtocolLite;
usersItem.alterId = node.alterId; usersItem.alterId = node.alterId;
} }
else if (node.configType == (int)EConfigType.VLESS) else if (node.configType == EConfigType.VLESS)
{ {
inbound.protocol = Global.vlessProtocolLite; inbound.protocol = Global.vlessProtocolLite;
usersItem.flow = node.flow; usersItem.flow = node.flow;
@ -1432,7 +1432,7 @@ namespace v2rayN.Handler
foreach (var it in selecteds) foreach (var it in selecteds)
{ {
if (it.configType == (int)EConfigType.Custom) if (it.configType == EConfigType.Custom)
{ {
continue; continue;
} }
@ -1440,7 +1440,7 @@ namespace v2rayN.Handler
{ {
continue; continue;
} }
if (it.configType == (int)EConfigType.Vmess || it.configType == (int)EConfigType.VLESS) if (it.configType == EConfigType.Vmess || it.configType == EConfigType.VLESS)
{ {
if (!Utils.IsGuidByParse(configCopy.GetVmessItem(it.indexId).id)) if (!Utils.IsGuidByParse(configCopy.GetVmessItem(it.indexId).id))
{ {

View File

@ -320,7 +320,7 @@ namespace v2rayN.Handler
private void SetCore(Config config, VmessItem item) private void SetCore(Config config, VmessItem item)
{ {
var coreType = config.GetCoreType((EConfigType)item.configType); var coreType = config.GetCoreType(item.configType);
if (item.coreType != null) if (item.coreType != null)
{ {
coreType = (ECoreType)item.coreType; coreType = (ECoreType)item.coreType;

View File

@ -308,7 +308,7 @@ namespace v2rayN.Mode
public VmessItem() public VmessItem()
{ {
indexId = string.Empty; indexId = string.Empty;
configType = (int)EConfigType.Vmess; configType = EConfigType.Vmess;
configVersion = 2; configVersion = 2;
sort = 0; sort = 0;
address = string.Empty; address = string.Empty;
@ -332,7 +332,7 @@ namespace v2rayN.Mode
#region function #region function
public string GetSummary() public string GetSummary()
{ {
string summary = string.Format("[{0}] ", ((EConfigType)configType).ToString()); string summary = string.Format("[{0}] ", (configType).ToString());
string[] arrAddr = address.Split('.'); string[] arrAddr = address.Split('.');
string addr; string addr;
if (arrAddr.Length > 2) if (arrAddr.Length > 2)
@ -349,34 +349,16 @@ namespace v2rayN.Mode
} }
switch (configType) switch (configType)
{ {
case (int)EConfigType.Vmess: case EConfigType.Vmess:
case (int)EConfigType.Shadowsocks: case EConfigType.Shadowsocks:
case (int)EConfigType.Socks: case EConfigType.Socks:
case (int)EConfigType.VLESS: case EConfigType.VLESS:
case (int)EConfigType.Trojan: case EConfigType.Trojan:
summary += string.Format("{0}({1}:{2})", remarks, addr, port); summary += string.Format("{0}({1}:{2})", remarks, addr, port);
break; break;
default: default:
summary += string.Format("{0}", remarks); summary += string.Format("{0}", remarks);
break; break;
//case (int)EConfigType.Vmess:
// summary += string.Format("{0}({1}:{2})", remarks, addr, port);
// break;
//case (int)EConfigType.Shadowsocks:
// summary += string.Format("{0}({1}:{2})", remarks, addr, port);
// break;
//case (int)EConfigType.Socks:
// summary += string.Format("{0}({1}:{2})", remarks, addr, port);
// break;
//case (int)EConfigType.VLESS:
// summary += string.Format("{0}({1}:{2})", remarks, addr, port);
// break;
//case (int)EConfigType.Trojan:
// summary += string.Format("{0}({1}:{2})", remarks, addr, port);
// break;
//default:
// summary += string.Format("{0}", remarks);
// break;
} }
return summary; return summary;
} }
@ -435,7 +417,7 @@ namespace v2rayN.Mode
/// <summary> /// <summary>
/// config type(1=normal,2=custom) /// config type(1=normal,2=custom)
/// </summary> /// </summary>
public int configType public EConfigType configType
{ {
get; set; get; set;
} }

View File

@ -17,7 +17,7 @@ namespace v2rayN.Mode
{ {
get; set; get; set;
} }
public int configType public EConfigType configType
{ {
get; set; get; set;
} }