Refactoring Project

pull/5566/head
2dust 2024-08-19 18:15:54 +08:00
parent bbe7c7b884
commit 61bea05f63
168 changed files with 345 additions and 578 deletions

View File

@ -1,10 +1,9 @@
using Downloader; using Downloader;
using System.IO;
using System.Net; using System.Net;
namespace v2rayN namespace ServiceLib.Common
{ {
internal class DownloaderHelper public class DownloaderHelper
{ {
private static readonly Lazy<DownloaderHelper> _instance = new(() => new()); private static readonly Lazy<DownloaderHelper> _instance = new(() => new());
public static DownloaderHelper Instance => _instance.Value; public static DownloaderHelper Instance => _instance.Value;

View File

@ -1,8 +1,7 @@
using System.IO; using System.IO.Compression;
using System.IO.Compression;
using System.Text; using System.Text;
namespace v2rayN namespace ServiceLib.Common
{ {
public static class FileManager public static class FileManager
{ {
@ -86,5 +85,19 @@ namespace v2rayN
} }
return true; return true;
} }
public static bool CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName)
{
try
{
ZipFile.CreateFromDirectory(sourceDirectoryName, destinationArchiveFileName);
}
catch (Exception ex)
{
Logging.SaveLog(ex.Message, ex);
return false;
}
return true;
}
} }
} }

View File

