diff --git a/v2rayN/v2rayN/Handler/ConfigHandler.cs b/v2rayN/v2rayN/Handler/ConfigHandler.cs
index 23628aa3..1367ebcd 100644
--- a/v2rayN/v2rayN/Handler/ConfigHandler.cs
+++ b/v2rayN/v2rayN/Handler/ConfigHandler.cs
@@ -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))
{
diff --git a/v2rayN/v2rayN/Handler/CoreConfigHandler.cs b/v2rayN/v2rayN/Handler/CoreConfigHandler.cs
index bbce66ee..c1d7e05c 100644
--- a/v2rayN/v2rayN/Handler/CoreConfigHandler.cs
+++ b/v2rayN/v2rayN/Handler/CoreConfigHandler.cs
@@ -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))
{
diff --git a/v2rayN/v2rayN/Mode/Config.cs b/v2rayN/v2rayN/Mode/Config.cs
index 85e92a2c..2ba09b71 100644
--- a/v2rayN/v2rayN/Mode/Config.cs
+++ b/v2rayN/v2rayN/Mode/Config.cs
@@ -8,34 +8,14 @@
{
#region property
- ///
- /// 允许日志
- ///
- public bool logEnabled
- {
- get; set;
- }
-
- ///
- /// 日志等级
- ///
- public string loglevel
- {
- get; set;
- }
+
public string indexId
{
get; set;
}
- ///
- /// 允许Mux多路复用
- ///
- public bool muxEnabled
- {
- get; set;
- }
+
///
///
@@ -87,17 +67,7 @@
get; set;
}
- ///
- /// 是否允许不安全连接
- ///
- public bool defAllowInsecure { get; set; }
-
- public string defFingerprint { get; set; }
-
- ///
- /// 默认用户代理
- ///
- public string defUserAgent { get; set; }
+
///
/// 域名解析策略
@@ -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; }
diff --git a/v2rayN/v2rayN/Mode/ConfigItems.cs b/v2rayN/v2rayN/Mode/ConfigItems.cs
index f652aad0..95444036 100644
--- a/v2rayN/v2rayN/Mode/ConfigItems.cs
+++ b/v2rayN/v2rayN/Mode/ConfigItems.cs
@@ -2,6 +2,37 @@
namespace v2rayN.Mode
{
+ public class CoreBasicItem
+ {
+ ///
+ /// 允许日志
+ ///
+ public bool logEnabled { get; set; }
+
+ ///
+ /// 日志等级
+ ///
+ public string loglevel { get; set; }
+
+ ///
+ /// 允许Mux多路复用
+ ///
+ public bool muxEnabled { get; set; }
+
+ ///
+ /// 是否允许不安全连接
+ ///
+ public bool defAllowInsecure { get; set; }
+
+ public string defFingerprint { get; set; }
+
+ ///
+ /// 默认用户代理
+ ///
+ public string defUserAgent { get; set; }
+ }
+
+
[Serializable]
public class InItem
{
diff --git a/v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs b/v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs
index 461caa0b..ba387c37 100644
--- a/v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs
+++ b/v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs
@@ -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