mirror of https://github.com/2dust/v2rayN
Refactor gui settings
parent
1ff1962425
commit
9b8181b72b
|
@ -44,9 +44,6 @@ namespace v2rayN.Handler
|
|||
{
|
||||
config = new Config
|
||||
{
|
||||
enableStatistics = false,
|
||||
|
||||
statisticsFreshRate = 1,
|
||||
|
||||
enableRoutingAdvanced = true
|
||||
};
|
||||
|
@ -134,6 +131,14 @@ namespace v2rayN.Handler
|
|||
mtu = 9000,
|
||||
};
|
||||
}
|
||||
if (config.guiItem == null)
|
||||
{
|
||||
config.guiItem = new()
|
||||
{
|
||||
enableStatistics = false,
|
||||
statisticsFreshRate = 1,
|
||||
};
|
||||
}
|
||||
if (config.uiItem == null)
|
||||
{
|
||||
config.uiItem = new UIItem()
|
||||
|
@ -180,9 +185,9 @@ namespace v2rayN.Handler
|
|||
config.speedTestItem.speedPingTestUrl = Global.SpeedPingTestUrl;
|
||||
}
|
||||
|
||||
if (config.statisticsFreshRate > 100 || config.statisticsFreshRate < 1)
|
||||
if (config.guiItem.statisticsFreshRate > 100 || config.guiItem.statisticsFreshRate < 1)
|
||||
{
|
||||
config.statisticsFreshRate = 1;
|
||||
config.guiItem.statisticsFreshRate = 1;
|
||||
}
|
||||
|
||||
if (config == null)
|
||||
|
@ -758,7 +763,7 @@ namespace v2rayN.Handler
|
|||
public static int DedupServerList(ref Config config, ref List<ProfileItem> lstProfile)
|
||||
{
|
||||
List<ProfileItem> source = lstProfile;
|
||||
bool keepOlder = config.keepOlderDedupl;
|
||||
bool keepOlder = config.guiItem.keepOlderDedupl;
|
||||
|
||||
List<ProfileItem> list = new List<ProfileItem>();
|
||||
if (!keepOlder) source.Reverse(); // Remove the early items first
|
||||
|
|
|
@ -825,7 +825,7 @@ namespace v2rayN.Handler
|
|||
|
||||
private static int statistic(Config config, ref V2rayConfig v2rayConfig)
|
||||
{
|
||||
if (config.enableStatistics)
|
||||
if (config.guiItem.enableStatistics)
|
||||
{
|
||||
string tag = Global.InboundAPITagName;
|
||||
API apiObj = new API();
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace v2rayN.Handler
|
|||
{
|
||||
try
|
||||
{
|
||||
Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().enableSecurityProtocolTls13);
|
||||
Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().guiItem.enableSecurityProtocolTls13);
|
||||
|
||||
var progress = new Progress<string>();
|
||||
progress.ProgressChanged += (sender, value) =>
|
||||
|
@ -67,7 +67,7 @@ namespace v2rayN.Handler
|
|||
{
|
||||
try
|
||||
{
|
||||
Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().enableSecurityProtocolTls13);
|
||||
Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().guiItem.enableSecurityProtocolTls13);
|
||||
UpdateCompleted?.Invoke(this, new ResultEventArgs(false, ResUI.Downloading));
|
||||
|
||||
var progress = new Progress<double>();
|
||||
|
@ -101,7 +101,7 @@ namespace v2rayN.Handler
|
|||
|
||||
public async Task<string> UrlRedirectAsync(string url, bool blProxy)
|
||||
{
|
||||
Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().enableSecurityProtocolTls13);
|
||||
Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().guiItem.enableSecurityProtocolTls13);
|
||||
var webRequestHandler = new SocketsHttpHandler
|
||||
{
|
||||
AllowAutoRedirect = false,
|
||||
|
@ -129,7 +129,7 @@ namespace v2rayN.Handler
|
|||
{
|
||||
try
|
||||
{
|
||||
Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().enableSecurityProtocolTls13);
|
||||
Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().guiItem.enableSecurityProtocolTls13);
|
||||
|
||||
var webProxy = GetWebProxy(blProxy);
|
||||
var result = await DownloaderHelper.Instance.DownloadStringAsync(webProxy, url, userAgent, 30);
|
||||
|
@ -155,7 +155,7 @@ namespace v2rayN.Handler
|
|||
{
|
||||
try
|
||||
{
|
||||
Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().enableSecurityProtocolTls13);
|
||||
Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().guiItem.enableSecurityProtocolTls13);
|
||||
var client = new HttpClient(new SocketsHttpHandler()
|
||||
{
|
||||
Proxy = GetWebProxy(blProxy)
|
||||
|
|
|
@ -309,9 +309,9 @@ namespace v2rayN.Handler
|
|||
{
|
||||
var dtNow = DateTime.Now;
|
||||
|
||||
if (config.autoUpdateSubInterval > 0)
|
||||
if (config.guiItem.autoUpdateSubInterval > 0)
|
||||
{
|
||||
if ((dtNow - autoUpdateSubTime).Hours % config.autoUpdateSubInterval == 0)
|
||||
if ((dtNow - autoUpdateSubTime).Hours % config.guiItem.autoUpdateSubInterval == 0)
|
||||
{
|
||||
updateHandle.UpdateSubscriptionProcess(config, "", true, (bool success, string msg) =>
|
||||
{
|
||||
|
@ -324,9 +324,9 @@ namespace v2rayN.Handler
|
|||
Thread.Sleep(60000);
|
||||
}
|
||||
|
||||
if (config.autoUpdateInterval > 0)
|
||||
if (config.guiItem.autoUpdateInterval > 0)
|
||||
{
|
||||
if ((dtNow - autoUpdateGeoTime).Hours % config.autoUpdateInterval == 0)
|
||||
if ((dtNow - autoUpdateGeoTime).Hours % config.guiItem.autoUpdateInterval == 0)
|
||||
{
|
||||
updateHandle.UpdateGeoFile("geosite", config, (bool success, string msg) =>
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace v2rayN.Handler
|
|||
public StatisticsHandler(Mode.Config config, Action<ServerSpeedItem> update)
|
||||
{
|
||||
config_ = config;
|
||||
Enable = config.enableStatistics;
|
||||
Enable = config.guiItem.enableStatistics;
|
||||
updateFunc_ = update;
|
||||
exitFlag_ = false;
|
||||
|
||||
|
@ -103,7 +103,7 @@ namespace v2rayN.Handler
|
|||
}
|
||||
}
|
||||
}
|
||||
var sleep = config_.statisticsFreshRate < 1 ? 1 : config_.statisticsFreshRate;
|
||||
var sleep = config_.guiItem.statisticsFreshRate < 1 ? 1 : config_.guiItem.statisticsFreshRate;
|
||||
Thread.Sleep(1000 * sleep);
|
||||
channel_.ConnectAsync();
|
||||
}
|
||||
|
|
|
@ -8,15 +8,11 @@
|
|||
{
|
||||
#region property
|
||||
|
||||
|
||||
|
||||
public string indexId
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
@ -25,32 +21,6 @@
|
|||
get; set;
|
||||
}
|
||||
|
||||
public bool autoRun { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 启用实时网速和流量统计
|
||||
/// </summary>
|
||||
public bool enableStatistics
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 去重时优先保留较旧(顶部)节点
|
||||
/// </summary>
|
||||
public bool keepOlderDedupl
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 视图刷新率
|
||||
/// </summary>
|
||||
public int statisticsFreshRate
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自定义远程DNS
|
||||
/// </summary>
|
||||
|
@ -67,8 +37,6 @@
|
|||
get; set;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 域名解析策略
|
||||
/// </summary>
|
||||
|
@ -86,8 +54,6 @@
|
|||
get; set;
|
||||
}
|
||||
|
||||
public bool ignoreGeoUpdateCore { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// systemProxyExceptions
|
||||
/// </summary>
|
||||
|
@ -97,19 +63,6 @@
|
|||
}
|
||||
public string systemProxyAdvancedProtocol { get; set; }
|
||||
|
||||
public int autoUpdateInterval { get; set; } = 10;
|
||||
|
||||
public int autoUpdateSubInterval { get; set; } = 10;
|
||||
|
||||
public bool checkPreReleaseUpdate { get; set; } = false;
|
||||
|
||||
public bool enableSecurityProtocolTls13
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public int trayMenuServersLimit { get; set; } = 20;
|
||||
|
||||
#endregion
|
||||
|
||||
#region other entities
|
||||
|
@ -118,6 +71,7 @@
|
|||
public TunModeItem tunModeItem { get; set; }
|
||||
public KcpItem kcpItem { get; set; }
|
||||
public GrpcItem grpcItem { get; set; }
|
||||
public GUIItem guiItem { get; set; }
|
||||
public UIItem uiItem { get; set; }
|
||||
public ConstItem constItem { get; set; }
|
||||
public SpeedTestItem speedTestItem { get; set; }
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace v2rayN.Mode
|
||||
{
|
||||
[Serializable]
|
||||
public class CoreBasicItem
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -32,7 +33,6 @@ namespace v2rayN.Mode
|
|||
public string defUserAgent { get; set; }
|
||||
}
|
||||
|
||||
|
||||
[Serializable]
|
||||
public class InItem
|
||||
{
|
||||
|
@ -82,6 +82,30 @@ namespace v2rayN.Mode
|
|||
public int initial_windows_size { get; set; }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class GUIItem
|
||||
{
|
||||
public bool autoRun { get; set; }
|
||||
|
||||
public bool enableStatistics { get; set; }
|
||||
|
||||
public int statisticsFreshRate { get; set; }
|
||||
|
||||
public bool keepOlderDedupl { get; set; }
|
||||
|
||||
public bool ignoreGeoUpdateCore { get; set; } = true;
|
||||
|
||||
public int autoUpdateInterval { get; set; } = 10;
|
||||
|
||||
public int autoUpdateSubInterval { get; set; } = 10;
|
||||
|
||||
public bool checkPreReleaseUpdate { get; set; } = false;
|
||||
|
||||
public bool enableSecurityProtocolTls13 { get; set; }
|
||||
|
||||
public int trayMenuServersLimit { get; set; } = 20;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class UIItem
|
||||
{
|
||||
|
|
|
@ -506,7 +506,7 @@ namespace v2rayN.ViewModels
|
|||
//MainFormHandler.Instance.BackupGuiNConfig(_config, true);
|
||||
_coreHandler = new CoreHandler(UpdateHandler);
|
||||
|
||||
if (_config.enableStatistics)
|
||||
if (_config.guiItem.enableStatistics)
|
||||
{
|
||||
_statistics = new StatisticsHandler(_config, UpdateStatisticsHandler);
|
||||
}
|
||||
|
@ -773,7 +773,7 @@ namespace v2rayN.ViewModels
|
|||
private void RefreshServersMenu()
|
||||
{
|
||||
_servers.Clear();
|
||||
if (_lstProfile.Count > _config.trayMenuServersLimit)
|
||||
if (_lstProfile.Count > _config.guiItem.trayMenuServersLimit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -1301,7 +1301,7 @@ namespace v2rayN.ViewModels
|
|||
MyAppExit(false);
|
||||
}
|
||||
};
|
||||
(new UpdateHandle()).CheckUpdateGuiN(_config, _updateUI, _config.checkPreReleaseUpdate);
|
||||
(new UpdateHandle()).CheckUpdateGuiN(_config, _updateUI, _config.guiItem.checkPreReleaseUpdate);
|
||||
}
|
||||
|
||||
private void CheckUpdateCore(ECoreType type)
|
||||
|
@ -1316,7 +1316,7 @@ namespace v2rayN.ViewModels
|
|||
string fileName = Utils.GetTempPath(Utils.GetDownloadFileName(msg));
|
||||
string toPath = Utils.GetBinPath("", type);
|
||||
|
||||
FileManager.ZipExtractToFile(fileName, toPath, _config.ignoreGeoUpdateCore ? "geo" : "");
|
||||
FileManager.ZipExtractToFile(fileName, toPath, _config.guiItem.ignoreGeoUpdateCore ? "geo" : "");
|
||||
|
||||
_noticeHandler?.SendMessage(ResUI.MsgUpdateV2rayCoreSuccessfullyMore);
|
||||
|
||||
|
@ -1330,7 +1330,7 @@ namespace v2rayN.ViewModels
|
|||
}
|
||||
}
|
||||
};
|
||||
(new UpdateHandle()).CheckUpdateCore(type, _config, _updateUI, _config.checkPreReleaseUpdate);
|
||||
(new UpdateHandle()).CheckUpdateCore(type, _config, _updateUI, _config.guiItem.checkPreReleaseUpdate);
|
||||
}
|
||||
|
||||
private void CheckUpdateGeo()
|
||||
|
|
|
@ -140,20 +140,20 @@ namespace v2rayN.ViewModels
|
|||
#endregion
|
||||
|
||||
#region UI
|
||||
AutoRun = _config.autoRun;
|
||||
EnableStatistics = _config.enableStatistics;
|
||||
StatisticsFreshRate = _config.statisticsFreshRate;
|
||||
KeepOlderDedupl = _config.keepOlderDedupl;
|
||||
IgnoreGeoUpdateCore = _config.ignoreGeoUpdateCore;
|
||||
AutoRun = _config.guiItem.autoRun;
|
||||
EnableStatistics = _config.guiItem.enableStatistics;
|
||||
StatisticsFreshRate = _config.guiItem.statisticsFreshRate;
|
||||
KeepOlderDedupl = _config.guiItem.keepOlderDedupl;
|
||||
IgnoreGeoUpdateCore = _config.guiItem.ignoreGeoUpdateCore;
|
||||
EnableAutoAdjustMainLvColWidth = _config.uiItem.enableAutoAdjustMainLvColWidth;
|
||||
EnableSecurityProtocolTls13 = _config.enableSecurityProtocolTls13;
|
||||
EnableSecurityProtocolTls13 = _config.guiItem.enableSecurityProtocolTls13;
|
||||
AutoHideStartup = _config.uiItem.autoHideStartup;
|
||||
EnableCheckPreReleaseUpdate = _config.checkPreReleaseUpdate;
|
||||
EnableCheckPreReleaseUpdate = _config.guiItem.checkPreReleaseUpdate;
|
||||
EnableDragDropSort = _config.uiItem.enableDragDropSort;
|
||||
DoubleClick2Activate = _config.uiItem.doubleClick2Activate;
|
||||
autoUpdateInterval = _config.autoUpdateInterval;
|
||||
autoUpdateSubInterval = _config.autoUpdateSubInterval;
|
||||
trayMenuServersLimit = _config.trayMenuServersLimit;
|
||||
autoUpdateInterval = _config.guiItem.autoUpdateInterval;
|
||||
autoUpdateSubInterval = _config.guiItem.autoUpdateSubInterval;
|
||||
trayMenuServersLimit = _config.guiItem.trayMenuServersLimit;
|
||||
currentFontFamily = _config.uiItem.currentFontFamily;
|
||||
SpeedTestTimeout = _config.speedTestItem.speedTestTimeout;
|
||||
SpeedTestUrl = _config.speedTestItem.speedTestUrl;
|
||||
|
@ -312,24 +312,24 @@ namespace v2rayN.ViewModels
|
|||
|
||||
//UI
|
||||
Utils.SetAutoRun(AutoRun);
|
||||
_config.autoRun = AutoRun;
|
||||
_config.enableStatistics = EnableStatistics;
|
||||
_config.statisticsFreshRate = StatisticsFreshRate;
|
||||
if (_config.statisticsFreshRate > 100 || _config.statisticsFreshRate < 1)
|
||||
_config.guiItem.autoRun = AutoRun;
|
||||
_config.guiItem.enableStatistics = EnableStatistics;
|
||||
_config.guiItem.statisticsFreshRate = StatisticsFreshRate;
|
||||
if (_config.guiItem.statisticsFreshRate > 100 || _config.guiItem.statisticsFreshRate < 1)
|
||||
{
|
||||
_config.statisticsFreshRate = 1;
|
||||
_config.guiItem.statisticsFreshRate = 1;
|
||||
}
|
||||
_config.keepOlderDedupl = KeepOlderDedupl;
|
||||
_config.ignoreGeoUpdateCore = IgnoreGeoUpdateCore;
|
||||
_config.guiItem.keepOlderDedupl = KeepOlderDedupl;
|
||||
_config.guiItem.ignoreGeoUpdateCore = IgnoreGeoUpdateCore;
|
||||
_config.uiItem.enableAutoAdjustMainLvColWidth = EnableAutoAdjustMainLvColWidth;
|
||||
_config.enableSecurityProtocolTls13 = EnableSecurityProtocolTls13;
|
||||
_config.guiItem.enableSecurityProtocolTls13 = EnableSecurityProtocolTls13;
|
||||
_config.uiItem.autoHideStartup = AutoHideStartup;
|
||||
_config.autoUpdateInterval = autoUpdateInterval;
|
||||
_config.autoUpdateSubInterval = autoUpdateSubInterval;
|
||||
_config.checkPreReleaseUpdate = EnableCheckPreReleaseUpdate;
|
||||
_config.guiItem.autoUpdateInterval = autoUpdateInterval;
|
||||
_config.guiItem.autoUpdateSubInterval = autoUpdateSubInterval;
|
||||
_config.guiItem.checkPreReleaseUpdate = EnableCheckPreReleaseUpdate;
|
||||
_config.uiItem.enableDragDropSort = EnableDragDropSort;
|
||||
_config.uiItem.doubleClick2Activate = DoubleClick2Activate;
|
||||
_config.trayMenuServersLimit = trayMenuServersLimit;
|
||||
_config.guiItem.trayMenuServersLimit = trayMenuServersLimit;
|
||||
_config.uiItem.currentFontFamily = currentFontFamily;
|
||||
_config.speedTestItem.speedTestTimeout = SpeedTestTimeout;
|
||||
_config.speedTestItem.speedTestUrl = SpeedTestUrl;
|
||||
|
|
|
@ -434,7 +434,7 @@ namespace v2rayN.Views
|
|||
var width = ConfigHandler.GetformMainLvColWidth(ref _config, ((EServerColName)k).ToString(), Convert.ToInt32(lstProfiles.Columns[k].Width.Value));
|
||||
lstProfiles.Columns[k].Width = width;
|
||||
}
|
||||
if (!_config.enableStatistics)
|
||||
if (!_config.guiItem.enableStatistics)
|
||||
{
|
||||
colTodayUp.Visibility = Visibility.Hidden;
|
||||
colTodayDown.Visibility = Visibility.Hidden;
|
||||
|
|
Loading…
Reference in New Issue