@ -1,10 +1,8 @@
using System.IO; using System.Net.Http.Headers;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Mime; using System.Net.Mime;
using System.Text; using System.Text;
namespace v2rayN namespace ServiceLib.Common
{ {
/// <summary> /// <summary>
/// </summary> /// </summary>

View File

@ -1,7 +1,7 @@
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace v2rayN namespace ServiceLib.Common
{ {
/* /*
* See: * See:

View File

@ -1,11 +1,10 @@
using System.IO; using System.Text.Json;
using System.Text.Json;
using System.Text.Json.Nodes; using System.Text.Json.Nodes;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace v2rayN namespace ServiceLib.Common
{ {
internal class JsonUtils public class JsonUtils
{ {
/// <summary> /// <summary>
/// DeepCopy /// DeepCopy

View File

@ -1,9 +1,8 @@
using NLog; using NLog;
using NLog.Config; using NLog.Config;
using NLog.Targets; using NLog.Targets;
using System.IO;
namespace v2rayN namespace ServiceLib.Common
{ {
public class Logging public class Logging
{ {

View File

@ -1,7 +1,7 @@
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection; using System.Reflection;
namespace v2rayN namespace ServiceLib.Common
{ {
public static class QueryableExtension public static class QueryableExtension
{ {

View File

@ -1,4 +1,4 @@
namespace v2rayN namespace ServiceLib.Common
{ {
public class SemanticVersion public class SemanticVersion
{ {

View File

@ -1,7 +1,7 @@
using SQLite; using SQLite;
using System.Collections; using System.Collections;
namespace v2rayN namespace ServiceLib.Common
{ {
public sealed class SQLiteHelper public sealed class SQLiteHelper
{ {

View File

@ -1,9 +1,8 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.IO;
namespace v2rayN namespace ServiceLib.Common
{ {
internal static class StringEx public static class StringEx
{ {
public static bool IsNullOrEmpty([NotNullWhen(false)] this string? value) public static bool IsNullOrEmpty([NotNullWhen(false)] this string? value)
{ {

View File

@ -1,6 +1,5 @@
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Net; using System.Net;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
@ -10,9 +9,9 @@ using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace v2rayN namespace ServiceLib.Common
{ {
internal class Utils public class Utils
{ {
#region 资源Json操作 #region 资源Json操作

View File

@ -1,9 +1,9 @@
using YamlDotNet.Serialization; using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NamingConventions;
namespace v2rayN.Common namespace ServiceLib.Common
{ {
internal class YamlUtils public class YamlUtils
{ {
#region YAML #region YAML

View File

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

View File

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

View File

@ -1,4 +1,4 @@
namespace v2rayN.Enums namespace ServiceLib.Enums
{ {
public enum EGirdOrientation public enum EGirdOrientation
{ {

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
namespace v2rayN.Enums namespace ServiceLib.Enums
{ {
public enum ERuleMode public enum ERuleMode
{ {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,8 +1,6 @@
using v2rayN.Enums; namespace ServiceLib
namespace v2rayN
{ {
internal class Global public class Global
{ {
#region const #region const
@ -32,21 +30,21 @@ namespace v2rayN
public const string CoreSpeedtestConfigFileName = "configSpeedtest.json"; public const string CoreSpeedtestConfigFileName = "configSpeedtest.json";
public const string CoreMultipleLoadConfigFileName = "configMultipleLoad.json"; public const string CoreMultipleLoadConfigFileName = "configMultipleLoad.json";
public const string ClashMixinConfigFileName = "Mixin.yaml"; public const string ClashMixinConfigFileName = "Mixin.yaml";
public const string V2raySampleClient = "v2rayN.Sample.SampleClientConfig"; public const string V2raySampleClient = "ServiceLib.Sample.SampleClientConfig";
public const string SingboxSampleClient = "v2rayN.Sample.SingboxSampleClientConfig"; public const string SingboxSampleClient = "ServiceLib.Sample.SingboxSampleClientConfig";
public const string V2raySampleHttpRequestFileName = "v2rayN.Sample.SampleHttpRequest"; public const string V2raySampleHttpRequestFileName = "ServiceLib.Sample.SampleHttpRequest";
public const string V2raySampleHttpResponseFileName = "v2rayN.Sample.SampleHttpResponse"; public const string V2raySampleHttpResponseFileName = "ServiceLib.Sample.SampleHttpResponse";
public const string V2raySampleInbound = "v2rayN.Sample.SampleInbound"; public const string V2raySampleInbound = "ServiceLib.Sample.SampleInbound";
public const string V2raySampleOutbound = "v2rayN.Sample.SampleOutbound"; public const string V2raySampleOutbound = "ServiceLib.Sample.SampleOutbound";
public const string SingboxSampleOutbound = "v2rayN.Sample.SingboxSampleOutbound"; public const string SingboxSampleOutbound = "ServiceLib.Sample.SingboxSampleOutbound";
public const string CustomRoutingFileName = "v2rayN.Sample.custom_routing_"; public const string CustomRoutingFileName = "ServiceLib.Sample.custom_routing_";
public const string TunSingboxDNSFileName = "v2rayN.Sample.tun_singbox_dns"; public const string TunSingboxDNSFileName = "ServiceLib.Sample.tun_singbox_dns";
public const string TunSingboxInboundFileName = "v2rayN.Sample.tun_singbox_inbound"; public const string TunSingboxInboundFileName = "ServiceLib.Sample.tun_singbox_inbound";
public const string TunSingboxRulesFileName = "v2rayN.Sample.tun_singbox_rules"; public const string TunSingboxRulesFileName = "ServiceLib.Sample.tun_singbox_rules";
public const string DNSV2rayNormalFileName = "v2rayN.Sample.dns_v2ray_normal"; public const string DNSV2rayNormalFileName = "ServiceLib.Sample.dns_v2ray_normal";
public const string DNSSingboxNormalFileName = "v2rayN.Sample.dns_singbox_normal"; public const string DNSSingboxNormalFileName = "ServiceLib.Sample.dns_singbox_normal";
public const string ClashMixinYaml = "v2rayN.Sample.clash_mixin_yaml"; public const string ClashMixinYaml = "ServiceLib.Sample.clash_mixin_yaml";
public const string ClashTunYaml = "v2rayN.Sample.clash_tun_yaml"; public const string ClashTunYaml = "ServiceLib.Sample.clash_tun_yaml";
public const string DefaultSecurity = "auto"; public const string DefaultSecurity = "auto";
public const string DefaultNetwork = "tcp"; public const string DefaultNetwork = "tcp";

View File

@ -0,0 +1,7 @@
global using ServiceLib.Common;
global using ServiceLib.Enums;
global using ServiceLib.Handler.CoreConfig;
global using ServiceLib.Handler.Fmt;
global using ServiceLib.Handler.Statistics;
global using ServiceLib.Models;
global using ServiceLib.Resx;

View File

@ -1,7 +1,6 @@
using v2rayN.Models; using static ServiceLib.Models.ClashProxies;
using static v2rayN.Models.ClashProxies;
namespace v2rayN.Handler namespace ServiceLib.Handler
{ {
public sealed class ClashApiHandler public sealed class ClashApiHandler
{ {

View File

@ -1,18 +1,13 @@
using System.Data; using System.Data;
using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Web; using System.Web;
using v2rayN.Enums;
using v2rayN.Handler.CoreConfig;
using v2rayN.Handler.Fmt;
using v2rayN.Models;
namespace v2rayN.Handler namespace ServiceLib.Handler
{ {
/// <summary> /// <summary>
/// 本软件配置文件处理类 /// 本软件配置文件处理类
/// </summary> /// </summary>
internal class ConfigHandler public class ConfigHandler
{ {
private static string configRes = Global.ConfigFileName; private static string configRes = Global.ConfigFileName;
private static readonly object objLock = new(); private static readonly object objLock = new();
@ -1156,7 +1151,7 @@ namespace v2rayN.Handler
var profileItem = LazyConfig.Instance.GetProfileItem(indexId) ?? new(); var profileItem = LazyConfig.Instance.GetProfileItem(indexId) ?? new();
profileItem.indexId = indexId; profileItem.indexId = indexId;
profileItem.remarks = coreType == ECoreType.sing_box ? Resx.ResUI.menuSetDefaultMultipleServer : Resx.ResUI.menuSetDefaultLoadBalanceServer; profileItem.remarks = coreType == ECoreType.sing_box ? ResUI.menuSetDefaultMultipleServer : ResUI.menuSetDefaultLoadBalanceServer;
profileItem.address = Global.CoreMultipleLoadConfigFileName; profileItem.address = Global.CoreMultipleLoadConfigFileName;
profileItem.configType = EConfigType.Custom; profileItem.configType = EConfigType.Custom;
profileItem.coreType = coreType; profileItem.coreType = coreType;

View File

@ -1,15 +1,9 @@
using System.IO; namespace ServiceLib.Handler.CoreConfig
using v2rayN.Common;
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler.CoreConfig
{ {
/// <summary> /// <summary>
/// Core configuration file processing class /// Core configuration file processing class
/// </summary> /// </summary>
internal class CoreConfigClash public class CoreConfigClash
{ {
private Config _config; private Config _config;

View File

@ -1,14 +1,9 @@
using System.IO; namespace ServiceLib.Handler.CoreConfig
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler.CoreConfig
{ {
/// <summary> /// <summary>
/// Core configuration file processing class /// Core configuration file processing class
/// </summary> /// </summary>
internal class CoreConfigHandler public class CoreConfigHandler
{ {
public static int GenerateClientConfig(ProfileItem node, string? fileName, out string msg, out string content) public static int GenerateClientConfig(ProfileItem node, string? fileName, out string msg, out string content)
{ {

View File

@ -1,14 +1,10 @@
using System.Data; using System.Data;
using System.IO;
using System.Net; using System.Net;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler.CoreConfig namespace ServiceLib.Handler.CoreConfig
{ {
internal class CoreConfigSingbox public class CoreConfigSingbox
{ {
private Config _config; private Config _config;

View File

@ -1,13 +1,10 @@
using System.Net; using System.Net;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using System.Text.Json.Nodes; using System.Text.Json.Nodes;
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler.CoreConfig namespace ServiceLib.Handler.CoreConfig
{ {
internal class CoreConfigV2ray public class CoreConfigV2ray
{ {
private Config _config; private Config _config;

View File

@ -1,17 +1,12 @@
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using System.Text; using System.Text;
using v2rayN.Enums;
using v2rayN.Handler.CoreConfig;
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler namespace ServiceLib.Handler
{ {
/// <summary> /// <summary>
/// Core process processing class /// Core process processing class
/// </summary> /// </summary>
internal class CoreHandler public class CoreHandler
{ {
private Config _config; private Config _config;
private Process? _process; private Process? _process;

View File

@ -1,8 +1,6 @@
using System.Runtime.Intrinsics.X86; using System.Runtime.Intrinsics.X86;
using v2rayN.Enums;
using v2rayN.Models;
namespace v2rayN.Handler namespace ServiceLib.Handler
{ {
public sealed class CoreInfoHandler public sealed class CoreInfoHandler
{ {

View File

@ -1,18 +1,14 @@
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using System.Net; using System.Net;
using System.Net.Http;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Net.Sockets; using System.Net.Sockets;
using v2rayN.Enums;
using v2rayN.Resx;
namespace v2rayN.Handler namespace ServiceLib.Handler
{ {
/// <summary> /// <summary>
///Download ///Download
/// </summary> /// </summary>
internal class DownloadHandler public class DownloadHandler
{ {
public event EventHandler<ResultEventArgs>? UpdateCompleted; public event EventHandler<ResultEventArgs>? UpdateCompleted;

View File

@ -1,11 +1,8 @@
using System.Collections.Specialized; using System.Collections.Specialized;
using System.IO;
using v2rayN.Enums;
using v2rayN.Models;
namespace v2rayN.Handler.Fmt namespace ServiceLib.Handler.Fmt
{ {
internal class BaseFmt public class BaseFmt
{ {
protected static string GetIpv6(string address) protected static string GetIpv6(string address)
{ {

View File

@ -1,9 +1,6 @@
using v2rayN.Enums; namespace ServiceLib.Handler.Fmt
using v2rayN.Models;
namespace v2rayN.Handler.Fmt
{ {
internal class ClashFmt : BaseFmt public class ClashFmt : BaseFmt
{ {
public static ProfileItem? ResolveFull(string strData, string? subRemarks) public static ProfileItem? ResolveFull(string strData, string? subRemarks)
{ {

View File

@ -1,10 +1,6 @@
using v2rayN.Enums; namespace ServiceLib.Handler.Fmt
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler.Fmt
{ {
internal class FmtHandler public class FmtHandler
{ {
public static string? GetShareUri(ProfileItem item) public static string? GetShareUri(ProfileItem item)
{ {

View File

@ -1,10 +1,6 @@
using v2rayN.Enums; namespace ServiceLib.Handler.Fmt
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler.Fmt
{ {
internal class Hysteria2Fmt : BaseFmt public class Hysteria2Fmt : BaseFmt
{ {
public static ProfileItem? Resolve(string str, out string msg) public static ProfileItem? Resolve(string str, out string msg)
{ {

View File

@ -1,9 +1,6 @@
using v2rayN.Enums; namespace ServiceLib.Handler.Fmt
using v2rayN.Models;
namespace v2rayN.Handler.Fmt
{ {
internal class NaiveproxyFmt : BaseFmt public class NaiveproxyFmt : BaseFmt
{ {
public static ProfileItem? ResolveFull(string strData, string? subRemarks) public static ProfileItem? ResolveFull(string strData, string? subRemarks)
{ {

View File

@ -1,11 +1,8 @@
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler.Fmt namespace ServiceLib.Handler.Fmt
{ {
internal class ShadowsocksFmt : BaseFmt public class ShadowsocksFmt : BaseFmt
{ {
public static ProfileItem? Resolve(string str, out string msg) public static ProfileItem? Resolve(string str, out string msg)
{ {

View File

@ -1,9 +1,6 @@
using v2rayN.Enums; namespace ServiceLib.Handler.Fmt
using v2rayN.Models;
namespace v2rayN.Handler.Fmt
{ {
internal class SingboxFmt : BaseFmt public class SingboxFmt : BaseFmt
{ {
public static List<ProfileItem>? ResolveFullArray(string strData, string? subRemarks) public static List<ProfileItem>? ResolveFullArray(string strData, string? subRemarks)
{ {

View File

@ -1,10 +1,6 @@
using v2rayN.Enums; namespace ServiceLib.Handler.Fmt
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler.Fmt
{ {
internal class SocksFmt : BaseFmt public class SocksFmt : BaseFmt
{ {
public static ProfileItem? Resolve(string str, out string msg) public static ProfileItem? Resolve(string str, out string msg)
{ {

View File

@ -1,10 +1,6 @@
using v2rayN.Enums; namespace ServiceLib.Handler.Fmt
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler.Fmt
{ {
internal class TrojanFmt : BaseFmt public class TrojanFmt : BaseFmt
{ {
public static ProfileItem? Resolve(string str, out string msg) public static ProfileItem? Resolve(string str, out string msg)
{ {

View File

@ -1,10 +1,6 @@
using v2rayN.Enums; namespace ServiceLib.Handler.Fmt
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler.Fmt
{ {
internal class TuicFmt : BaseFmt public class TuicFmt : BaseFmt
{ {
public static ProfileItem? Resolve(string str, out string msg) public static ProfileItem? Resolve(string str, out string msg)
{ {

View File

@ -1,9 +1,6 @@
using v2rayN.Enums; namespace ServiceLib.Handler.Fmt
using v2rayN.Models;
namespace v2rayN.Handler.Fmt
{ {
internal class V2rayFmt : BaseFmt public class V2rayFmt : BaseFmt
{ {
public static List<ProfileItem>? ResolveFullArray(string strData, string? subRemarks) public static List<ProfileItem>? ResolveFullArray(string strData, string? subRemarks)
{ {

View File

@ -1,10 +1,6 @@
using v2rayN.Enums; namespace ServiceLib.Handler.Fmt
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler.Fmt
{ {
internal class VLESSFmt : BaseFmt public class VLESSFmt : BaseFmt
{ {
public static ProfileItem? Resolve(string str, out string msg) public static ProfileItem? Resolve(string str, out string msg)
{ {

View File

@ -1,10 +1,6 @@
using v2rayN.Enums; namespace ServiceLib.Handler.Fmt
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler.Fmt
{ {
internal class VmessFmt : BaseFmt public class VmessFmt : BaseFmt
{ {
public static ProfileItem? Resolve(string str, out string msg) public static ProfileItem? Resolve(string str, out string msg)
{ {

View File

@ -1,10 +1,6 @@
using v2rayN.Enums; namespace ServiceLib.Handler.Fmt
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler.Fmt
{ {
internal class WireguardFmt : BaseFmt public class WireguardFmt : BaseFmt
{ {
public static ProfileItem? Resolve(string str, out string msg) public static ProfileItem? Resolve(string str, out string msg)
{ {

View File

@ -1,8 +1,4 @@
using v2rayN.Enums; namespace ServiceLib.Handler
using v2rayN.Handler.Statistics;
using v2rayN.Models;
namespace v2rayN.Handler
{ {
public sealed class LazyConfig public sealed class LazyConfig
{ {

View File

@ -1,10 +1,10 @@
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Reactive.Linq;
using v2rayN.Models;
namespace v2rayN.Handler //using System.Reactive.Linq;
namespace ServiceLib.Handler
{ {
internal class ProfileExHandler public class ProfileExHandler
{ {
private static readonly Lazy<ProfileExHandler> _instance = new(() => new()); private static readonly Lazy<ProfileExHandler> _instance = new(() => new());
private ConcurrentBag<ProfileExItem> _lstProfileEx = []; private ConcurrentBag<ProfileExItem> _lstProfileEx = [];

View File

@ -1,25 +1,17 @@
using ReactiveUI; using System.Diagnostics;
using System.Diagnostics;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler namespace ServiceLib.Handler
{ {
internal class SpeedtestHandler public class SpeedtestHandler
{ {
private Config? _config; private Config? _config;
private CoreHandler _coreHandler; private CoreHandler _coreHandler;
private List<ServerTestItem> _selecteds; private List<ServerTestItem> _selecteds;
private ESpeedActionType _actionType; private ESpeedActionType _actionType;
private Action<SpeedTestResult> _updateFunc; private Action<SpeedTestResult> _updateFunc;
private bool _exitLoop = false;
public SpeedtestHandler(Config config)
{
_config = config;
}
public SpeedtestHandler(Config config, CoreHandler coreHandler, List<ProfileItem> selecteds, ESpeedActionType actionType, Action<SpeedTestResult> update) public SpeedtestHandler(Config config, CoreHandler coreHandler, List<ProfileItem> selecteds, ESpeedActionType actionType, Action<SpeedTestResult> update)
{ {
@ -91,6 +83,12 @@ namespace v2rayN.Handler
} }
} }
public void ExitLoop()
{
_exitLoop = true;
UpdateFunc("", ResUI.SpeedtestingStop);
}
private Task RunTcping() private Task RunTcping()
{ {
try try
@ -215,20 +213,9 @@ namespace v2rayN.Handler
DownloadHandler downloadHandle = new(); DownloadHandler downloadHandle = new();
var exitLoop = false;
MessageBus.Current.Listen<string>(Global.CommandStopSpeedTest)
.Subscribe(x =>
{
if (!exitLoop)
{
UpdateFunc("", ResUI.SpeedtestingStop);
}
exitLoop = true;
});
foreach (var it in _selecteds) foreach (var it in _selecteds)
{ {
if (exitLoop) if (_exitLoop)
{ {
UpdateFunc(it.indexId, "", ResUI.SpeedtestingSkip); UpdateFunc(it.indexId, "", ResUI.SpeedtestingSkip);
continue; continue;
@ -288,20 +275,9 @@ namespace v2rayN.Handler
DownloadHandler downloadHandle = new(); DownloadHandler downloadHandle = new();
var exitLoop = false;
MessageBus.Current.Listen<string>(Global.CommandStopSpeedTest)
.Subscribe(x =>
{
if (!exitLoop)
{
UpdateFunc("", ResUI.SpeedtestingStop);
}
exitLoop = true;
});
foreach (var it in _selecteds) foreach (var it in _selecteds)
{ {
if (exitLoop) if (_exitLoop)
{ {
UpdateFunc(it.indexId, "", ResUI.SpeedtestingSkip); UpdateFunc(it.indexId, "", ResUI.SpeedtestingSkip);
continue; continue;

View File

@ -1,8 +1,6 @@
using v2rayN.Models; namespace ServiceLib.Handler.Statistics
namespace v2rayN.Handler.Statistics
{ {
internal class StatisticsHandler public class StatisticsHandler
{ {
private static readonly Lazy<StatisticsHandler> instance = new(() => new()); private static readonly Lazy<StatisticsHandler> instance = new(() => new());
public static StatisticsHandler Instance => instance.Value; public static StatisticsHandler Instance => instance.Value;

View File

@ -1,11 +1,9 @@
using System.Net.WebSockets; using System.Net.WebSockets;
using System.Text; using System.Text;
using v2rayN.Enums;
using v2rayN.Models;
namespace v2rayN.Handler.Statistics namespace ServiceLib.Handler.Statistics
{ {
internal class StatisticsSingbox public class StatisticsSingbox
{ {
private Config _config; private Config _config;
private bool _exitFlag; private bool _exitFlag;

View File

@ -1,12 +1,10 @@
using Grpc.Core; using Grpc.Core;
using Grpc.Net.Client; using Grpc.Net.Client;
using ProtosLib.Statistics; using ProtosLib.Statistics;
using v2rayN.Enums;
using v2rayN.Models;
namespace v2rayN.Handler.Statistics namespace ServiceLib.Handler.Statistics
{ {
internal class StatisticsV2ray public class StatisticsV2ray
{ {
private Models.Config _config; private Models.Config _config;
private GrpcChannel? _channel; private GrpcChannel? _channel;

View File

@ -1,8 +1,6 @@
using v2rayN.Models; namespace ServiceLib.Handler
namespace v2rayN.Handler
{ {
internal class TaskHandler public class TaskHandler
{ {
private static readonly Lazy<TaskHandler> _instance = new(() => new()); private static readonly Lazy<TaskHandler> _instance = new(() => new());
public static TaskHandler Instance => _instance.Value; public static TaskHandler Instance => _instance.Value;

View File

@ -1,17 +1,11 @@
using DynamicData; using System.Diagnostics;
using Splat;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;
namespace v2rayN.Handler namespace ServiceLib.Handler
{ {
internal class UpdateHandler public class UpdateHandler
{ {
private Action<bool, string> _updateFunc; private Action<bool, string> _updateFunc;
private Config _config; private Config _config;
@ -44,30 +38,9 @@ namespace v2rayN.Handler
if (args.Success) if (args.Success)
{ {
_updateFunc(false, ResUI.MsgDownloadV2rayCoreSuccessfully); _updateFunc(false, ResUI.MsgDownloadV2rayCoreSuccessfully);
string fileName = Utils.GetTempPath(Utils.GetDownloadFileName(url));
try fileName = Utils.UrlEncode(fileName);
{ _updateFunc(true, fileName);
string fileName = Utils.GetTempPath(Utils.GetDownloadFileName(url));
fileName = Utils.UrlEncode(fileName);
Process process = new()
{
StartInfo = new ProcessStartInfo
{
FileName = "v2rayUpgrade.exe",
Arguments = fileName.AppendQuotes(),
WorkingDirectory = Utils.StartupPath()
}
};
process.Start();
if (process.Id > 0)
{
_updateFunc(true, "");
}
}
catch (Exception ex)
{
_updateFunc(false, ex.Message);
}
} }
else else
{ {
@ -82,7 +55,7 @@ namespace v2rayN.Handler
{ {
if (args.Success) if (args.Success)
{ {
_updateFunc(false, string.Format(ResUI.MsgParsingSuccessfully, "v2rayN")); _updateFunc(false, string.Format(ResUI.MsgParsingSuccessfully, ECoreType.v2rayN));
_updateFunc(false, args.Msg); _updateFunc(false, args.Msg);
url = args.Url; url = args.Url;
@ -93,11 +66,10 @@ namespace v2rayN.Handler
} }
else else
{ {
Locator.Current.GetService<NoticeHandler>()?.Enqueue(args.Msg);
_updateFunc(false, args.Msg); _updateFunc(false, args.Msg);
} }
}; };
_updateFunc(false, string.Format(ResUI.MsgStartUpdating, "v2rayN")); _updateFunc(false, string.Format(ResUI.MsgStartUpdating, ECoreType.v2rayN));
CheckUpdateAsync(ECoreType.v2rayN, preRelease); CheckUpdateAsync(ECoreType.v2rayN, preRelease);
} }
@ -138,7 +110,7 @@ namespace v2rayN.Handler
{ {
if (args.Success) if (args.Success)
{ {
_updateFunc(false, string.Format(ResUI.MsgParsingSuccessfully, "Core")); _updateFunc(false, string.Format(ResUI.MsgParsingSuccessfully, type));
_updateFunc(false, args.Msg); _updateFunc(false, args.Msg);
url = args.Url; url = args.Url;
@ -149,11 +121,10 @@ namespace v2rayN.Handler
} }
else else
{ {
Locator.Current.GetService<NoticeHandler>()?.Enqueue(args.Msg);
_updateFunc(false, args.Msg); _updateFunc(false, args.Msg);
} }
}; };
_updateFunc(false, string.Format(ResUI.MsgStartUpdating, "Core")); _updateFunc(false, string.Format(ResUI.MsgStartUpdating, type));
CheckUpdateAsync(type, preRelease); CheckUpdateAsync(type, preRelease);
} }
@ -232,10 +203,7 @@ namespace v2rayN.Handler
result = Utils.Base64Decode(result); result = Utils.Base64Decode(result);
} }
var lstUrl = new List<string> var lstUrl = item.moreUrl.TrimEx().Split(",") ?? [];
{
item.moreUrl.TrimEx().Split(",")
};
foreach (var it in lstUrl) foreach (var it in lstUrl)
{ {
var url2 = Utils.GetPunycode(it); var url2 = Utils.GetPunycode(it);
@ -570,11 +538,6 @@ namespace v2rayN.Handler
string fileName = Utils.GetTempPath(Utils.GetDownloadFileName(url)); string fileName = Utils.GetTempPath(Utils.GetDownloadFileName(url));
if (File.Exists(fileName)) if (File.Exists(fileName))
{ {
//Global.coreTypes.ForEach(it =>
//{
// string targetPath = Utile.GetBinPath($"{geoName}.dat", (ECoreType)Enum.Parse(typeof(ECoreType), it));
// File.Copy(fileName, targetPath, true);
//});
string targetPath = Utils.GetBinPath($"{geoName}.dat"); string targetPath = Utils.GetBinPath($"{geoName}.dat");
File.Copy(fileName, targetPath, true); File.Copy(fileName, targetPath, true);

View File

@ -1,4 +1,4 @@
namespace v2rayN.Models namespace ServiceLib.Models
{ {
public class ClashConnectionModel public class ClashConnectionModel
{ {

View File

@ -1,4 +1,4 @@
namespace v2rayN.Models namespace ServiceLib.Models
{ {
public class ClashConnections public class ClashConnections
{ {

View File

@ -1,6 +1,6 @@
using static v2rayN.Models.ClashProxies; using static ServiceLib.Models.ClashProxies;
namespace v2rayN.Models namespace ServiceLib.Models
{ {
public class ClashProviders public class ClashProviders
{ {

View File

@ -1,4 +1,4 @@
namespace v2rayN.Models namespace ServiceLib.Models
{ {
public class ClashProxies public class ClashProxies
{ {

View File

@ -1,26 +1,18 @@
using ReactiveUI.Fody.Helpers; namespace ServiceLib.Models
namespace v2rayN.Models
{ {
[Serializable] [Serializable]
public class ClashProxyModel public class ClashProxyModel
{ {
[Reactive]
public string name { get; set; } public string name { get; set; }
[Reactive]
public string type { get; set; } public string type { get; set; }
[Reactive]
public string now { get; set; } public string now { get; set; }
[Reactive]
public int delay { get; set; } public int delay { get; set; }
[Reactive]
public string delayName { get; set; } public string delayName { get; set; }
[Reactive]
public bool isActive { get; set; } public bool isActive { get; set; }
} }
} }

View File

@ -1,4 +1,4 @@
namespace v2rayN.Models namespace ServiceLib.Models
{ {
public class ComboItem public class ComboItem
{ {

View File

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

View File

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

View File

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

View File

@ -1,7 +1,6 @@
using SQLite; using SQLite;
using v2rayN.Enums;
namespace v2rayN.Models namespace ServiceLib.Models
{ {
[Serializable] [Serializable]
public class DNSItem public class DNSItem

View File

@ -1,6 +1,6 @@
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace v2rayN.Models namespace ServiceLib.Models
{ {
public class GitHubReleaseAsset public class GitHubReleaseAsset
{ {

View File

@ -1,6 +1,6 @@
using SQLite; using SQLite;
namespace v2rayN.Models namespace ServiceLib.Models
{ {
[Serializable] [Serializable]
public class ProfileExItem public class ProfileExItem

View File

@ -1,7 +1,6 @@
using SQLite; using SQLite;
using v2rayN.Enums;
namespace v2rayN.Models namespace ServiceLib.Models
{ {
[Serializable] [Serializable]
public class ProfileItem public class ProfileItem

View File

@ -1,4 +1,4 @@
namespace v2rayN.Models namespace ServiceLib.Models
{ {
[Serializable] [Serializable]
public class ProfileItemModel : ProfileItem public class ProfileItemModel : ProfileItem

View File

@ -1,6 +1,6 @@
using SQLite; using SQLite;
namespace v2rayN.Models namespace ServiceLib.Models
{ {
[Serializable] [Serializable]
public class RoutingItem public class RoutingItem

View File

@ -1,4 +1,4 @@
namespace v2rayN.Models namespace ServiceLib.Models
{ {
[Serializable] [Serializable]
public class RoutingItemModel : RoutingItem public class RoutingItemModel : RoutingItem

View File

@ -1,4 +1,4 @@
namespace v2rayN.Models namespace ServiceLib.Models
{ {
[Serializable] [Serializable]
public class RulesItem public class RulesItem

View File

@ -1,4 +1,4 @@
namespace v2rayN.Models namespace ServiceLib.Models
{ {
[Serializable] [Serializable]
public class RulesItemModel : RulesItem public class RulesItemModel : RulesItem

View File

@ -1,4 +1,4 @@
namespace v2rayN.Models namespace ServiceLib.Models
{ {
[Serializable] [Serializable]
public class ServerSpeedItem : ServerStatItem public class ServerSpeedItem : ServerStatItem

View File

@ -1,6 +1,6 @@
using SQLite; using SQLite;
namespace v2rayN.Models namespace ServiceLib.Models
{ {
[Serializable] [Serializable]
public class ServerStatItem public class ServerStatItem

View File

@ -1,9 +1,7 @@
using v2rayN.Enums; namespace ServiceLib.Models
namespace v2rayN.Models
{ {
[Serializable] [Serializable]
internal class ServerTestItem public class ServerTestItem
{ {
public string indexId { get; set; } public string indexId { get; set; }
public string address { get; set; } public string address { get; set; }

View File

@ -1,4 +1,4 @@
namespace v2rayN.Models namespace ServiceLib.Models
{ {
public class SingboxConfig public class SingboxConfig
{ {

View File

@ -1,4 +1,4 @@
namespace v2rayN.Models namespace ServiceLib.Models
{ {
[Serializable] [Serializable]
public class SpeedTestResult public class SpeedTestResult

View File

@ -1,4 +1,4 @@
namespace v2rayN.Models namespace ServiceLib.Models
{ {
public class SsSIP008 public class SsSIP008
{ {

View File

@ -1,6 +1,6 @@
using SQLite; using SQLite;
namespace v2rayN.Models namespace ServiceLib.Models
{ {
[Serializable] [Serializable]
public class SubItem public class SubItem

View File

@ -1,6 +1,6 @@
namespace v2rayN.Models namespace ServiceLib.Models
{ {
internal class SysProxyConfig public class SysProxyConfig
{ {
public bool UserSettingsRecorded; public bool UserSettingsRecorded;
public string Flags; public string Flags;

View File

@ -1,6 +1,6 @@
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace v2rayN.Models namespace ServiceLib.Models
{ {
/// <summary> /// <summary>
/// v2ray配置文件实体类 例子SampleConfig.txt /// v2ray配置文件实体类 例子SampleConfig.txt

View File

@ -1,4 +1,4 @@
namespace v2rayN.Models namespace ServiceLib.Models
{ {
/// <summary> /// <summary>
/// Tcp伪装http的Request只要Host /// Tcp伪装http的Request只要Host

View File

@ -1,12 +1,12 @@
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace v2rayN.Models namespace ServiceLib.Models
{ {
/// <summary> /// <summary>
/// https://github.com/2dust/v2rayN/wiki/ /// https://github.com/2dust/v2rayN/wiki/
/// </summary> /// </summary>
[Serializable] [Serializable]
internal class VmessQRCode public class VmessQRCode
{ {
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)] [JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
public int v { get; set; } = 2; public int v { get; set; } = 2;

View File

@ -8,7 +8,7 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace v2rayN.Resx { namespace ServiceLib.Resx {
using System; using System;
@ -29,7 +29,7 @@ namespace v2rayN.Resx {
private static global::System.Globalization.CultureInfo resourceCulture; private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal ResUI() { public ResUI() {
} }
/// <summary> /// <summary>
@ -39,7 +39,7 @@ namespace v2rayN.Resx {
public static global::System.Resources.ResourceManager ResourceManager { public static global::System.Resources.ResourceManager ResourceManager {
get { get {
if (object.ReferenceEquals(resourceMan, null)) { if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("v2rayN.Resx.ResUI", typeof(ResUI).Assembly); global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ServiceLib.Resx.ResUI", typeof(ResUI).Assembly);
resourceMan = temp; resourceMan = temp;
} }
return resourceMan; return resourceMan;

Some files were not shown because too many files have changed in this diff Show More