mirror of https://github.com/2dust/v2rayN
Refactor basic settings
parent
9b05736746
commit
1ff1962425
|
@ -44,12 +44,6 @@ namespace v2rayN.Handler
|
|||
{
|
||||
config = new Config
|
||||
{
|
||||
logEnabled = false,
|
||||
loglevel = "warning",
|
||||
|
||||
//Mux
|
||||
muxEnabled = false,
|
||||
|
||||
enableStatistics = false,
|
||||
|
||||
statisticsFreshRate = 1,
|
||||
|
@ -57,6 +51,16 @@ namespace v2rayN.Handler
|
|||
enableRoutingAdvanced = true
|
||||
};
|
||||
}
|
||||
if (config.coreBasicItem == null)
|
||||
{
|
||||
config.coreBasicItem = new()
|
||||
{
|
||||
logEnabled = false,
|
||||
loglevel = "warning",
|
||||
|
||||
muxEnabled = false,
|
||||
};
|
||||
}
|
||||
|
||||
//本地监听
|
||||
if (config.inbound == null)
|
||||
|
@ -647,7 +651,7 @@ namespace v2rayN.Handler
|
|||
}
|
||||
if (Utils.IsNullOrEmpty(profileItem.allowInsecure))
|
||||
{
|
||||
profileItem.allowInsecure = config.defAllowInsecure.ToString().ToLower();
|
||||
profileItem.allowInsecure = config.coreBasicItem.defAllowInsecure.ToString().ToLower();
|
||||
}
|
||||
|
||||
AddServerCommon(ref config, profileItem);
|
||||
|
@ -781,7 +785,7 @@ namespace v2rayN.Handler
|
|||
profileItem.configVersion = 2;
|
||||
if (Utils.IsNullOrEmpty(profileItem.allowInsecure))
|
||||
{
|
||||
profileItem.allowInsecure = config.defAllowInsecure.ToString().ToLower();
|
||||
profileItem.allowInsecure = config.coreBasicItem.defAllowInsecure.ToString().ToLower();
|
||||
}
|
||||
if (!Utils.IsNullOrEmpty(profileItem.network) && !Global.networks.Contains(profileItem.network))
|
||||
{
|
||||
|
|
|
@ -73,29 +73,29 @@ namespace v2rayN.Handler
|
|||
{
|
||||
if (blExport)
|
||||
{
|
||||
if (config.logEnabled)
|
||||
if (config.coreBasicItem.logEnabled)
|
||||
{
|
||||
v2rayConfig.log.loglevel = config.loglevel;
|
||||
v2rayConfig.log.loglevel = config.coreBasicItem.loglevel;
|
||||
}
|
||||
else
|
||||
{
|
||||
v2rayConfig.log.loglevel = config.loglevel;
|
||||
v2rayConfig.log.loglevel = config.coreBasicItem.loglevel;
|
||||
v2rayConfig.log.access = "";
|
||||
v2rayConfig.log.error = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (config.logEnabled)
|
||||
if (config.coreBasicItem.logEnabled)
|
||||
{
|
||||
var dtNow = DateTime.Now;
|
||||
v2rayConfig.log.loglevel = config.loglevel;
|
||||
v2rayConfig.log.loglevel = config.coreBasicItem.loglevel;
|
||||
v2rayConfig.log.access = Utils.GetLogPath($"Vaccess_{dtNow.ToString("yyyy-MM-dd")}.txt");
|
||||
v2rayConfig.log.error = Utils.GetLogPath($"Verror_{dtNow.ToString("yyyy-MM-dd")}.txt");
|
||||
}
|
||||
else
|
||||
{
|
||||
v2rayConfig.log.loglevel = config.loglevel;
|
||||
v2rayConfig.log.loglevel = config.coreBasicItem.loglevel;
|
||||
v2rayConfig.log.access = "";
|
||||
v2rayConfig.log.error = "";
|
||||
}
|
||||
|
@ -348,8 +348,8 @@ namespace v2rayN.Handler
|
|||
}
|
||||
|
||||
//Mux
|
||||
outbound.mux.enabled = config.muxEnabled;
|
||||
outbound.mux.concurrency = config.muxEnabled ? 8 : -1;
|
||||
outbound.mux.enabled = config.coreBasicItem.muxEnabled;
|
||||
outbound.mux.concurrency = config.coreBasicItem.muxEnabled ? 8 : -1;
|
||||
|
||||
boundStreamSettings(node, "out", outbound.streamSettings);
|
||||
|
||||
|
@ -452,8 +452,8 @@ namespace v2rayN.Handler
|
|||
usersItem.encryption = node.security;
|
||||
|
||||
//Mux
|
||||
outbound.mux.enabled = config.muxEnabled;
|
||||
outbound.mux.concurrency = config.muxEnabled ? 8 : -1;
|
||||
outbound.mux.enabled = config.coreBasicItem.muxEnabled;
|
||||
outbound.mux.concurrency = config.coreBasicItem.muxEnabled ? 8 : -1;
|
||||
|
||||
boundStreamSettings(node, "out", outbound.streamSettings);
|
||||
|
||||
|
@ -548,15 +548,15 @@ namespace v2rayN.Handler
|
|||
string host = node.requestHost.TrimEx();
|
||||
string sni = node.sni;
|
||||
string useragent = "";
|
||||
if (!config.defUserAgent.IsNullOrEmpty())
|
||||
if (!config.coreBasicItem.defUserAgent.IsNullOrEmpty())
|
||||
{
|
||||
try
|
||||
{
|
||||
useragent = Global.userAgentTxt[config.defUserAgent];
|
||||
useragent = Global.userAgentTxt[config.coreBasicItem.defUserAgent];
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
useragent = config.defUserAgent;
|
||||
useragent = config.coreBasicItem.defUserAgent;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -567,9 +567,9 @@ namespace v2rayN.Handler
|
|||
|
||||
TlsSettings tlsSettings = new TlsSettings
|
||||
{
|
||||
allowInsecure = Utils.ToBool(node.allowInsecure.IsNullOrEmpty() ? config.defAllowInsecure.ToString().ToLower() : node.allowInsecure),
|
||||
allowInsecure = Utils.ToBool(node.allowInsecure.IsNullOrEmpty() ? config.coreBasicItem.defAllowInsecure.ToString().ToLower() : node.allowInsecure),
|
||||
alpn = node.GetAlpn(),
|
||||
fingerprint = node.fingerprint.IsNullOrEmpty() ? config.defFingerprint : node.fingerprint
|
||||
fingerprint = node.fingerprint.IsNullOrEmpty() ? config.coreBasicItem.defFingerprint : node.fingerprint
|
||||
};
|
||||
if (!string.IsNullOrWhiteSpace(sni))
|
||||
{
|
||||
|
@ -589,9 +589,9 @@ namespace v2rayN.Handler
|
|||
|
||||
TlsSettings xtlsSettings = new TlsSettings
|
||||
{
|
||||
allowInsecure = Utils.ToBool(node.allowInsecure.IsNullOrEmpty() ? config.defAllowInsecure.ToString().ToLower() : node.allowInsecure),
|
||||
allowInsecure = Utils.ToBool(node.allowInsecure.IsNullOrEmpty() ? config.coreBasicItem.defAllowInsecure.ToString().ToLower() : node.allowInsecure),
|
||||
alpn = node.GetAlpn(),
|
||||
fingerprint = node.fingerprint.IsNullOrEmpty() ? config.defFingerprint : node.fingerprint
|
||||
fingerprint = node.fingerprint.IsNullOrEmpty() ? config.coreBasicItem.defFingerprint : node.fingerprint
|
||||
};
|
||||
if (!string.IsNullOrWhiteSpace(sni))
|
||||
{
|
||||
|
|
|
@ -8,34 +8,14 @@
|
|||
{
|
||||
#region property
|
||||
|
||||
/// <summary>
|
||||
/// 允许日志
|
||||
/// </summary>
|
||||
public bool logEnabled
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 日志等级
|
||||
/// </summary>
|
||||
public string loglevel
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public string indexId
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 允许Mux多路复用
|
||||
/// </summary>
|
||||
public bool muxEnabled
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
|
@ -87,17 +67,7 @@
|
|||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否允许不安全连接
|
||||
/// </summary>
|
||||
public bool defAllowInsecure { get; set; }
|
||||
|
||||
public string defFingerprint { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 默认用户代理
|
||||
/// </summary>
|
||||
public string defUserAgent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 域名解析策略
|
||||
|
@ -144,6 +114,7 @@
|
|||
|
||||
#region other entities
|
||||
|
||||
public CoreBasicItem coreBasicItem { get; set; }
|
||||
public TunModeItem tunModeItem { get; set; }
|
||||
public KcpItem kcpItem { get; set; }
|
||||
public GrpcItem grpcItem { get; set; }
|
||||
|
|
|
@ -2,6 +2,37 @@
|
|||
|
||||
namespace v2rayN.Mode
|
||||
{
|
||||
public class CoreBasicItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 允许日志
|
||||
/// </summary>
|
||||
public bool logEnabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 日志等级
|
||||
/// </summary>
|
||||
public string loglevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 允许Mux多路复用
|
||||
/// </summary>
|
||||
public bool muxEnabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否允许不安全连接
|
||||
/// </summary>
|
||||
public bool defAllowInsecure { get; set; }
|
||||
|
||||
public string defFingerprint { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 默认用户代理
|
||||
/// </summary>
|
||||
public string defUserAgent { get; set; }
|
||||
}
|
||||
|
||||
|
||||
[Serializable]
|
||||
public class InItem
|
||||
{
|
||||
|
|
|
@ -116,12 +116,12 @@ namespace v2rayN.ViewModels
|
|||
newPort4LAN = inbound.newPort4LAN;
|
||||
user = inbound.user;
|
||||
pass = inbound.pass;
|
||||
muxEnabled = _config.muxEnabled;
|
||||
logEnabled = _config.logEnabled;
|
||||
loglevel = _config.loglevel;
|
||||
defAllowInsecure = _config.defAllowInsecure;
|
||||
defFingerprint = _config.defFingerprint;
|
||||
defUserAgent = _config.defUserAgent;
|
||||
muxEnabled = _config.coreBasicItem.muxEnabled;
|
||||
logEnabled = _config.coreBasicItem.logEnabled;
|
||||
loglevel = _config.coreBasicItem.loglevel;
|
||||
defAllowInsecure = _config.coreBasicItem.defAllowInsecure;
|
||||
defFingerprint = _config.coreBasicItem.defFingerprint;
|
||||
defUserAgent = _config.coreBasicItem.defUserAgent;
|
||||
#endregion
|
||||
|
||||
#region Core DNS
|
||||
|
@ -287,12 +287,12 @@ namespace v2rayN.ViewModels
|
|||
{
|
||||
_config.inbound.RemoveAt(1);
|
||||
}
|
||||
_config.logEnabled = logEnabled;
|
||||
_config.loglevel = loglevel;
|
||||
_config.muxEnabled = muxEnabled;
|
||||
_config.defAllowInsecure = defAllowInsecure;
|
||||
_config.defFingerprint = defFingerprint;
|
||||
_config.defUserAgent = defUserAgent;
|
||||
_config.coreBasicItem.logEnabled = logEnabled;
|
||||
_config.coreBasicItem.loglevel = loglevel;
|
||||
_config.coreBasicItem.muxEnabled = muxEnabled;
|
||||
_config.coreBasicItem.defAllowInsecure = defAllowInsecure;
|
||||
_config.coreBasicItem.defFingerprint = defFingerprint;
|
||||
_config.coreBasicItem.defUserAgent = defUserAgent;
|
||||
|
||||
|
||||
//DNS
|
||||
|
|
Loading…
Reference in New Issue