Refactor code

pull/5210/head
2dust 2024-06-03 17:50:18 +08:00
parent d0c6ea6a63
commit 31748aa660
43 changed files with 54 additions and 464 deletions

View File

@ -1,4 +1,4 @@
namespace v2rayN.Models
namespace v2rayN.Enums
{
public enum EConfigType
{

View File

@ -1,4 +1,4 @@
namespace v2rayN.Models
namespace v2rayN.Enums
{
public enum ECoreType
{

View File

@ -1,4 +1,4 @@
namespace v2rayN.Models
namespace v2rayN.Enums
{
public enum EGlobalHotkey
{

View File

@ -1,4 +1,4 @@
namespace v2rayN.Models
namespace v2rayN.Enums
{
public enum EInboundProtocol
{

View File

@ -1,4 +1,4 @@
namespace v2rayN.Models
namespace v2rayN.Enums
{
public enum EMove
{

View File

@ -1,4 +1,4 @@
namespace v2rayN.Models
namespace v2rayN.Enums
{
public enum EServerColName
{

View File

@ -1,4 +1,4 @@
namespace v2rayN.Models
namespace v2rayN.Enums
{
public enum ESpeedActionType
{

View File

@ -1,4 +1,4 @@
namespace v2rayN.Models
namespace v2rayN.Enums
{
public enum ESysProxyType
{

View File

@ -1,4 +1,4 @@
namespace v2rayN.Models
namespace v2rayN.Enums
{
public enum ETransport
{

View File

@ -1,4 +1,4 @@
namespace v2rayN.Models
namespace v2rayN.Enums
{
public enum EViewAction
{

View File

@ -1,4 +1,4 @@
using v2rayN.Models;
using v2rayN.Enums;
namespace v2rayN
{

View File

@ -1,6 +1,7 @@
using System.Data;
using System.IO;
using System.Text.RegularExpressions;
using v2rayN.Enums;
using v2rayN.Models;
namespace v2rayN.Handler

View File

@ -1,4 +1,5 @@
using System.IO;
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;

View File

@ -1,5 +1,6 @@
using System.Net;
using System.Net.NetworkInformation;
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;

View File

@ -1,5 +1,6 @@
using System.Net;
using System.Net.NetworkInformation;
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;

View File

@ -2,6 +2,7 @@
using System.IO;
using System.Reactive.Linq;
using System.Text;
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;

View File

@ -4,7 +4,7 @@ using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Sockets;
using v2rayN.Models;
using v2rayN.Enums;
using v2rayN.Resx;
namespace v2rayN.Handler

View File

@ -4,6 +4,7 @@ using System.Text;
using System.Windows;
using System.Windows.Input;
using System.Windows.Interop;
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;

View File

@ -1,4 +1,5 @@
using System.Runtime.Intrinsics.X86;
using v2rayN.Enums;
using v2rayN.Models;
namespace v2rayN.Handler

View File

@ -3,6 +3,7 @@ using Splat;
using System.Drawing;
using System.IO;
using System.Windows.Media.Imaging;
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;

View File

@ -1,5 +1,6 @@
using System.Collections.Specialized;
using System.Text.RegularExpressions;
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;

View File

@ -2,6 +2,7 @@
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;

View File

@ -1,5 +1,6 @@
using System.Net.WebSockets;
using System.Text;
using v2rayN.Enums;
using v2rayN.Models;
namespace v2rayN.Handler

View File

@ -1,6 +1,7 @@
using Grpc.Core;
using Grpc.Net.Client;
using ProtosLib.Statistics;
using v2rayN.Enums;
using v2rayN.Models;
namespace v2rayN.Handler

View File

@ -1,4 +1,5 @@
using PacLib;
using v2rayN.Enums;
using v2rayN.Models;
namespace v2rayN.Handler

View File

@ -6,6 +6,7 @@ using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows;
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;
@ -299,9 +300,6 @@ namespace v2rayN.Handler
{
await UpdateGeoFile("geosite", _config, update);
await UpdateGeoFile("geoip", _config, update);
//await UpdateGeoFile4Singbox("geosite", _config, false, update);
//await UpdateGeoFile4Singbox("geoip", _config, true, update);
});
}
@ -327,7 +325,7 @@ namespace v2rayN.Handler
var result = await (new DownloadHandle()).DownloadStringAsync(url, true, "");
if (!Utils.IsNullOrEmpty(result))
{
responseHandler(type, result, preRelease);
ResponseHandler(type, result, preRelease);
}
else
{
@ -345,7 +343,7 @@ namespace v2rayN.Handler
/// <summary>
/// 获取V2RayCore版本
/// </summary>
private SemanticVersion getCoreVersion(ECoreType type)
private SemanticVersion GetCoreVersion(ECoreType type)
{
try
{
@ -410,7 +408,7 @@ namespace v2rayN.Handler
}
}
private void responseHandler(ECoreType type, string gitHubReleaseApi, bool preRelease)
private void ResponseHandler(ECoreType type, string gitHubReleaseApi, bool preRelease)
{
try
{
@ -431,7 +429,7 @@ namespace v2rayN.Handler
case ECoreType.Xray:
case ECoreType.v2fly_v5:
{
curVersion = getCoreVersion(type);
curVersion = GetCoreVersion(type);
message = string.Format(ResUI.IsLatestCore, type, curVersion.ToVersionString("v"));
string osBit = "64";
switch (RuntimeInformation.ProcessArchitecture)
@ -456,7 +454,7 @@ namespace v2rayN.Handler
case ECoreType.clash_meta:
case ECoreType.mihomo:
{
curVersion = getCoreVersion(type);
curVersion = GetCoreVersion(type);
message = string.Format(ResUI.IsLatestCore, type, curVersion);
switch (RuntimeInformation.ProcessArchitecture)
{
@ -477,7 +475,7 @@ namespace v2rayN.Handler
}
case ECoreType.sing_box:
{
curVersion = getCoreVersion(type);
curVersion = GetCoreVersion(type);
message = string.Format(ResUI.IsLatestCore, type, curVersion.ToVersionString("v"));
switch (RuntimeInformation.ProcessArchitecture)
{

View File

@ -1,4 +1,6 @@
namespace v2rayN.Models
using v2rayN.Enums;
namespace v2rayN.Models
{
/// <summary>
/// 本软件配置文件实体类

View File

@ -1,4 +1,5 @@
using System.Windows.Input;
using v2rayN.Enums;
namespace v2rayN.Models
{

View File

@ -1,440 +0,0 @@
namespace v2rayN.Models
{
[Serializable]
public class ConfigOld
{
#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>
///
/// </summary>
public ESysProxyType sysProxyType
{
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>
public string remoteDNS
{
get; set;
}
/// <summary>
/// Outbound Freedom domainStrategy
/// </summary>
public string domainStrategy4Freedom
{
get; set;
}
/// <summary>
/// 是否允许不安全连接
/// </summary>
public bool defAllowInsecure
{
get; set;
}
/// <summary>
/// 域名解析策略
/// </summary>
public string domainStrategy
{
get; set;
}
public string domainMatcher
{
get; set;
}
public int routingIndex
{
get; set;
}
public bool enableRoutingAdvanced
{
get; set;
}
public bool ignoreGeoUpdateCore
{
get; set;
}
/// <summary>
/// systemProxyExceptions
/// </summary>
public string systemProxyExceptions
{
get; set;
}
public string systemProxyAdvancedProtocol { get; set; }
public int autoUpdateInterval { get; set; } = 0;
public int autoUpdateSubInterval { get; set; } = 0;
public bool checkPreReleaseUpdate { get; set; } = false;
public bool enableSecurityProtocolTls13
{
get; set;
}
public int trayMenuServersLimit { get; set; }
#endregion property
#region other entities
/// <summary>
/// 本地监听
/// </summary>
public List<InItem> inbound
{
get; set;
}
/// <summary>
/// vmess服务器信息
/// </summary>
public List<VmessItem> vmess
{
get; set;
}
/// <summary>
/// KcpItem
/// </summary>
public KcpItem kcpItem
{
get; set;
}
/// <summary>
/// 订阅
/// </summary>
public List<SubItem> subItem
{
get; set;
}
/// <summary>
/// UI
/// </summary>
public UIItem uiItem
{
get; set;
}
public List<RoutingItemOld> routings
{
get; set;
}
public ConstItem constItem
{
get; set;
}
public List<KeyEventItem> globalHotkeys
{
get; set;
}
public List<CoreTypeItem> coreTypeItem
{
get; set;
}
#endregion other entities
}
[Serializable]
public class VmessItem
{
public VmessItem()
{
indexId = string.Empty;
configType = EConfigType.VMess;
configVersion = 2;
sort = 0;
address = string.Empty;
port = 0;
id = string.Empty;
alterId = 0;
security = string.Empty;
network = string.Empty;
remarks = string.Empty;
headerType = string.Empty;
requestHost = string.Empty;
path = string.Empty;
streamSecurity = string.Empty;
allowInsecure = string.Empty;
testResult = string.Empty;
subid = string.Empty;
flow = string.Empty;
groupId = string.Empty;
}
public string indexId
{
get; set;
}
/// <summary>
/// config type(1=normal,2=custom)
/// </summary>
public EConfigType configType
{
get; set;
}
/// <summary>
/// 版本(现在=2)
/// </summary>
public int configVersion
{
get; set;
}
public int sort
{
get; set;
}
/// <summary>
/// 远程服务器地址
/// </summary>
public string address
{
get; set;
}
/// <summary>
/// 远程服务器端口
/// </summary>
public int port
{
get; set;
}
/// <summary>
/// 远程服务器ID
/// </summary>
public string id
{
get; set;
}
/// <summary>
/// 远程服务器额外ID
/// </summary>
public int alterId
{
get; set;
}
/// <summary>
/// 本地安全策略
/// </summary>
public string security
{
get; set;
}
/// <summary>
/// tcp,kcp,ws,h2,quic
/// </summary>
public string network
{
get; set;
}
/// <summary>
///
/// </summary>
public string remarks
{
get; set;
}
/// <summary>
/// 伪装类型
/// </summary>
public string headerType
{
get; set;
}
/// <summary>
/// 伪装的域名
/// </summary>
public string requestHost
{
get; set;
}
/// <summary>
/// ws h2 path
/// </summary>
public string path
{
get; set;
}
/// <summary>
/// 传输层安全
/// </summary>
public string streamSecurity
{
get; set;
}
/// <summary>
/// 是否允许不安全连接(用于客户端)
/// </summary>
public string allowInsecure
{
get; set;
}
/// <summary>
///
/// </summary>
public string testResult
{
get; set;
}
/// <summary>
/// SubItem id
/// </summary>
public string subid
{
get; set;
}
/// <summary>
/// VLESS flow
/// </summary>
public string flow
{
get; set;
}
/// <summary>
/// tls sni
/// </summary>
public string sni
{
get; set;
}
public string groupId
{
get; set;
} = string.Empty;
public ECoreType? coreType
{
get; set;
}
public int preSocksPort
{
get; set;
}
public string fingerprint { get; set; }
}
[Serializable]
public class RoutingItemOld
{
public string remarks
{
get; set;
}
public string url
{
get; set;
}
public List<RulesItem> rules
{
get; set;
}
public bool enabled { get; set; } = true;
public bool locked
{
get; set;
}
public string customIcon
{
get; set;
}
}
}

View File

@ -1,4 +1,6 @@
namespace v2rayN.Models
using v2rayN.Enums;
namespace v2rayN.Models
{
[Serializable]
public class CoreInfo

View File

@ -1,4 +1,5 @@
using SQLite;
using v2rayN.Enums;
namespace v2rayN.Models
{

View File

@ -1,4 +1,5 @@
using SQLite;
using v2rayN.Enums;
namespace v2rayN.Models
{

View File

@ -1,4 +1,6 @@
namespace v2rayN.Models
using v2rayN.Enums;
namespace v2rayN.Models
{
[Serializable]
internal class ServerTestItem

View File

@ -3,6 +3,7 @@ using ReactiveUI.Fody.Helpers;
using Splat;
using System.Reactive;
using System.Windows;
using v2rayN.Enums;
using v2rayN.Handler;
using v2rayN.Models;
using v2rayN.Resx;

View File

@ -3,6 +3,7 @@ using ReactiveUI.Fody.Helpers;
using Splat;
using System.Reactive;
using System.Windows;
using v2rayN.Enums;
using v2rayN.Handler;
using v2rayN.Models;
using v2rayN.Resx;

View File

@ -14,6 +14,7 @@ using System.Reactive.Linq;
using System.Text;
using System.Windows;
using System.Windows.Media;
using v2rayN.Enums;
using v2rayN.Handler;
using v2rayN.Models;
using v2rayN.Resx;

View File

@ -3,6 +3,7 @@ using ReactiveUI.Fody.Helpers;
using Splat;
using System.Reactive;
using System.Windows;
using v2rayN.Enums;
using v2rayN.Handler;
using v2rayN.Models;
using v2rayN.Resx;

View File

@ -4,6 +4,7 @@ using ReactiveUI.Fody.Helpers;
using Splat;
using System.Reactive;
using System.Windows;
using v2rayN.Enums;
using v2rayN.Handler;
using v2rayN.Models;
using v2rayN.Resx;

View File

@ -1,6 +1,7 @@
using ReactiveUI;
using System.Reactive.Disposables;
using System.Windows;
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.ViewModels;

View File

@ -2,6 +2,7 @@
using System.Reactive.Disposables;
using System.Windows;
using System.Windows.Controls;
using v2rayN.Enums;
using v2rayN.Handler;
using v2rayN.Models;
using v2rayN.Resx;

View File

@ -2,6 +2,7 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using v2rayN.Enums;
using v2rayN.Handler;
using v2rayN.Models;
using v2rayN.Resx;

View File

@ -10,6 +10,7 @@ using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using v2rayN.Base;
using v2rayN.Enums;
using v2rayN.Handler;
using v2rayN.Models;
using v2rayN.Resx;

View File

@ -2,6 +2,7 @@
using System.Reactive.Disposables;
using System.Windows;
using System.Windows.Input;
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.ViewModels;