diff --git a/v2rayN/v2rayN/Forms/AddServerForm.cs b/v2rayN/v2rayN/Forms/AddServerForm.cs
index 1f0c2722..e623929a 100644
--- a/v2rayN/v2rayN/Forms/AddServerForm.cs
+++ b/v2rayN/v2rayN/Forms/AddServerForm.cs
@@ -15,7 +15,7 @@ namespace v2rayN.Forms
private void AddServerForm_Load(object sender, EventArgs e)
{
- this.Text = ((EConfigType)eConfigType).ToString();
+ this.Text = (eConfigType).ToString();
cmbSecurity.Items.AddRange(Global.vmessSecuritys.ToArray());
cmbSecurity3.Items.AddRange(config.GetShadowsocksSecuritys().ToArray());
diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs
index 07ff609d..30b959e2 100644
--- a/v2rayN/v2rayN/Forms/MainForm.cs
+++ b/v2rayN/v2rayN/Forms/MainForm.cs
@@ -284,7 +284,7 @@ namespace v2rayN.Forms
}
}
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.address.ToString(), item.address);
Utils.AddSubItem(lvItem, EServerColName.port.ToString(), item.port.ToString());
@@ -576,10 +576,10 @@ namespace v2rayN.Forms
}
ShowServerForm(lstVmess[index].configType, index);
}
- private void ShowServerForm(int configType, int index)
+ private void ShowServerForm(EConfigType configType, int index)
{
BaseServerForm fm;
- if (configType == (int)EConfigType.Custom)
+ if (configType == EConfigType.Custom)
{
fm = new AddServer2Form();
}
@@ -589,7 +589,7 @@ namespace v2rayN.Forms
}
fm.vmessItem = index >= 0 ? lstVmess[index] : null;
fm.groupId = groupId;
- fm.eConfigType = (EConfigType)configType;
+ fm.eConfigType = configType;
if (fm.ShowDialog() == DialogResult.OK)
{
RefreshServers();
@@ -658,12 +658,12 @@ namespace v2rayN.Forms
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)
{
- ShowServerForm((int)EConfigType.VLESS, -1);
+ ShowServerForm(EConfigType.VLESS, -1);
}
private void menuRemoveServer_Click(object sender, EventArgs e)
@@ -940,24 +940,24 @@ namespace v2rayN.Forms
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)
{
- ShowServerForm((int)EConfigType.Shadowsocks, -1);
+ ShowServerForm(EConfigType.Shadowsocks, -1);
ShowForm();
}
private void menuAddSocksServer_Click(object sender, EventArgs e)
{
- ShowServerForm((int)EConfigType.Socks, -1);
+ ShowServerForm(EConfigType.Socks, -1);
ShowForm();
}
private void menuAddTrojanServer_Click(object sender, EventArgs e)
{
- ShowServerForm((int)EConfigType.Trojan, -1);
+ ShowServerForm(EConfigType.Trojan, -1);
ShowForm();
}
diff --git a/v2rayN/v2rayN/Handler/ConfigHandler.cs b/v2rayN/v2rayN/Handler/ConfigHandler.cs
index 9bdf698b..40b32a5b 100644
--- a/v2rayN/v2rayN/Handler/ConfigHandler.cs
+++ b/v2rayN/v2rayN/Handler/ConfigHandler.cs
@@ -197,7 +197,7 @@ namespace v2rayN.Handler
///
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.id = vmessItem.id.TrimEx();
@@ -439,7 +439,7 @@ namespace v2rayN.Handler
}
vmessItem.address = newFileName;
- vmessItem.configType = (int)EConfigType.Custom;
+ vmessItem.configType = EConfigType.Custom;
if (Utils.IsNullOrEmpty(vmessItem.remarks))
{
vmessItem.remarks = string.Format("import custom@{0}", DateTime.Now.ToShortDateString());
@@ -474,7 +474,7 @@ namespace v2rayN.Handler
///
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.id = vmessItem.id.TrimEx();
@@ -503,7 +503,7 @@ namespace v2rayN.Handler
///
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();
@@ -526,7 +526,7 @@ namespace v2rayN.Handler
///
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.id = vmessItem.id.TrimEx();
@@ -563,7 +563,7 @@ namespace v2rayN.Handler
{
return 0;
}
- if (vmessItem.configType == (int)EConfigType.Vmess)
+ if (vmessItem.configType == EConfigType.Vmess)
{
string path = "";
string host = "";
@@ -672,35 +672,35 @@ namespace v2rayN.Handler
//groupId
vmessItem.groupId = groupId;
- if (vmessItem.configType == (int)EConfigType.Vmess)
+ if (vmessItem.configType == EConfigType.Vmess)
{
if (AddServer(ref config, vmessItem, false) == 0)
{
countServers++;
}
}
- else if (vmessItem.configType == (int)EConfigType.Shadowsocks)
+ else if (vmessItem.configType == EConfigType.Shadowsocks)
{
if (AddShadowsocksServer(ref config, vmessItem, false) == 0)
{
countServers++;
}
}
- else if (vmessItem.configType == (int)EConfigType.Socks)
+ else if (vmessItem.configType == EConfigType.Socks)
{
if (AddSocksServer(ref config, vmessItem, false) == 0)
{
countServers++;
}
}
- else if (vmessItem.configType == (int)EConfigType.Trojan)
+ else if (vmessItem.configType == EConfigType.Trojan)
{
if (AddTrojanServer(ref config, vmessItem, false) == 0)
{
countServers++;
}
}
- else if (vmessItem.configType == (int)EConfigType.VLESS)
+ else if (vmessItem.configType == EConfigType.VLESS)
{
if (AddVlessServer(ref config, vmessItem, false) == 0)
{
@@ -839,7 +839,7 @@ namespace v2rayN.Handler
///
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.id = vmessItem.id.TrimEx();
diff --git a/v2rayN/v2rayN/Handler/MainFormHandler.cs b/v2rayN/v2rayN/Handler/MainFormHandler.cs
index 2387bb68..1661bbd2 100644
--- a/v2rayN/v2rayN/Handler/MainFormHandler.cs
+++ b/v2rayN/v2rayN/Handler/MainFormHandler.cs
@@ -85,8 +85,8 @@ namespace v2rayN.Handler
{
return;
}
- if (item.configType != (int)EConfigType.Vmess
- && item.configType != (int)EConfigType.VLESS)
+ if (item.configType != EConfigType.Vmess
+ && item.configType != EConfigType.VLESS)
{
UI.Show(UIRes.I18N("NonVmessService"));
return;
@@ -125,8 +125,8 @@ namespace v2rayN.Handler
{
return;
}
- if (item.configType != (int)EConfigType.Vmess
- && item.configType != (int)EConfigType.VLESS)
+ if (item.configType != EConfigType.Vmess
+ && item.configType != EConfigType.VLESS)
{
UI.Show(UIRes.I18N("NonVmessService"));
return;
diff --git a/v2rayN/v2rayN/Handler/ShareHandler.cs b/v2rayN/v2rayN/Handler/ShareHandler.cs
index badd9812..fb755af5 100644
--- a/v2rayN/v2rayN/Handler/ShareHandler.cs
+++ b/v2rayN/v2rayN/Handler/ShareHandler.cs
@@ -30,19 +30,19 @@ namespace v2rayN.Handler
switch (item.configType)
{
- case (int)EConfigType.Vmess:
+ case EConfigType.Vmess:
url = ShareVmess(item);
break;
- case (int)EConfigType.Shadowsocks:
+ case EConfigType.Shadowsocks:
url = ShareShadowsocks(item);
break;
- case (int)EConfigType.Socks:
+ case EConfigType.Socks:
url = ShareSocks(item);
break;
- case (int)EConfigType.Trojan:
+ case EConfigType.Trojan:
url = ShareTrojan(item);
break;
- case (int)EConfigType.VLESS:
+ case EConfigType.VLESS:
url = ShareVLESS(item);
break;
default:
@@ -354,7 +354,7 @@ namespace v2rayN.Handler
return null;
}
- vmessItem.configType = (int)EConfigType.Shadowsocks;
+ vmessItem.configType = EConfigType.Shadowsocks;
}
else if (result.StartsWith(Global.socksProtocol))
{
@@ -374,7 +374,7 @@ namespace v2rayN.Handler
return null;
}
- vmessItem.configType = (int)EConfigType.Socks;
+ vmessItem.configType = EConfigType.Socks;
}
else if (result.StartsWith(Global.trojanProtocol))
{
@@ -408,7 +408,7 @@ namespace v2rayN.Handler
msg = string.Empty;
VmessItem vmessItem = new VmessItem();
- vmessItem.configType = (int)EConfigType.Vmess;
+ vmessItem.configType = EConfigType.Vmess;
result = result.Substring(Global.vmessProtocol.Length);
result = Utils.Base64Decode(result);
@@ -461,7 +461,7 @@ namespace v2rayN.Handler
{
VmessItem vmessItem = new VmessItem
{
- configType = (int)EConfigType.Vmess
+ configType = EConfigType.Vmess
};
result = result.Substring(Global.vmessProtocol.Length);
int indexSplit = result.IndexOf("?");
@@ -499,7 +499,7 @@ namespace v2rayN.Handler
{
VmessItem i = new VmessItem
{
- configType = (int)EConfigType.Vmess,
+ configType = EConfigType.Vmess,
security = "auto"
};
@@ -655,7 +655,7 @@ namespace v2rayN.Handler
private static VmessItem ResolveSocks(string result)
{
VmessItem vmessItem = new VmessItem();
- vmessItem.configType = (int)EConfigType.Socks;
+ vmessItem.configType = EConfigType.Socks;
result = result.Substring(Global.socksProtocol.Length);
//remark
int indexRemark = result.IndexOf("#");
@@ -733,7 +733,7 @@ namespace v2rayN.Handler
{
VmessItem item = new VmessItem
{
- configType = (int)EConfigType.Trojan
+ configType = EConfigType.Trojan
};
Uri url = new Uri(result);
@@ -752,7 +752,7 @@ namespace v2rayN.Handler
{
VmessItem item = new VmessItem
{
- configType = (int)EConfigType.VLESS,
+ configType = EConfigType.VLESS,
security = "none"
};
diff --git a/v2rayN/v2rayN/Handler/SpeedtestHandler.cs b/v2rayN/v2rayN/Handler/SpeedtestHandler.cs
index db05ec2f..c6faabd2 100644
--- a/v2rayN/v2rayN/Handler/SpeedtestHandler.cs
+++ b/v2rayN/v2rayN/Handler/SpeedtestHandler.cs
@@ -64,7 +64,7 @@ namespace v2rayN.Handler
{
foreach (var it in _selecteds)
{
- if (it.configType == (int)EConfigType.Custom)
+ if (it.configType == EConfigType.Custom)
{
continue;
}
@@ -129,7 +129,7 @@ namespace v2rayN.Handler
{
continue;
}
- if (it.configType == (int)EConfigType.Custom)
+ if (it.configType == EConfigType.Custom)
{
continue;
}
@@ -226,7 +226,7 @@ namespace v2rayN.Handler
{
continue;
}
- if (it.configType == (int)EConfigType.Custom)
+ if (it.configType == EConfigType.Custom)
{
continue;
}
diff --git a/v2rayN/v2rayN/Handler/V2rayConfigHandler.cs b/v2rayN/v2rayN/Handler/V2rayConfigHandler.cs
index 5324683c..dae03c68 100644
--- a/v2rayN/v2rayN/Handler/V2rayConfigHandler.cs
+++ b/v2rayN/v2rayN/Handler/V2rayConfigHandler.cs
@@ -37,7 +37,7 @@ namespace v2rayN.Handler
}
msg = UIRes.I18N("InitialConfiguration");
- if (node.configType == (int)EConfigType.Custom)
+ if (node.configType == EConfigType.Custom)
{
return GenerateClientCustomConfig(node, fileName, out msg);
}
@@ -334,7 +334,7 @@ namespace v2rayN.Handler
{
var config = LazyConfig.Instance.GetConfig();
Outbounds outbound = v2rayConfig.outbounds[0];
- if (node.configType == (int)EConfigType.Vmess)
+ if (node.configType == EConfigType.Vmess)
{
VnextItem vnextItem;
if (outbound.settings.vnext.Count <= 0)
@@ -384,7 +384,7 @@ namespace v2rayN.Handler
outbound.protocol = Global.vmessProtocolLite;
outbound.settings.servers = null;
}
- else if (node.configType == (int)EConfigType.Shadowsocks)
+ else if (node.configType == EConfigType.Shadowsocks)
{
ServersItem serversItem;
if (outbound.settings.servers.Count <= 0)
@@ -420,7 +420,7 @@ namespace v2rayN.Handler
outbound.protocol = Global.ssProtocolLite;
outbound.settings.vnext = null;
}
- else if (node.configType == (int)EConfigType.Socks)
+ else if (node.configType == EConfigType.Socks)
{
ServersItem serversItem;
if (outbound.settings.servers.Count <= 0)
@@ -457,7 +457,7 @@ namespace v2rayN.Handler
outbound.protocol = Global.socksProtocolLite;
outbound.settings.vnext = null;
}
- else if (node.configType == (int)EConfigType.VLESS)
+ else if (node.configType == EConfigType.VLESS)
{
VnextItem vnextItem;
if (outbound.settings.vnext.Count <= 0)
@@ -516,7 +516,7 @@ namespace v2rayN.Handler
outbound.protocol = Global.vlessProtocolLite;
outbound.settings.servers = null;
}
- else if (node.configType == (int)EConfigType.Trojan)
+ else if (node.configType == EConfigType.Trojan)
{
ServersItem serversItem;
if (outbound.settings.servers.Count <= 0)
@@ -1022,13 +1022,13 @@ namespace v2rayN.Handler
usersItem.id = node.id;
usersItem.email = Global.userEMail;
- if (node.configType == (int)EConfigType.Vmess)
+ if (node.configType == EConfigType.Vmess)
{
inbound.protocol = Global.vmessProtocolLite;
usersItem.alterId = node.alterId;
}
- else if (node.configType == (int)EConfigType.VLESS)
+ else if (node.configType == EConfigType.VLESS)
{
inbound.protocol = Global.vlessProtocolLite;
usersItem.flow = node.flow;
@@ -1432,7 +1432,7 @@ namespace v2rayN.Handler
foreach (var it in selecteds)
{
- if (it.configType == (int)EConfigType.Custom)
+ if (it.configType == EConfigType.Custom)
{
continue;
}
@@ -1440,7 +1440,7 @@ namespace v2rayN.Handler
{
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))
{
diff --git a/v2rayN/v2rayN/Handler/V2rayHandler.cs b/v2rayN/v2rayN/Handler/V2rayHandler.cs
index 4b6c234a..1005366b 100644
--- a/v2rayN/v2rayN/Handler/V2rayHandler.cs
+++ b/v2rayN/v2rayN/Handler/V2rayHandler.cs
@@ -320,7 +320,7 @@ namespace v2rayN.Handler
private void SetCore(Config config, VmessItem item)
{
- var coreType = config.GetCoreType((EConfigType)item.configType);
+ var coreType = config.GetCoreType(item.configType);
if (item.coreType != null)
{
coreType = (ECoreType)item.coreType;
diff --git a/v2rayN/v2rayN/Mode/Config.cs b/v2rayN/v2rayN/Mode/Config.cs
index ee4e9447..d8ccb076 100644
--- a/v2rayN/v2rayN/Mode/Config.cs
+++ b/v2rayN/v2rayN/Mode/Config.cs
@@ -308,7 +308,7 @@ namespace v2rayN.Mode
public VmessItem()
{
indexId = string.Empty;
- configType = (int)EConfigType.Vmess;
+ configType = EConfigType.Vmess;
configVersion = 2;
sort = 0;
address = string.Empty;
@@ -332,7 +332,7 @@ namespace v2rayN.Mode
#region function
public string GetSummary()
{
- string summary = string.Format("[{0}] ", ((EConfigType)configType).ToString());
+ string summary = string.Format("[{0}] ", (configType).ToString());
string[] arrAddr = address.Split('.');
string addr;
if (arrAddr.Length > 2)
@@ -349,34 +349,16 @@ namespace v2rayN.Mode
}
switch (configType)
{
- case (int)EConfigType.Vmess:
- case (int)EConfigType.Shadowsocks:
- case (int)EConfigType.Socks:
- case (int)EConfigType.VLESS:
- case (int)EConfigType.Trojan:
+ case EConfigType.Vmess:
+ case EConfigType.Shadowsocks:
+ case EConfigType.Socks:
+ case EConfigType.VLESS:
+ case EConfigType.Trojan:
summary += string.Format("{0}({1}:{2})", remarks, addr, port);
break;
default:
summary += string.Format("{0}", remarks);
- 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;
+ break;
}
return summary;
}
@@ -435,7 +417,7 @@ namespace v2rayN.Mode
///
/// config type(1=normal,2=custom)
///
- public int configType
+ public EConfigType configType
{
get; set;
}
diff --git a/v2rayN/v2rayN/Mode/ServerTestItem.cs b/v2rayN/v2rayN/Mode/ServerTestItem.cs
index 2d204a8d..45d6b5f9 100644
--- a/v2rayN/v2rayN/Mode/ServerTestItem.cs
+++ b/v2rayN/v2rayN/Mode/ServerTestItem.cs
@@ -17,7 +17,7 @@ namespace v2rayN.Mode
{
get; set;
}
- public int configType
+ public EConfigType configType
{
get; set;
}