using DownKyi.Core.Aria2cNet.Server; namespace DownKyi.Core.Settings { public partial class SettingsManager { // 是否开启解除地区限制 private readonly AllowStatus isLiftingOfRegion = AllowStatus.YES; // 启用https private readonly AllowStatus useSSL = AllowStatus.YES; // 下载器 private readonly Downloader downloader = Downloader.ARIA; // 最大同时下载数(任务数) private readonly int maxCurrentDownloads = 3; // 单文件最大线程数 private readonly int split = 8; // HttpProxy代理 private readonly AllowStatus isHttpProxy = AllowStatus.NO; private readonly string httpProxy = ""; private readonly int httpProxyListenPort = 0; // Aria服务器token private readonly string ariaToken = "downkyi"; // Aria服务器host private readonly string ariaHost = "http://localhost"; // Aria服务器端口号 private readonly int ariaListenPort = 6800; // Aria日志等级 private readonly AriaConfigLogLevel ariaLogLevel = AriaConfigLogLevel.INFO; // Aria单文件最大线程数 private readonly int ariaSplit = 5; // Aria下载速度限制 private readonly int ariaMaxOverallDownloadLimit = 0; // Aria下载单文件速度限制 private readonly int ariaMaxDownloadLimit = 0; // Aria文件预分配 private readonly AriaConfigFileAllocation ariaFileAllocation = AriaConfigFileAllocation.NONE; // Aria HttpProxy代理 private readonly AllowStatus isAriaHttpProxy = AllowStatus.NO; private readonly string ariaHttpProxy = ""; private readonly int ariaHttpProxyListenPort = 0; /// /// 获取是否解除地区限制 /// /// public AllowStatus IsLiftingOfRegion() { appSettings = GetSettings(); if (appSettings.Network.IsLiftingOfRegion == AllowStatus.NONE) { // 第一次获取,先设置默认值 IsLiftingOfRegion(isLiftingOfRegion); return isLiftingOfRegion; } return appSettings.Network.IsLiftingOfRegion; } /// /// 设置是否解除地区限制 /// /// /// public bool IsLiftingOfRegion(AllowStatus isLiftingOfRegion) { appSettings.Network.IsLiftingOfRegion = isLiftingOfRegion; return SetSettings(); } /// /// 获取是否启用https /// /// public AllowStatus UseSSL() { appSettings = GetSettings(); if (appSettings.Network.UseSSL == AllowStatus.NONE) { // 第一次获取,先设置默认值 UseSSL(useSSL); return useSSL; } return appSettings.Network.UseSSL; } /// /// 设置是否启用https /// /// /// public bool UseSSL(AllowStatus useSSL) { appSettings.Network.UseSSL = useSSL; return SetSettings(); } /// /// 获取下载器 /// /// public Downloader GetDownloader() { appSettings = GetSettings(); if (appSettings.Network.Downloader == Downloader.NOT_SET) { // 第一次获取,先设置默认值 SetDownloader(downloader); return downloader; } return appSettings.Network.Downloader; } /// /// 设置下载器 /// /// /// public bool SetDownloader(Downloader downloader) { appSettings.Network.Downloader = downloader; return SetSettings(); } /// /// 获取最大同时下载数(任务数) /// /// public int GetMaxCurrentDownloads() { appSettings = GetSettings(); if (appSettings.Network.MaxCurrentDownloads == -1) { // 第一次获取,先设置默认值 SetMaxCurrentDownloads(maxCurrentDownloads); return maxCurrentDownloads; } return appSettings.Network.MaxCurrentDownloads; } /// /// 设置最大同时下载数(任务数) /// /// /// public bool SetMaxCurrentDownloads(int maxCurrentDownloads) { appSettings.Network.MaxCurrentDownloads = maxCurrentDownloads; return SetSettings(); } /// /// 获取单文件最大线程数 /// /// public int GetSplit() { appSettings = GetSettings(); if (appSettings.Network.Split == -1) { // 第一次获取,先设置默认值 SetSplit(split); return split; } return appSettings.Network.Split; } /// /// 设置单文件最大线程数 /// /// /// public bool SetSplit(int split) { appSettings.Network.Split = split; return SetSettings(); } /// /// 获取是否开启Http代理 /// /// public AllowStatus IsHttpProxy() { appSettings = GetSettings(); if (appSettings.Network.IsHttpProxy == AllowStatus.NONE) { // 第一次获取,先设置默认值 IsHttpProxy(isHttpProxy); return isHttpProxy; } return appSettings.Network.IsHttpProxy; } /// /// 设置是否开启Http代理 /// /// /// public bool IsHttpProxy(AllowStatus isHttpProxy) { appSettings.Network.IsHttpProxy = isHttpProxy; return SetSettings(); } /// /// 获取Http代理的地址 /// /// public string GetHttpProxy() { appSettings = GetSettings(); if (appSettings.Network.HttpProxy == null) { // 第一次获取,先设置默认值 SetHttpProxy(httpProxy); return httpProxy; } return appSettings.Network.HttpProxy; } /// /// 设置Aria的http代理的地址 /// /// /// public bool SetHttpProxy(string httpProxy) { appSettings.Network.HttpProxy = httpProxy; return SetSettings(); } /// /// 获取Http代理的端口 /// /// public int GetHttpProxyListenPort() { appSettings = GetSettings(); if (appSettings.Network.HttpProxyListenPort == -1) { // 第一次获取,先设置默认值 SetHttpProxyListenPort(httpProxyListenPort); return httpProxyListenPort; } return appSettings.Network.HttpProxyListenPort; } /// /// 设置Http代理的端口 /// /// /// public bool SetHttpProxyListenPort(int httpProxyListenPort) { appSettings.Network.HttpProxyListenPort = httpProxyListenPort; return SetSettings(); } /// /// 获取Aria服务器的token /// /// public string GetAriaToken() { appSettings = GetSettings(); if (appSettings.Network.AriaToken == null) { // 第一次获取,先设置默认值 SetHttpProxy(ariaToken); return ariaToken; } return appSettings.Network.AriaToken; } /// /// 设置Aria服务器的token /// /// /// public bool SetAriaToken(string token) { appSettings.Network.AriaToken = token; return SetSettings(); } /// /// 获取Aria服务器的host /// /// public string GetAriaHost() { appSettings = GetSettings(); if (appSettings.Network.AriaHost == null) { // 第一次获取,先设置默认值 SetHttpProxy(ariaHost); return ariaHost; } return appSettings.Network.AriaHost; } /// /// 设置Aria服务器的host /// /// /// public bool SetAriaHost(string host) { appSettings.Network.AriaHost = host; return SetSettings(); } /// /// 获取Aria服务器的端口号 /// /// public int GetAriaListenPort() { appSettings = GetSettings(); if (appSettings.Network.AriaListenPort == -1) { // 第一次获取,先设置默认值 SetAriaListenPort(ariaListenPort); return ariaListenPort; } return appSettings.Network.AriaListenPort; } /// /// 设置Aria服务器的端口号 /// /// /// public bool SetAriaListenPort(int ariaListenPort) { appSettings.Network.AriaListenPort = ariaListenPort; return SetSettings(); } /// /// 获取Aria日志等级 /// /// public AriaConfigLogLevel GetAriaLogLevel() { appSettings = GetSettings(); if (appSettings.Network.AriaLogLevel == AriaConfigLogLevel.NOT_SET) { // 第一次获取,先设置默认值 SetAriaLogLevel(ariaLogLevel); return ariaLogLevel; } return appSettings.Network.AriaLogLevel; } /// /// 设置Aria日志等级 /// /// /// public bool SetAriaLogLevel(AriaConfigLogLevel ariaLogLevel) { appSettings.Network.AriaLogLevel = ariaLogLevel; return SetSettings(); } /// /// 获取Aria单文件最大线程数 /// /// public int GetAriaSplit() { appSettings = GetSettings(); if (appSettings.Network.AriaSplit == -1) { // 第一次获取,先设置默认值 SetAriaSplit(ariaSplit); return ariaSplit; } return appSettings.Network.AriaSplit; } /// /// 设置Aria单文件最大线程数 /// /// /// public bool SetAriaSplit(int ariaSplit) { appSettings.Network.AriaSplit = ariaSplit; return SetSettings(); } /// /// 获取Aria下载速度限制 /// /// public int GetAriaMaxOverallDownloadLimit() { appSettings = GetSettings(); if (appSettings.Network.AriaMaxOverallDownloadLimit == -1) { // 第一次获取,先设置默认值 SetAriaMaxOverallDownloadLimit(ariaMaxOverallDownloadLimit); return ariaMaxOverallDownloadLimit; } return appSettings.Network.AriaMaxOverallDownloadLimit; } /// /// 设置Aria下载速度限制 /// /// /// public bool SetAriaMaxOverallDownloadLimit(int ariaMaxOverallDownloadLimit) { appSettings.Network.AriaMaxOverallDownloadLimit = ariaMaxOverallDownloadLimit; return SetSettings(); } /// /// 获取Aria下载单文件速度限制 /// /// public int GetAriaMaxDownloadLimit() { appSettings = GetSettings(); if (appSettings.Network.AriaMaxDownloadLimit == -1) { // 第一次获取,先设置默认值 SetAriaMaxDownloadLimit(ariaMaxDownloadLimit); return ariaMaxDownloadLimit; } return appSettings.Network.AriaMaxDownloadLimit; } /// /// 设置Aria下载单文件速度限制 /// /// /// public bool SetAriaMaxDownloadLimit(int ariaMaxDownloadLimit) { appSettings.Network.AriaMaxDownloadLimit = ariaMaxDownloadLimit; return SetSettings(); } /// /// 获取Aria文件预分配 /// /// public AriaConfigFileAllocation GetAriaFileAllocation() { appSettings = GetSettings(); if (appSettings.Network.AriaFileAllocation == AriaConfigFileAllocation.NOT_SET) { // 第一次获取,先设置默认值 SetAriaFileAllocation(ariaFileAllocation); return ariaFileAllocation; } return appSettings.Network.AriaFileAllocation; } /// /// 设置Aria文件预分配 /// /// /// public bool SetAriaFileAllocation(AriaConfigFileAllocation ariaFileAllocation) { appSettings.Network.AriaFileAllocation = ariaFileAllocation; return SetSettings(); } /// /// 获取是否开启Aria http代理 /// /// public AllowStatus IsAriaHttpProxy() { appSettings = GetSettings(); if (appSettings.Network.IsAriaHttpProxy == AllowStatus.NONE) { // 第一次获取,先设置默认值 IsAriaHttpProxy(isAriaHttpProxy); return isAriaHttpProxy; } return appSettings.Network.IsAriaHttpProxy; } /// /// 设置是否开启Aria http代理 /// /// /// public bool IsAriaHttpProxy(AllowStatus isAriaHttpProxy) { appSettings.Network.IsAriaHttpProxy = isAriaHttpProxy; return SetSettings(); } /// /// 获取Aria的http代理的地址 /// /// public string GetAriaHttpProxy() { appSettings = GetSettings(); if (appSettings.Network.AriaHttpProxy == null) { // 第一次获取,先设置默认值 SetAriaHttpProxy(ariaHttpProxy); return ariaHttpProxy; } return appSettings.Network.AriaHttpProxy; } /// /// 设置Aria的http代理的地址 /// /// /// public bool SetAriaHttpProxy(string ariaHttpProxy) { appSettings.Network.AriaHttpProxy = ariaHttpProxy; return SetSettings(); } /// /// 获取Aria的http代理的端口 /// /// public int GetAriaHttpProxyListenPort() { appSettings = GetSettings(); if (appSettings.Network.AriaHttpProxyListenPort == -1) { // 第一次获取,先设置默认值 SetAriaHttpProxyListenPort(ariaHttpProxyListenPort); return ariaHttpProxyListenPort; } return appSettings.Network.AriaHttpProxyListenPort; } /// /// 设置Aria的http代理的端口 /// /// /// public bool SetAriaHttpProxyListenPort(int ariaHttpProxyListenPort) { appSettings.Network.AriaHttpProxyListenPort = ariaHttpProxyListenPort; return SetSettings(); } } }