Skip to content

Commit

Permalink
Refactoring Project
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Aug 19, 2024
1 parent bbe7c7b commit 61bea05
Show file tree
Hide file tree
Showing 168 changed files with 345 additions and 578 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using Downloader;
using System.IO;
using System.Net;

namespace v2rayN
namespace ServiceLib.Common
{
internal class DownloaderHelper
public class DownloaderHelper
{
private static readonly Lazy<DownloaderHelper> _instance = new(() => new());
public static DownloaderHelper Instance => _instance.Value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System.IO;
using System.IO.Compression;
using System.IO.Compression;
using System.Text;

namespace v2rayN
namespace ServiceLib.Common
{
public static class FileManager
{
Expand Down Expand Up @@ -86,5 +85,19 @@ public static bool ZipExtractToFile(string fileName, string toPath, string ignor
}
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;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Http.Headers;
using System.Net.Mime;
using System.Text;

namespace v2rayN
namespace ServiceLib.Common
{
/// <summary>
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace v2rayN
namespace ServiceLib.Common
{
/*
* See:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using System.IO;
using System.Text.Json;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;

namespace v2rayN
namespace ServiceLib.Common
{
internal class JsonUtils
public class JsonUtils
{
/// <summary>
/// DeepCopy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using NLog;
using NLog.Config;
using NLog.Targets;
using System.IO;

namespace v2rayN
namespace ServiceLib.Common
{
public class Logging
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Linq.Expressions;
using System.Reflection;

namespace v2rayN
namespace ServiceLib.Common
{
public static class QueryableExtension
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace v2rayN
namespace ServiceLib.Common
{
public class SemanticVersion
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using SQLite;
using System.Collections;

namespace v2rayN
namespace ServiceLib.Common
{
public sealed class SQLiteHelper
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
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)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections.Specialized;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Net;
using System.Net.NetworkInformation;
Expand All @@ -10,9 +9,9 @@
using System.Text;
using System.Text.RegularExpressions;

namespace v2rayN
namespace ServiceLib.Common
{
internal class Utils
public class Utils
{
#region 资源Json操作

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;

namespace v2rayN.Common
namespace ServiceLib.Common
{
internal class YamlUtils
public class YamlUtils
{
#region YAML

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace v2rayN.Enums
namespace ServiceLib.Enums
{
public enum EConfigType
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace v2rayN.Enums
namespace ServiceLib.Enums
{
public enum ECoreType
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace v2rayN.Enums
namespace ServiceLib.Enums
{
public enum EGirdOrientation
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace v2rayN.Enums
namespace ServiceLib.Enums
{
public enum EGlobalHotkey
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace v2rayN.Enums
namespace ServiceLib.Enums
{
public enum EInboundProtocol
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace v2rayN.Enums
namespace ServiceLib.Enums
{
public enum EMove
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace v2rayN.Enums
namespace ServiceLib.Enums
{
public enum ERuleMode
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace v2rayN.Enums
namespace ServiceLib.Enums
{
public enum EServerColName
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace v2rayN.Enums
namespace ServiceLib.Enums
{
public enum ESpeedActionType
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace v2rayN.Enums
namespace ServiceLib.Enums
{
public enum ESysProxyType
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace v2rayN.Enums
namespace ServiceLib.Enums
{
public enum ETransport
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace v2rayN.Enums
namespace ServiceLib.Enums
{
public enum EViewAction
{
Expand Down
36 changes: 17 additions & 19 deletions v2rayN/v2rayN/Global.cs → v2rayN/ServiceLib/Global.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using v2rayN.Enums;

namespace v2rayN
namespace ServiceLib
{
internal class Global
public class Global
{
#region const

Expand Down Expand Up @@ -32,21 +30,21 @@ internal class Global
public const string CoreSpeedtestConfigFileName = "configSpeedtest.json";
public const string CoreMultipleLoadConfigFileName = "configMultipleLoad.json";
public const string ClashMixinConfigFileName = "Mixin.yaml";
public const string V2raySampleClient = "v2rayN.Sample.SampleClientConfig";
public const string SingboxSampleClient = "v2rayN.Sample.SingboxSampleClientConfig";
public const string V2raySampleHttpRequestFileName = "v2rayN.Sample.SampleHttpRequest";
public const string V2raySampleHttpResponseFileName = "v2rayN.Sample.SampleHttpResponse";
public const string V2raySampleInbound = "v2rayN.Sample.SampleInbound";
public const string V2raySampleOutbound = "v2rayN.Sample.SampleOutbound";
public const string SingboxSampleOutbound = "v2rayN.Sample.SingboxSampleOutbound";
public const string CustomRoutingFileName = "v2rayN.Sample.custom_routing_";
public const string TunSingboxDNSFileName = "v2rayN.Sample.tun_singbox_dns";
public const string TunSingboxInboundFileName = "v2rayN.Sample.tun_singbox_inbound";
public const string TunSingboxRulesFileName = "v2rayN.Sample.tun_singbox_rules";
public const string DNSV2rayNormalFileName = "v2rayN.Sample.dns_v2ray_normal";
public const string DNSSingboxNormalFileName = "v2rayN.Sample.dns_singbox_normal";
public const string ClashMixinYaml = "v2rayN.Sample.clash_mixin_yaml";
public const string ClashTunYaml = "v2rayN.Sample.clash_tun_yaml";
public const string V2raySampleClient = "ServiceLib.Sample.SampleClientConfig";
public const string SingboxSampleClient = "ServiceLib.Sample.SingboxSampleClientConfig";
public const string V2raySampleHttpRequestFileName = "ServiceLib.Sample.SampleHttpRequest";
public const string V2raySampleHttpResponseFileName = "ServiceLib.Sample.SampleHttpResponse";
public const string V2raySampleInbound = "ServiceLib.Sample.SampleInbound";
public const string V2raySampleOutbound = "ServiceLib.Sample.SampleOutbound";
public const string SingboxSampleOutbound = "ServiceLib.Sample.SingboxSampleOutbound";
public const string CustomRoutingFileName = "ServiceLib.Sample.custom_routing_";
public const string TunSingboxDNSFileName = "ServiceLib.Sample.tun_singbox_dns";
public const string TunSingboxInboundFileName = "ServiceLib.Sample.tun_singbox_inbound";
public const string TunSingboxRulesFileName = "ServiceLib.Sample.tun_singbox_rules";
public const string DNSV2rayNormalFileName = "ServiceLib.Sample.dns_v2ray_normal";
public const string DNSSingboxNormalFileName = "ServiceLib.Sample.dns_singbox_normal";
public const string ClashMixinYaml = "ServiceLib.Sample.clash_mixin_yaml";
public const string ClashTunYaml = "ServiceLib.Sample.clash_tun_yaml";

public const string DefaultSecurity = "auto";
public const string DefaultNetwork = "tcp";
Expand Down
7 changes: 7 additions & 0 deletions v2rayN/ServiceLib/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using v2rayN.Models;
using static v2rayN.Models.ClashProxies;
using static ServiceLib.Models.ClashProxies;

namespace v2rayN.Handler
namespace ServiceLib.Handler
{
public sealed class ClashApiHandler
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
using System.Data;
using System.IO;
using System.Text.RegularExpressions;
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>
internal class ConfigHandler
public class ConfigHandler
{
private static string configRes = Global.ConfigFileName;
private static readonly object objLock = new();
Expand Down Expand Up @@ -1156,7 +1151,7 @@ public static int AddCustomServer4Multiple(Config config, List<ProfileItem> sele

var profileItem = LazyConfig.Instance.GetProfileItem(indexId) ?? new();
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.configType = EConfigType.Custom;
profileItem.coreType = coreType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
using System.IO;
using v2rayN.Common;
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;

namespace v2rayN.Handler.CoreConfig
namespace ServiceLib.Handler.CoreConfig
{
/// <summary>
/// Core configuration file processing class
/// </summary>
internal class CoreConfigClash
public class CoreConfigClash
{
private Config _config;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
using System.IO;
using v2rayN.Enums;
using v2rayN.Models;
using v2rayN.Resx;

namespace v2rayN.Handler.CoreConfig
namespace ServiceLib.Handler.CoreConfig
{
/// <summary>
/// Core configuration file processing class
/// </summary>
internal class CoreConfigHandler
public class CoreConfigHandler
{
public static int GenerateClientConfig(ProfileItem node, string? fileName, out string msg, out string content)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
using System.Data;
using System.IO;
using System.Net;
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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
using System.Net;
using System.Net.NetworkInformation;
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;

Expand Down
Loading

0 comments on commit 61bea05

Please sign in to comment.