mirror of
https://github.com/2dust/v2rayN.git
synced 2025-07-02 04:52:09 +00:00
refactor some code
This commit is contained in:
parent
78d6bcd57a
commit
a2679e009d
10 changed files with 48 additions and 42 deletions
|
@ -16,13 +16,7 @@ namespace v2rayN.Forms
|
||||||
private void AddServerForm_Load(object sender, EventArgs e)
|
private void AddServerForm_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
this.Text = (eConfigType).ToString();
|
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.AddRange(Global.coreTypes.ToArray());
|
||||||
cmbCoreType.Items.Add(string.Empty);
|
cmbCoreType.Items.Add(string.Empty);
|
||||||
|
|
||||||
|
@ -31,12 +25,16 @@ namespace v2rayN.Forms
|
||||||
case EConfigType.Vmess:
|
case EConfigType.Vmess:
|
||||||
panVmess.Dock = DockStyle.Fill;
|
panVmess.Dock = DockStyle.Fill;
|
||||||
panVmess.Visible = true;
|
panVmess.Visible = true;
|
||||||
|
|
||||||
|
cmbSecurity.Items.AddRange(Global.vmessSecuritys.ToArray());
|
||||||
break;
|
break;
|
||||||
case EConfigType.Shadowsocks:
|
case EConfigType.Shadowsocks:
|
||||||
panSs.Dock = DockStyle.Fill;
|
panSs.Dock = DockStyle.Fill;
|
||||||
panSs.Visible = true;
|
panSs.Visible = true;
|
||||||
panTran.Visible = false;
|
panTran.Visible = false;
|
||||||
this.Height = this.Height - panTran.Height;
|
this.Height = this.Height - panTran.Height;
|
||||||
|
|
||||||
|
cmbSecurity3.Items.AddRange(LazyConfig.Instance.GetShadowsocksSecuritys().ToArray());
|
||||||
break;
|
break;
|
||||||
case EConfigType.Socks:
|
case EConfigType.Socks:
|
||||||
panSocks.Dock = DockStyle.Fill;
|
panSocks.Dock = DockStyle.Fill;
|
||||||
|
@ -48,11 +46,15 @@ namespace v2rayN.Forms
|
||||||
panVless.Dock = DockStyle.Fill;
|
panVless.Dock = DockStyle.Fill;
|
||||||
panVless.Visible = true;
|
panVless.Visible = true;
|
||||||
transportControl.AllowXtls = true;
|
transportControl.AllowXtls = true;
|
||||||
|
|
||||||
|
cmbFlow5.Items.AddRange(Global.xtlsFlows.ToArray());
|
||||||
break;
|
break;
|
||||||
case EConfigType.Trojan:
|
case EConfigType.Trojan:
|
||||||
panTrojan.Dock = DockStyle.Fill;
|
panTrojan.Dock = DockStyle.Fill;
|
||||||
panTrojan.Visible = true;
|
panTrojan.Visible = true;
|
||||||
transportControl.AllowXtls = true;
|
transportControl.AllowXtls = true;
|
||||||
|
|
||||||
|
cmbFlow6.Items.AddRange(Global.xtlsFlows.ToArray());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -488,7 +488,7 @@ namespace v2rayN.Handler
|
||||||
vmessItem.id = vmessItem.id.TrimEx();
|
vmessItem.id = vmessItem.id.TrimEx();
|
||||||
vmessItem.security = vmessItem.security.TrimEx();
|
vmessItem.security = vmessItem.security.TrimEx();
|
||||||
|
|
||||||
if (!config.GetShadowsocksSecuritys().Contains(vmessItem.security))
|
if (!LazyConfig.Instance.GetShadowsocksSecuritys().Contains(vmessItem.security))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using v2rayN.Mode;
|
using v2rayN.Mode;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace v2rayN.Handler
|
namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
|
@ -20,5 +22,34 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
return _config;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace v2rayN.Handler
|
||||||
if (!Utils.IsNullOrEmpty(item.customIcon) && File.Exists(item.customIcon))
|
if (!Utils.IsNullOrEmpty(item.customIcon) && File.Exists(item.customIcon))
|
||||||
{
|
{
|
||||||
graphics.FillRectangle(drawBrush, new Rectangle(0, 0, width, height));
|
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;
|
customIcon = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -400,7 +400,7 @@ namespace v2rayN.Handler
|
||||||
serversItem.address = node.address;
|
serversItem.address = node.address;
|
||||||
serversItem.port = node.port;
|
serversItem.port = node.port;
|
||||||
serversItem.password = node.id;
|
serversItem.password = node.id;
|
||||||
if (config.GetShadowsocksSecuritys().Contains(node.security))
|
if (LazyConfig.Instance.GetShadowsocksSecuritys().Contains(node.security))
|
||||||
{
|
{
|
||||||
serversItem.method = node.security;
|
serversItem.method = node.security;
|
||||||
}
|
}
|
||||||
|
|
|
@ -332,11 +332,7 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var coreType = config.GetCoreType(item.configType);
|
var coreType = LazyConfig.Instance.GetCoreType(item, item.configType);
|
||||||
if (item.coreType != null)
|
|
||||||
{
|
|
||||||
coreType = (ECoreType)item.coreType;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (coreType == ECoreType.v2fly)
|
if (coreType == ECoreType.v2fly)
|
||||||
{
|
{
|
||||||
|
|
|
@ -256,16 +256,6 @@ namespace v2rayN.Mode
|
||||||
return vmess.FirstOrDefault(it => it.indexId == id);
|
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)
|
public bool IsActiveNode(VmessItem item)
|
||||||
{
|
{
|
||||||
if (!Utils.IsNullOrEmpty(item.indexId) && item.indexId == indexId)
|
if (!Utils.IsNullOrEmpty(item.indexId) && item.indexId == indexId)
|
||||||
|
@ -285,19 +275,6 @@ namespace v2rayN.Mode
|
||||||
return groupItem.Where(it => it.id == groupId).FirstOrDefault()?.remarks;
|
return groupItem.Where(it => it.id == groupId).FirstOrDefault()?.remarks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ECoreType GetCoreType(EConfigType eConfigType)
|
|
||||||
{
|
|
||||||
if (coreTypeItem == null)
|
|
||||||
{
|
|
||||||
return ECoreType.Xray;
|
|
||||||
}
|
|
||||||
var item = coreTypeItem.FirstOrDefault(it => it.configType == eConfigType);
|
|
||||||
if (item == null)
|
|
||||||
{
|
|
||||||
return ECoreType.Xray;
|
|
||||||
}
|
|
||||||
return item.coreType;
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -358,7 +335,7 @@ namespace v2rayN.Mode
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
summary += string.Format("{0}", remarks);
|
summary += string.Format("{0}", remarks);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return summary;
|
return summary;
|
||||||
}
|
}
|
||||||
|
|
2
v2rayN/v2rayN/Resx/ResUI.Designer.cs
generated
2
v2rayN/v2rayN/Resx/ResUI.Designer.cs
generated
|
@ -115,7 +115,7 @@ namespace v2rayN.Resx {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
internal static string CustomServerTips {
|
internal static string CustomServerTips {
|
||||||
get {
|
get {
|
||||||
|
|
|
@ -130,7 +130,7 @@
|
||||||
<value> configuration format is incorrect</value>
|
<value> configuration format is incorrect</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="CustomServerTips" xml:space="preserve">
|
<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>
|
||||||
<data name="Downloading" xml:space="preserve">
|
<data name="Downloading" xml:space="preserve">
|
||||||
<value>Downloading...</value>
|
<value>Downloading...</value>
|
||||||
|
|
|
@ -130,7 +130,7 @@
|
||||||
<value>配置格式不正确</value>
|
<value>配置格式不正确</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="CustomServerTips" xml:space="preserve">
|
<data name="CustomServerTips" xml:space="preserve">
|
||||||
<value>注意,自定义配置完全依赖您自己的配置,不能使用所有设置功能。在自定义配置inbound中有socks port等于设置中的port时,系统代理才可用</value>
|
<value>注意,自定义配置完全依赖您自己的配置,不能使用所有设置功能。如需使用系统代理请手工修改监听端口。</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Downloading" xml:space="preserve">
|
<data name="Downloading" xml:space="preserve">
|
||||||
<value>下载开始...</value>
|
<value>下载开始...</value>
|
||||||
|
|
Loading…
Reference in a new issue