feat: 目前完成了订阅功能和 Xray-Core 的更新管理.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using Proxd_man.Config.Outbound;
|
||||
|
||||
namespace Proxd_man.ShareLink;
|
||||
|
||||
public class ShareLinkParser
|
||||
{
|
||||
|
||||
private static readonly Lazy<List<IShareLinkParser>> parser = new(() => [
|
||||
new ShadowSocksLinkParserV2()
|
||||
]);
|
||||
|
||||
public static BaseOutboundSetting Parse(string shareLink)
|
||||
{
|
||||
foreach (var p in parser.Value.Where(p => p.CanParse(shareLink)))
|
||||
{
|
||||
return p.Parse(shareLink);
|
||||
}
|
||||
|
||||
throw new InvalidShareLinkException("不支持的分享链接: " + shareLink);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public interface IShareLinkParser
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 检查该分享链接是否可以被该实现解析.
|
||||
///
|
||||
/// 该方法只需要检查是否可以解析, 并不需要检查是否正确.
|
||||
/// </summary>
|
||||
/// <param name="shareLink">要尝试解析的出站配置分享链接.</param>
|
||||
/// <returns>如果可以被实现解析, 则返回 true.</returns>
|
||||
bool CanParse(string shareLink);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 将分享链接解析为出站配置.
|
||||
/// </summary>
|
||||
/// <param name="shareLink">要解析的分享链接.</param>
|
||||
/// <returns>返回分享链接解析得出的出站配置.</returns>
|
||||
/// <exception cref="InvalidShareLinkException">当分享链接错误导致无法解析时抛出异常.</exception>
|
||||
BaseOutboundSetting Parse(string shareLink);
|
||||
|
||||
}
|
||||
|
||||
public class InvalidShareLinkException(string message, Exception? cause = null) : Exception(message, cause);
|
||||
Reference in New Issue
Block a user