mirror of
https://github.com/snltty/linker.git
synced 2025-10-06 17:46:59 +08:00
源生成器替代反射
This commit is contained in:
10
.github/workflows/docker.yml
vendored
10
.github/workflows/docker.yml
vendored
@@ -47,19 +47,25 @@ jobs:
|
|||||||
|
|
||||||
- name: create docker image manifest
|
- name: create docker image manifest
|
||||||
run: |
|
run: |
|
||||||
|
docker pull --platform linux/arm/v7 snltty/linker-musl-arm:latest && \
|
||||||
|
docker tag snltty/linker-musl-arm:latest snltty/linker-musl:arm && \
|
||||||
|
docker push snltty/linker-musl:arm && \
|
||||||
docker pull --platform linux/arm64 snltty/linker-musl-arm64:latest && \
|
docker pull --platform linux/arm64 snltty/linker-musl-arm64:latest && \
|
||||||
docker tag snltty/linker-musl-arm64:latest snltty/linker-musl:arm64 && \
|
docker tag snltty/linker-musl-arm64:latest snltty/linker-musl:arm64 && \
|
||||||
docker push snltty/linker-musl:arm64 && \
|
docker push snltty/linker-musl:arm64 && \
|
||||||
docker pull --platform linux/amd64 snltty/linker-musl-x64:latest && \
|
docker pull --platform linux/amd64 snltty/linker-musl-x64:latest && \
|
||||||
docker tag snltty/linker-musl-x64:latest snltty/linker-musl:amd64 && \
|
docker tag snltty/linker-musl-x64:latest snltty/linker-musl:amd64 && \
|
||||||
docker push snltty/linker-musl:amd64 && \
|
docker push snltty/linker-musl:amd64 && \
|
||||||
docker manifest create snltty/linker-musl:latest snltty/linker-musl:amd64 snltty/linker-musl:arm64 && \
|
docker manifest create snltty/linker-musl:latest snltty/linker-musl:amd64 snltty/linker-musl:arm64 snltty/linker-musl:arm && \
|
||||||
docker manifest push snltty/linker-musl:latest && \
|
docker manifest push snltty/linker-musl:latest && \
|
||||||
|
docker pull --platform linux/arm/v7 snltty/linker-debian-arm:latest && \
|
||||||
|
docker tag snltty/linker-debian-arm:latest snltty/linker-debian:arm && \
|
||||||
|
docker push snltty/linker-debian:arm && \
|
||||||
docker pull --platform linux/arm64 snltty/linker-debian-arm64:latest && \
|
docker pull --platform linux/arm64 snltty/linker-debian-arm64:latest && \
|
||||||
docker tag snltty/linker-debian-arm64:latest snltty/linker-debian:arm64 && \
|
docker tag snltty/linker-debian-arm64:latest snltty/linker-debian:arm64 && \
|
||||||
docker push snltty/linker-debian:arm64 && \
|
docker push snltty/linker-debian:arm64 && \
|
||||||
docker pull --platform linux/amd64 snltty/linker-debian-x64:latest && \
|
docker pull --platform linux/amd64 snltty/linker-debian-x64:latest && \
|
||||||
docker tag snltty/linker-debian-x64:latest snltty/linker-debian:amd64 && \
|
docker tag snltty/linker-debian-x64:latest snltty/linker-debian:amd64 && \
|
||||||
docker push snltty/linker-debian:amd64 && \
|
docker push snltty/linker-debian:amd64 && \
|
||||||
docker manifest create snltty/linker-debian:latest snltty/linker-debian:amd64 snltty/linker-debian:arm64 && \
|
docker manifest create snltty/linker-debian:latest snltty/linker-debian:amd64 snltty/linker-debian:arm64 snltty/linker-debian:arm && \
|
||||||
docker manifest push snltty/linker-debian:latest
|
docker manifest push snltty/linker-debian:latest
|
2
.github/workflows/dotnet.yml
vendored
2
.github/workflows/dotnet.yml
vendored
@@ -37,7 +37,7 @@ jobs:
|
|||||||
release_name: v1.4.8.${{ steps.date.outputs.today }}
|
release_name: v1.4.8.${{ steps.date.outputs.today }}
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
body: "1. 优化减少信标流量\r\n2. 增加upnp和NAT-PMP,自动添加端口映射,在无法进路由器时很有用\r\n3. 可选禁用UDP广播,可有效减少中继流量消耗"
|
body: 1. 使用原生成器替代反射
|
||||||
- name: upload-win-x86-oss
|
- name: upload-win-x86-oss
|
||||||
id: upload-win-x86-oss
|
id: upload-win-x86-oss
|
||||||
uses: tvrcgo/oss-action@v0.1.1
|
uses: tvrcgo/oss-action@v0.1.1
|
||||||
|
114
linker.gen/InterfaceSourceGenerator.cs
Normal file
114
linker.gen/InterfaceSourceGenerator.cs
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
|
using Microsoft.CodeAnalysis;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.CodeAnalysis.Text;
|
||||||
|
using System.Text;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace linker.gen
|
||||||
|
{
|
||||||
|
|
||||||
|
[Generator(LanguageNames.CSharp)]
|
||||||
|
public class InterfaceSourceGenerator : IIncrementalGenerator
|
||||||
|
{
|
||||||
|
private List<GeneratorInfo> generators = new List<GeneratorInfo> {
|
||||||
|
new GeneratorInfo{ ClassName="FlowTransfer", ClassNameSpace="linker.plugins.flow", InterfaceName="linker.plugins.flow.IFlow" },
|
||||||
|
new GeneratorInfo{ ClassName="RelayValidatorTransfer", ClassNameSpace="linker.plugins.relay.validator", InterfaceName="linker.plugins.relay.validator.IRelayValidator" },
|
||||||
|
new GeneratorInfo{ ClassName="SignInArgsTransfer", ClassNameSpace="linker.plugins.signIn.args", InterfaceName="linker.plugins.signIn.args.ISignInArgs" },
|
||||||
|
new GeneratorInfo{ ClassName="RelayTransfer", ClassNameSpace="linker.plugins.relay", InterfaceName="linker.plugins.relay.transport.ITransport" },
|
||||||
|
new GeneratorInfo{ ClassName="ResolverTransfer", ClassNameSpace="linker.plugins.resolver", InterfaceName="linker.plugins.resolver.IResolver" },
|
||||||
|
new GeneratorInfo{ ClassName="TunnelExcludeIPTransfer", ClassNameSpace="linker.plugins.tunnel.excludeip", InterfaceName="linker.plugins.tunnel.excludeip.ITunnelExcludeIP" },
|
||||||
|
new GeneratorInfo{ ClassName="StartupTransfer", ClassNameSpace="linker.startup", InterfaceName="linker.startup.IStartup", Instance=true },
|
||||||
|
new GeneratorInfo{ ClassName="MessengerResolverTypes", ClassNameSpace="linker.plugins.messenger", InterfaceName="linker.plugins.messenger.IMessenger"},
|
||||||
|
new GeneratorInfo{ ClassName="ApiClientServer", ClassNameSpace="linker.plugins.capi", InterfaceName="linker.plugins.capi.IApiClientController"},
|
||||||
|
};
|
||||||
|
|
||||||
|
public void Initialize(IncrementalGeneratorInitializationContext context)
|
||||||
|
{
|
||||||
|
IncrementalValueProvider<Compilation> compilations = context.CompilationProvider.Select((compilation, cancellationToken) => compilation);
|
||||||
|
|
||||||
|
context.RegisterSourceOutput(compilations, (sourceProductionContext, compilation) =>
|
||||||
|
{
|
||||||
|
foreach (GeneratorInfo info in generators)
|
||||||
|
{
|
||||||
|
var iFlowSymbol = compilation.GetTypeByMetadataName(info.InterfaceName);
|
||||||
|
List<string> types = new List<string> { };
|
||||||
|
List<string> classs = new List<string> { };
|
||||||
|
List<string> namespaces = new List<string> { };
|
||||||
|
|
||||||
|
foreach (var syntaxTree in compilation.SyntaxTrees)
|
||||||
|
{
|
||||||
|
if (syntaxTree == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var root = syntaxTree.GetRoot(sourceProductionContext.CancellationToken);
|
||||||
|
var classDeclarationSyntaxs = root
|
||||||
|
.DescendantNodes(descendIntoTrivia: false)
|
||||||
|
.OfType<ClassDeclarationSyntax>();
|
||||||
|
|
||||||
|
foreach (var classDeclarationSyntax in classDeclarationSyntaxs)
|
||||||
|
{
|
||||||
|
var model = compilation.GetSemanticModel(classDeclarationSyntax.SyntaxTree);
|
||||||
|
var classSymbol = model.GetDeclaredSymbol(classDeclarationSyntax) as INamedTypeSymbol;
|
||||||
|
if (classSymbol.AllInterfaces.Contains(iFlowSymbol))
|
||||||
|
{
|
||||||
|
types.Add($"typeof({classDeclarationSyntax.Identifier.Text})");
|
||||||
|
|
||||||
|
if (info.Instance)
|
||||||
|
classs.Add($"new {classDeclarationSyntax.Identifier.Text}()");
|
||||||
|
|
||||||
|
var namespaceDecl = classDeclarationSyntax.FirstAncestorOrSelf<NamespaceDeclarationSyntax>();
|
||||||
|
if (namespaceDecl != null)
|
||||||
|
{
|
||||||
|
namespaces.Add($"using {namespaceDecl.Name.ToString()};");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var source = $@"
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
{string.Join("\r\n", namespaces)}
|
||||||
|
|
||||||
|
namespace {info.ClassNameSpace}
|
||||||
|
{{
|
||||||
|
public partial class {info.ClassName}
|
||||||
|
{{
|
||||||
|
public static List<Type> GetSourceGeneratorTypes()
|
||||||
|
{{
|
||||||
|
return new List<Type> {{
|
||||||
|
{string.Join(",", types)}
|
||||||
|
}};
|
||||||
|
}}
|
||||||
|
public static List<{info.InterfaceName}> GetSourceGeneratorInstances()
|
||||||
|
{{
|
||||||
|
return new List<{info.InterfaceName}> {{
|
||||||
|
{string.Join(",", classs)}
|
||||||
|
}};
|
||||||
|
}}
|
||||||
|
}}
|
||||||
|
}}";
|
||||||
|
|
||||||
|
var sourceText = SourceText.From(source, Encoding.UTF8);
|
||||||
|
sourceProductionContext.AddSource($"{info.ClassName}Instances.g.cs", sourceText);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public sealed class GeneratorInfo
|
||||||
|
{
|
||||||
|
public string ClassName { get; set; }
|
||||||
|
public string ClassNameSpace { get; set; }
|
||||||
|
public string InterfaceName { get; set; }
|
||||||
|
public bool Instance { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
14
linker.gen/Properties/PublishProfiles/FolderProfile.pubxml
Normal file
14
linker.gen/Properties/PublishProfiles/FolderProfile.pubxml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||||
|
-->
|
||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Any CPU</Platform>
|
||||||
|
<PublishDir>bin\Release\publish\</PublishDir>
|
||||||
|
<PublishProtocol>FileSystem</PublishProtocol>
|
||||||
|
<_TargetId>Folder</_TargetId>
|
||||||
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||||
|
-->
|
||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<History>True|2024-10-10T09:23:14.3539248Z||;</History>
|
||||||
|
<LastFailureDetails />
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
21
linker.gen/linker.gen.csproj
Normal file
21
linker.gen/linker.gen.csproj
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
|
<AnalyzerLanguage>cs</AnalyzerLanguage>
|
||||||
|
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
|
||||||
|
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||||
|
<IsRoslynComponent>true</IsRoslynComponent>
|
||||||
|
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
|
||||||
|
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
||||||
|
<IncludeBuildOutput>false</IncludeBuildOutput>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.3.0" PrivateAssets="all" />
|
||||||
|
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
6
linker.gen/linker.gen.csproj.user
Normal file
6
linker.gen/linker.gen.csproj.user
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<_LastSelectedProfileId>C:\Users\snltty\Desktop\linker\linker.gen\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
@@ -1,32 +1,17 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace linker.libs
|
namespace linker.libs
|
||||||
{
|
{
|
||||||
public sealed class ReflectionHelper
|
public sealed class ReflectionHelper
|
||||||
{
|
{
|
||||||
public static IEnumerable<Type> GetInterfaceSchieves(Type type)
|
/*
|
||||||
{
|
|
||||||
return GetInterfaceSchieves(AppDomain.CurrentDomain.GetAssemblies(), type);
|
|
||||||
}
|
|
||||||
public static IEnumerable<Type> GetInterfaceSchieves(Assembly[] assemblys, Type type)
|
public static IEnumerable<Type> GetInterfaceSchieves(Assembly[] assemblys, Type type)
|
||||||
{
|
{
|
||||||
return assemblys.SelectMany(c => c.GetTypes())
|
return assemblys.SelectMany(c => c.GetTypes())
|
||||||
.Where(c => !c.IsAbstract).Where(c => c.GetInterfaces().Contains(type));
|
.Where(c => !c.IsAbstract).Where(c => c.GetInterfaces().Contains(type));
|
||||||
}
|
}
|
||||||
public static IEnumerable<Type> GetSubClass(Assembly[] assemblys, Type type)
|
*/
|
||||||
{
|
|
||||||
return assemblys.SelectMany(c => c.GetTypes())
|
|
||||||
.Where(c => !c.IsAbstract).Where(c => c.IsSubclassOf(type));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static IEnumerable<Type> GetEnums(Assembly[] assemblys)
|
|
||||||
{
|
|
||||||
return assemblys.SelectMany(c => c.GetTypes())
|
|
||||||
.Where(c => c.IsEnum);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Net.Sockets;
|
|
||||||
using System.Net;
|
|
||||||
using System.Reflection.Metadata;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace linker.libs.winapis;
|
namespace linker.libs.winapis;
|
||||||
|
14
linker.sln
14
linker.sln
@@ -15,6 +15,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "linker.tun", "linker.tun\li
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "linker.tun.test", "linker.tun.test\linker.tun.test.csproj", "{4A660D3B-76DE-4E6F-9E90-90BA0DBE906A}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "linker.tun.test", "linker.tun.test\linker.tun.test.csproj", "{4A660D3B-76DE-4E6F-9E90-90BA0DBE906A}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "linker.gen", "linker.gen\linker.gen.csproj", "{031C3589-72BB-4A3F-B1A5-BC0665FDF01B}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -97,6 +99,18 @@ Global
|
|||||||
{4A660D3B-76DE-4E6F-9E90-90BA0DBE906A}.Release|x64.Build.0 = Release|Any CPU
|
{4A660D3B-76DE-4E6F-9E90-90BA0DBE906A}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{4A660D3B-76DE-4E6F-9E90-90BA0DBE906A}.Release|x86.ActiveCfg = Release|Any CPU
|
{4A660D3B-76DE-4E6F-9E90-90BA0DBE906A}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{4A660D3B-76DE-4E6F-9E90-90BA0DBE906A}.Release|x86.Build.0 = Release|Any CPU
|
{4A660D3B-76DE-4E6F-9E90-90BA0DBE906A}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{031C3589-72BB-4A3F-B1A5-BC0665FDF01B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{031C3589-72BB-4A3F-B1A5-BC0665FDF01B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{031C3589-72BB-4A3F-B1A5-BC0665FDF01B}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{031C3589-72BB-4A3F-B1A5-BC0665FDF01B}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{031C3589-72BB-4A3F-B1A5-BC0665FDF01B}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{031C3589-72BB-4A3F-B1A5-BC0665FDF01B}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{031C3589-72BB-4A3F-B1A5-BC0665FDF01B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{031C3589-72BB-4A3F-B1A5-BC0665FDF01B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{031C3589-72BB-4A3F-B1A5-BC0665FDF01B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{031C3589-72BB-4A3F-B1A5-BC0665FDF01B}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{031C3589-72BB-4A3F-B1A5-BC0665FDF01B}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{031C3589-72BB-4A3F-B1A5-BC0665FDF01B}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@@ -45,7 +45,7 @@ namespace linker.tun
|
|||||||
adapter = WinTun.WintunCreateAdapter(name, name, ref guid);
|
adapter = WinTun.WintunCreateAdapter(name, name, ref guid);
|
||||||
if (adapter == 0)
|
if (adapter == 0)
|
||||||
{
|
{
|
||||||
error = ($"Failed to create adapter {Marshal.GetLastWin32Error():x2}");
|
error = ($"Failed to create adapter {Marshal.GetLastWin32Error()}");
|
||||||
Shutdown();
|
Shutdown();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,7 @@ namespace linker.tun
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
error = ($"Failed to set adapter ip {Marshal.GetLastWin32Error():x2}");
|
error = ($"Failed to set adapter ip {Marshal.GetLastWin32Error()}");
|
||||||
Shutdown();
|
Shutdown();
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@@ -129,6 +129,7 @@ namespace linker.tunnel.transport
|
|||||||
|
|
||||||
public sealed partial class TunnelTransportItemInfo
|
public sealed partial class TunnelTransportItemInfo
|
||||||
{
|
{
|
||||||
|
public TunnelTransportItemInfo() { }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 协议名称
|
/// 协议名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@@ -33,6 +33,7 @@ namespace linker.tunnel.wanport
|
|||||||
|
|
||||||
public sealed partial class TunnelWanPortInfo
|
public sealed partial class TunnelWanPortInfo
|
||||||
{
|
{
|
||||||
|
public TunnelWanPortInfo() { }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 名称
|
/// 名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
using linker.libs;
|
using linker.libs;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Reflection;
|
|
||||||
using linker.startup;
|
using linker.startup;
|
||||||
using linker.config;
|
using linker.config;
|
||||||
using System.ServiceProcess;
|
using System.ServiceProcess;
|
||||||
@@ -47,8 +46,7 @@ namespace linker
|
|||||||
LoggerHelper.Instance.Warning($"linker env is docker : {Environment.GetEnvironmentVariable("SNLTTY_LINKER_IS_DOCKER")}");
|
LoggerHelper.Instance.Warning($"linker env is docker : {Environment.GetEnvironmentVariable("SNLTTY_LINKER_IS_DOCKER")}");
|
||||||
LoggerHelper.Instance.Warning($"linker env os : {System.Runtime.InteropServices.RuntimeInformation.OSDescription}");
|
LoggerHelper.Instance.Warning($"linker env os : {System.Runtime.InteropServices.RuntimeInformation.OSDescription}");
|
||||||
|
|
||||||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
StartupTransfer.Init(config);
|
||||||
StartupTransfer.Init(config, assemblies);
|
|
||||||
|
|
||||||
//依赖注入
|
//依赖注入
|
||||||
ServiceProvider serviceProvider = null;
|
ServiceProvider serviceProvider = null;
|
||||||
@@ -56,11 +54,11 @@ namespace linker
|
|||||||
//注入
|
//注入
|
||||||
serviceCollection.AddSingleton((e) => serviceProvider);
|
serviceCollection.AddSingleton((e) => serviceProvider);
|
||||||
serviceCollection.AddSingleton((a) => config);
|
serviceCollection.AddSingleton((a) => config);
|
||||||
StartupTransfer.Add(serviceCollection, config, assemblies);
|
StartupTransfer.Add(serviceCollection, config);
|
||||||
|
|
||||||
//运行
|
//运行
|
||||||
serviceProvider = serviceCollection.BuildServiceProvider();
|
serviceProvider = serviceCollection.BuildServiceProvider();
|
||||||
StartupTransfer.Use(serviceProvider, config, assemblies);
|
StartupTransfer.Use(serviceProvider, config);
|
||||||
|
|
||||||
GCHelper.FlushMemory();
|
GCHelper.FlushMemory();
|
||||||
}
|
}
|
||||||
|
@@ -10,9 +10,10 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||||||
<PublishProtocol>FileSystem</PublishProtocol>
|
<PublishProtocol>FileSystem</PublishProtocol>
|
||||||
<_TargetId>Folder</_TargetId>
|
<_TargetId>Folder</_TargetId>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<SelfContained>false</SelfContained>
|
<SelfContained>true</SelfContained>
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
<PublishSingleFile>true</PublishSingleFile>
|
<PublishSingleFile>true</PublishSingleFile>
|
||||||
<PublishReadyToRun>false</PublishReadyToRun>
|
<PublishReadyToRun>false</PublishReadyToRun>
|
||||||
|
<PublishTrimmed>true</PublishTrimmed>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
@@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||||||
-->
|
-->
|
||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<History>True|2024-08-23T02:51:58.4468622Z||;True|2024-08-23T10:50:24.9490093+08:00||;True|2024-08-23T10:47:22.7180336+08:00||;True|2024-08-23T10:44:58.5670901+08:00||;True|2024-08-23T10:43:21.8874172+08:00||;True|2024-08-23T10:42:36.6889366+08:00||;True|2024-08-23T10:41:53.5656929+08:00||;True|2024-08-23T10:41:48.6036362+08:00||;True|2024-08-23T10:40:09.3649807+08:00||;True|2024-08-23T10:39:32.4793121+08:00||;False|2024-08-23T10:39:19.4117931+08:00||;True|2024-08-23T10:35:42.9767722+08:00||;True|2024-08-23T10:35:00.2434227+08:00||;True|2024-08-23T10:33:52.2828327+08:00||;True|2024-08-23T10:32:48.1055213+08:00||;True|2024-08-23T10:30:54.0109448+08:00||;True|2024-08-23T10:27:57.3877299+08:00||;True|2024-08-23T10:27:54.0431848+08:00||;True|2024-08-23T10:27:30.2617469+08:00||;True|2024-08-23T10:24:27.5920712+08:00||;True|2024-08-23T10:21:09.9703353+08:00||;True|2024-08-23T10:18:55.2035793+08:00||;True|2024-08-23T10:18:34.9805916+08:00||;True|2024-08-23T10:18:20.6676415+08:00||;True|2024-08-23T10:17:38.1634986+08:00||;True|2024-08-23T10:16:28.1682988+08:00||;True|2024-08-23T10:00:48.4543408+08:00||;True|2024-08-23T09:55:05.4757944+08:00||;False|2024-08-23T09:54:27.3467579+08:00||;True|2024-08-23T09:50:36.2439630+08:00||;False|2024-08-23T09:50:11.6253822+08:00||;False|2024-08-23T09:49:56.1119041+08:00||;False|2024-08-23T09:49:41.8313525+08:00||;True|2024-08-23T09:47:09.0982192+08:00||;True|2024-08-23T09:46:12.1445883+08:00||;True|2024-07-01T17:25:46.1203574+08:00||;True|2024-06-02T15:39:16.1880914+08:00||;True|2024-06-02T15:38:26.4314913+08:00||;True|2024-06-02T15:27:20.2651650+08:00||;True|2024-06-02T15:26:34.3414728+08:00||;True|2024-06-02T15:22:33.1407820+08:00||;True|2024-06-02T15:22:01.4381533+08:00||;True|2024-06-02T15:20:29.6692030+08:00||;True|2024-06-02T15:19:55.9152032+08:00||;True|2024-06-02T15:16:15.2278365+08:00||;True|2024-04-23T09:09:03.5136215+08:00||;True|2024-04-22T12:57:38.4988098+08:00||;True|2023-12-23T09:50:45.7841097+08:00||;True|2023-11-17T09:24:26.3650754+08:00||;True|2023-11-17T09:11:28.0867966+08:00||;True|2023-11-17T09:09:49.7366925+08:00||;False|2023-11-17T09:08:56.6254247+08:00||;False|2023-11-17T09:08:45.4560896+08:00||;True|2023-11-16T11:49:56.3722044+08:00||;True|2023-11-16T11:48:06.3192199+08:00||;True|2023-11-16T11:47:35.3708397+08:00||;True|2023-11-16T11:45:11.0208634+08:00||;False|2023-11-16T11:44:01.7611210+08:00||;True|2023-10-01T17:27:31.0065885+08:00||;True|2023-09-04T18:19:54.7492652+08:00||;True|2023-09-04T18:19:32.2969345+08:00||;False|2023-09-04T18:18:51.7827366+08:00||;True|2023-09-04T18:15:31.6783417+08:00||;True|2023-09-04T18:14:40.9964104+08:00||;</History>
|
<History>False|2024-10-10T14:16:16.3110909Z||;False|2024-10-10T22:11:21.0881724+08:00||;False|2024-10-10T22:09:10.1989910+08:00||;False|2024-10-10T21:50:21.7296489+08:00||;False|2024-10-10T21:47:58.4483180+08:00||;False|2024-10-10T21:45:03.8865649+08:00||;False|2024-10-10T17:35:43.5322585+08:00||;False|2024-10-10T17:26:43.3077023+08:00||;True|2024-10-10T17:26:30.3061770+08:00||;True|2024-10-10T17:19:53.7202305+08:00||;False|2024-10-10T17:19:30.0472147+08:00||;False|2024-10-10T17:09:11.5458248+08:00||;False|2024-10-10T17:05:01.9807383+08:00||;False|2024-10-10T16:32:47.9197855+08:00||;False|2024-10-10T16:27:33.3843344+08:00||;False|2024-10-10T16:17:45.5400935+08:00||;False|2024-10-10T16:16:00.7310907+08:00||;False|2024-10-10T16:11:16.4527258+08:00||;False|2024-10-10T16:01:49.3234495+08:00||;False|2024-10-10T16:00:52.7042699+08:00||;False|2024-10-10T15:58:26.2250525+08:00||;False|2024-10-10T15:29:21.2118650+08:00||;False|2024-10-10T15:27:57.3759612+08:00||;False|2024-10-10T15:26:24.8835185+08:00||;False|2024-10-10T15:24:48.1428403+08:00||;False|2024-10-10T15:23:40.7151355+08:00||;False|2024-10-10T15:23:27.3693403+08:00||;False|2024-10-10T15:22:30.7759285+08:00||;False|2024-10-10T15:20:07.4952154+08:00||;False|2024-10-10T15:14:25.2072081+08:00||;False|2024-10-10T15:06:41.7786909+08:00||;False|2024-10-10T15:05:22.2113720+08:00||;False|2024-10-10T15:00:57.3305970+08:00||;False|2024-10-10T15:00:48.3682184+08:00||;False|2024-10-10T14:59:37.0795714+08:00||;False|2024-10-10T14:56:38.0161474+08:00||;False|2024-10-10T14:54:00.5195838+08:00||;True|2024-10-10T11:44:31.3807621+08:00||;True|2024-10-10T11:42:10.9702062+08:00||;True|2024-10-10T11:38:58.4038620+08:00||;True|2024-10-10T11:34:46.6640510+08:00||;True|2024-10-10T11:31:11.4793243+08:00||;True|2024-10-10T11:29:18.5541962+08:00||;False|2024-10-10T11:28:45.6627606+08:00||;True|2024-08-23T10:51:58.4468622+08:00||;True|2024-08-23T10:50:24.9490093+08:00||;True|2024-08-23T10:47:22.7180336+08:00||;True|2024-08-23T10:44:58.5670901+08:00||;True|2024-08-23T10:43:21.8874172+08:00||;True|2024-08-23T10:42:36.6889366+08:00||;True|2024-08-23T10:41:53.5656929+08:00||;True|2024-08-23T10:41:48.6036362+08:00||;True|2024-08-23T10:40:09.3649807+08:00||;True|2024-08-23T10:39:32.4793121+08:00||;False|2024-08-23T10:39:19.4117931+08:00||;True|2024-08-23T10:35:42.9767722+08:00||;True|2024-08-23T10:35:00.2434227+08:00||;True|2024-08-23T10:33:52.2828327+08:00||;True|2024-08-23T10:32:48.1055213+08:00||;True|2024-08-23T10:30:54.0109448+08:00||;True|2024-08-23T10:27:57.3877299+08:00||;True|2024-08-23T10:27:54.0431848+08:00||;True|2024-08-23T10:27:30.2617469+08:00||;True|2024-08-23T10:24:27.5920712+08:00||;True|2024-08-23T10:21:09.9703353+08:00||;True|2024-08-23T10:18:55.2035793+08:00||;True|2024-08-23T10:18:34.9805916+08:00||;True|2024-08-23T10:18:20.6676415+08:00||;True|2024-08-23T10:17:38.1634986+08:00||;True|2024-08-23T10:16:28.1682988+08:00||;True|2024-08-23T10:00:48.4543408+08:00||;True|2024-08-23T09:55:05.4757944+08:00||;False|2024-08-23T09:54:27.3467579+08:00||;True|2024-08-23T09:50:36.2439630+08:00||;False|2024-08-23T09:50:11.6253822+08:00||;False|2024-08-23T09:49:56.1119041+08:00||;False|2024-08-23T09:49:41.8313525+08:00||;True|2024-08-23T09:47:09.0982192+08:00||;True|2024-08-23T09:46:12.1445883+08:00||;True|2024-07-01T17:25:46.1203574+08:00||;True|2024-06-02T15:39:16.1880914+08:00||;True|2024-06-02T15:38:26.4314913+08:00||;True|2024-06-02T15:27:20.2651650+08:00||;True|2024-06-02T15:26:34.3414728+08:00||;True|2024-06-02T15:22:33.1407820+08:00||;True|2024-06-02T15:22:01.4381533+08:00||;True|2024-06-02T15:20:29.6692030+08:00||;True|2024-06-02T15:19:55.9152032+08:00||;True|2024-06-02T15:16:15.2278365+08:00||;True|2024-04-23T09:09:03.5136215+08:00||;True|2024-04-22T12:57:38.4988098+08:00||;True|2023-12-23T09:50:45.7841097+08:00||;True|2023-11-17T09:24:26.3650754+08:00||;True|2023-11-17T09:11:28.0867966+08:00||;True|2023-11-17T09:09:49.7366925+08:00||;False|2023-11-17T09:08:56.6254247+08:00||;False|2023-11-17T09:08:45.4560896+08:00||;True|2023-11-16T11:49:56.3722044+08:00||;True|2023-11-16T11:48:06.3192199+08:00||;True|2023-11-16T11:47:35.3708397+08:00||;</History>
|
||||||
<LastFailureDetails />
|
<LastFailureDetails />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
@@ -133,6 +133,7 @@ namespace linker.config
|
|||||||
}
|
}
|
||||||
public sealed partial class ConfigInfo
|
public sealed partial class ConfigInfo
|
||||||
{
|
{
|
||||||
|
public ConfigInfo() { }
|
||||||
public ConfigCommonInfo Common { get; set; } = new ConfigCommonInfo();
|
public ConfigCommonInfo Common { get; set; } = new ConfigCommonInfo();
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
@@ -153,6 +154,7 @@ namespace linker.config
|
|||||||
|
|
||||||
public sealed partial class ConfigCommonInfo : IConfig
|
public sealed partial class ConfigCommonInfo : IConfig
|
||||||
{
|
{
|
||||||
|
public ConfigCommonInfo() { }
|
||||||
public string[] Modes { get; set; } = new string[] { "client", "server" };
|
public string[] Modes { get; set; } = new string[] { "client", "server" };
|
||||||
|
|
||||||
|
|
||||||
|
BIN
linker/libmsquic-musl-arm.so
Normal file
BIN
linker/libmsquic-musl-arm.so
Normal file
Binary file not shown.
@@ -19,9 +19,7 @@
|
|||||||
<Title>linker</Title>
|
<Title>linker</Title>
|
||||||
<Authors>snltty</Authors>
|
<Authors>snltty</Authors>
|
||||||
<Company>snltty</Company>
|
<Company>snltty</Company>
|
||||||
<Description>1. 优化减少信标流量
|
<Description>1. 使用原生成器替代反射</Description>
|
||||||
2. 增加upnp和NAT-PMP,自动添加端口映射,在无法进路由器时很有用
|
|
||||||
3. 可选禁用UDP广播,可有效减少中继流量消耗</Description>
|
|
||||||
<Copyright>snltty</Copyright>
|
<Copyright>snltty</Copyright>
|
||||||
<PackageProjectUrl>https://github.com/snltty/linker</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/snltty/linker</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://github.com/snltty/linker</RepositoryUrl>
|
<RepositoryUrl>https://github.com/snltty/linker</RepositoryUrl>
|
||||||
@@ -57,6 +55,11 @@
|
|||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\linker.gen\linker.gen.csproj">
|
||||||
|
<OutputItemType>Analyzer</OutputItemType>
|
||||||
|
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||||
|
<IsTrimmable>false</IsTrimmable>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\linker.tunnel\linker.tunnel.csproj" />
|
<ProjectReference Include="..\linker.tunnel\linker.tunnel.csproj" />
|
||||||
<ProjectReference Include="..\linker.libs\linker.libs.csproj" />
|
<ProjectReference Include="..\linker.libs\linker.libs.csproj" />
|
||||||
<ProjectReference Include="..\linker.tun\linker.tun.csproj" />
|
<ProjectReference Include="..\linker.tun\linker.tun.csproj" />
|
||||||
@@ -64,7 +67,6 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="LiteDB" Version="5.0.17" />
|
<PackageReference Include="LiteDB" Version="5.0.17" />
|
||||||
<PackageReference Include="MemoryPack" Version="1.10.0" />
|
<PackageReference Include="MemoryPack" Version="1.10.0" />
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0-2.final" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||||
<PackageReference Include="System.ServiceProcess.ServiceController" Version="8.0.0" />
|
<PackageReference Include="System.ServiceProcess.ServiceController" Version="8.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@@ -2,7 +2,6 @@
|
|||||||
using linker.plugins.action;
|
using linker.plugins.action;
|
||||||
using linker.startup;
|
using linker.startup;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace linker.plugins.signin
|
namespace linker.plugins.signin
|
||||||
{
|
{
|
||||||
@@ -18,7 +17,7 @@ namespace linker.plugins.signin
|
|||||||
public StartupLoadType LoadType => StartupLoadType.Normal;
|
public StartupLoadType LoadType => StartupLoadType.Normal;
|
||||||
|
|
||||||
|
|
||||||
public void AddClient(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddClient(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
serviceCollection.AddSingleton<ActionApiController>();
|
serviceCollection.AddSingleton<ActionApiController>();
|
||||||
serviceCollection.AddSingleton<ActionTransfer>();
|
serviceCollection.AddSingleton<ActionTransfer>();
|
||||||
@@ -28,7 +27,7 @@ namespace linker.plugins.signin
|
|||||||
serviceCollection.AddSingleton<SForwardValidatorAction>();
|
serviceCollection.AddSingleton<SForwardValidatorAction>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddServer(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddServer(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
serviceCollection.AddSingleton<ActionTransfer>();
|
serviceCollection.AddSingleton<ActionTransfer>();
|
||||||
|
|
||||||
@@ -38,11 +37,11 @@ namespace linker.plugins.signin
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseClient(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseClient(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseServer(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseServer(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -214,7 +214,7 @@ namespace linker.plugins.action
|
|||||||
{
|
{
|
||||||
if (actionTransfer.TryGetActionArg(cache.Args, out string str, out string machineKey) == false)
|
if (actionTransfer.TryGetActionArg(cache.Args, out string str, out string machineKey) == false)
|
||||||
{
|
{
|
||||||
return "sforward action URL exists, but action value is not configured";
|
return $"sforward action URL exists, but [{cache.MachineName}] action value is not configured";
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonArgInfo replace = new JsonArgInfo
|
JsonArgInfo replace = new JsonArgInfo
|
||||||
|
@@ -8,6 +8,7 @@ namespace linker.config
|
|||||||
}
|
}
|
||||||
public sealed partial class ConfigActionInfo : IConfig
|
public sealed partial class ConfigActionInfo : IConfig
|
||||||
{
|
{
|
||||||
|
public ConfigActionInfo() { }
|
||||||
public string SignInActionUrl { get; set; } = string.Empty;
|
public string SignInActionUrl { get; set; } = string.Empty;
|
||||||
public string RelayActionUrl { get; set; } = string.Empty;
|
public string RelayActionUrl { get; set; } = string.Empty;
|
||||||
public string SForwardActionUrl { get; set; } = string.Empty;
|
public string SForwardActionUrl { get; set; } = string.Empty;
|
||||||
|
@@ -9,7 +9,7 @@ namespace linker.plugins.capi
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 前段接口服务
|
/// 前段接口服务
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class ApiClientServer : ApiServer, IApiClientServer
|
public sealed partial class ApiClientServer : ApiServer, IApiClientServer
|
||||||
{
|
{
|
||||||
private readonly ServiceProvider serviceProvider;
|
private readonly ServiceProvider serviceProvider;
|
||||||
private readonly FileConfig config;
|
private readonly FileConfig config;
|
||||||
@@ -18,17 +18,18 @@ namespace linker.plugins.capi
|
|||||||
{
|
{
|
||||||
this.serviceProvider = serviceProvider;
|
this.serviceProvider = serviceProvider;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
||||||
|
LoadPlugins();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载插件
|
/// 加载插件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assemblys"></param>
|
private void LoadPlugins()
|
||||||
public void LoadPlugins(Assembly[] assemblys)
|
|
||||||
{
|
{
|
||||||
Type voidType = typeof(void);
|
Type voidType = typeof(void);
|
||||||
|
|
||||||
IEnumerable<Type> types = assemblys.SelectMany(c => c.GetTypes()).Where(c => c.GetInterfaces().Contains(typeof(IApiClientController)));
|
IEnumerable<Type> types = GetSourceGeneratorTypes();
|
||||||
|
|
||||||
foreach (Type item in types)
|
foreach (Type item in types)
|
||||||
{
|
{
|
||||||
|
@@ -2,7 +2,6 @@
|
|||||||
using linker.startup;
|
using linker.startup;
|
||||||
using linker.libs;
|
using linker.libs;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace linker.plugins.capi
|
namespace linker.plugins.capi
|
||||||
{
|
{
|
||||||
@@ -14,19 +13,18 @@ namespace linker.plugins.capi
|
|||||||
public string[] Dependent => new string[] { };
|
public string[] Dependent => new string[] { };
|
||||||
public StartupLoadType LoadType => StartupLoadType.Normal;
|
public StartupLoadType LoadType => StartupLoadType.Normal;
|
||||||
|
|
||||||
public void AddClient(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddClient(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
serviceCollection.AddSingleton<IApiClientServer, ApiClientServer>();
|
serviceCollection.AddSingleton<IApiClientServer, ApiClientServer>();
|
||||||
serviceCollection.AddSingleton<IWebClientServer, WebClientServer>();
|
serviceCollection.AddSingleton<IWebClientServer, WebClientServer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseClient(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseClient(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
if (config.Data.Client.CApi.ApiPort > 0)
|
if (config.Data.Client.CApi.ApiPort > 0)
|
||||||
{
|
{
|
||||||
LoggerHelper.Instance.Info($"start client api server");
|
LoggerHelper.Instance.Info($"start client api server");
|
||||||
IApiClientServer clientServer = serviceProvider.GetService<IApiClientServer>();
|
IApiClientServer clientServer = serviceProvider.GetService<IApiClientServer>();
|
||||||
clientServer.LoadPlugins(assemblies);
|
|
||||||
clientServer.Websocket(config.Data.Client.CApi.ApiPort, config.Data.Client.CApi.ApiPassword);
|
clientServer.Websocket(config.Data.Client.CApi.ApiPort, config.Data.Client.CApi.ApiPassword);
|
||||||
LoggerHelper.Instance.Warning($"client api listen:{config.Data.Client.CApi.ApiPort}");
|
LoggerHelper.Instance.Warning($"client api listen:{config.Data.Client.CApi.ApiPort}");
|
||||||
if (config.Data.Client.HasAccess(ClientApiAccess.Api))
|
if (config.Data.Client.HasAccess(ClientApiAccess.Api))
|
||||||
@@ -42,11 +40,11 @@ namespace linker.plugins.capi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void AddServer(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddServer(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
public void UseServer(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseServer(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using linker.libs.api;
|
using linker.libs.api;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace linker.plugins.capi
|
namespace linker.plugins.capi
|
||||||
{
|
{
|
||||||
@@ -10,7 +9,6 @@ namespace linker.plugins.capi
|
|||||||
|
|
||||||
public interface IApiClientServer : IApiServer
|
public interface IApiClientServer : IApiServer
|
||||||
{
|
{
|
||||||
public void LoadPlugins(Assembly[] assemblys);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
using linker.libs;
|
using linker.libs;
|
||||||
using linker.startup;
|
using linker.startup;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Reflection;
|
|
||||||
using linker.config;
|
using linker.config;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using linker.libs.extends;
|
using linker.libs.extends;
|
||||||
@@ -19,7 +18,7 @@ namespace linker.plugins.client
|
|||||||
public string[] Dependent => new string[] { "messenger", "firewall", "signin", "serialize", "config" };
|
public string[] Dependent => new string[] { "messenger", "firewall", "signin", "serialize", "config" };
|
||||||
public StartupLoadType LoadType => StartupLoadType.Normal;
|
public StartupLoadType LoadType => StartupLoadType.Normal;
|
||||||
|
|
||||||
public void AddClient(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddClient(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(config.Data.Client.Name))
|
if (string.IsNullOrWhiteSpace(config.Data.Client.Name))
|
||||||
{
|
{
|
||||||
@@ -33,7 +32,7 @@ namespace linker.plugins.client
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseClient(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseClient(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
LoggerHelper.Instance.Info($"start client");
|
LoggerHelper.Instance.Info($"start client");
|
||||||
|
|
||||||
@@ -43,11 +42,11 @@ namespace linker.plugins.client
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void AddServer(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddServer(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
serviceCollection.AddSingleton<SignInArgsSecretKeyServer>();
|
serviceCollection.AddSingleton<SignInArgsSecretKeyServer>();
|
||||||
}
|
}
|
||||||
public void UseServer(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseServer(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,8 @@ namespace linker.client.config
|
|||||||
|
|
||||||
public sealed class ClientRunningInfo
|
public sealed class ClientRunningInfo
|
||||||
{
|
{
|
||||||
|
public ClientRunningInfo() { }
|
||||||
|
|
||||||
public ObjectId Id { get; set; }
|
public ObjectId Id { get; set; }
|
||||||
public ClientServerInfo[] Servers { get; set; } = [];
|
public ClientServerInfo[] Servers { get; set; } = [];
|
||||||
}
|
}
|
||||||
@@ -153,6 +155,7 @@ namespace linker.config
|
|||||||
[MemoryPackable]
|
[MemoryPackable]
|
||||||
public sealed partial class ClientServerInfo
|
public sealed partial class ClientServerInfo
|
||||||
{
|
{
|
||||||
|
public ClientServerInfo() { }
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
public string Host { get; set; } = string.Empty;
|
public string Host { get; set; } = string.Empty;
|
||||||
public string SecretKey { get; set; } = string.Empty;
|
public string SecretKey { get; set; } = string.Empty;
|
||||||
|
@@ -3,7 +3,6 @@ using linker.config;
|
|||||||
using linker.plugins.config.messenger;
|
using linker.plugins.config.messenger;
|
||||||
using linker.startup;
|
using linker.startup;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace linker.plugins.config
|
namespace linker.plugins.config
|
||||||
{
|
{
|
||||||
@@ -19,7 +18,7 @@ namespace linker.plugins.config
|
|||||||
|
|
||||||
public StartupLoadType LoadType => StartupLoadType.Normal;
|
public StartupLoadType LoadType => StartupLoadType.Normal;
|
||||||
|
|
||||||
public void AddClient(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddClient(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
serviceCollection.AddSingleton<ConfigClientApiController>();
|
serviceCollection.AddSingleton<ConfigClientApiController>();
|
||||||
|
|
||||||
@@ -31,17 +30,17 @@ namespace linker.plugins.config
|
|||||||
serviceCollection.AddSingleton<AccessTransfer>();
|
serviceCollection.AddSingleton<AccessTransfer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddServer(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddServer(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
serviceCollection.AddSingleton<ConfigServerMessenger>();
|
serviceCollection.AddSingleton<ConfigServerMessenger>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseClient(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseClient(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
RunningConfig runningConfig = serviceProvider.GetService<RunningConfig>();
|
RunningConfig runningConfig = serviceProvider.GetService<RunningConfig>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseServer(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseServer(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -147,6 +147,8 @@ namespace linker.client.config
|
|||||||
|
|
||||||
public sealed partial class RunningConfigInfo
|
public sealed partial class RunningConfigInfo
|
||||||
{
|
{
|
||||||
|
public RunningConfigInfo() { }
|
||||||
|
|
||||||
public ObjectId Id { get; set; }
|
public ObjectId Id { get; set; }
|
||||||
|
|
||||||
[JsonIgnore, BsonIgnore]
|
[JsonIgnore, BsonIgnore]
|
||||||
@@ -164,6 +166,7 @@ namespace linker.client.config
|
|||||||
[MemoryPackable]
|
[MemoryPackable]
|
||||||
public sealed partial class SecretKeyAsyncInfo
|
public sealed partial class SecretKeyAsyncInfo
|
||||||
{
|
{
|
||||||
|
public SecretKeyAsyncInfo() { }
|
||||||
public string SignSecretKey { get; set; }
|
public string SignSecretKey { get; set; }
|
||||||
public string RelaySecretKey { get; set; }
|
public string RelaySecretKey { get; set; }
|
||||||
public string SForwardSecretKey { get; set; }
|
public string SForwardSecretKey { get; set; }
|
||||||
@@ -172,6 +175,7 @@ namespace linker.client.config
|
|||||||
[MemoryPackable]
|
[MemoryPackable]
|
||||||
public sealed partial class ServerAsyncInfo
|
public sealed partial class ServerAsyncInfo
|
||||||
{
|
{
|
||||||
|
public ServerAsyncInfo() { }
|
||||||
public ClientServerInfo[] SignServers { get; set; }
|
public ClientServerInfo[] SignServers { get; set; }
|
||||||
public RelayServerInfo[] RelayServers { get; set; }
|
public RelayServerInfo[] RelayServers { get; set; }
|
||||||
public TunnelWanPortInfo[] TunnelServers { get; set; }
|
public TunnelWanPortInfo[] TunnelServers { get; set; }
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
using linker.client.config;
|
using linker.client.config;
|
||||||
using linker.config;
|
using linker.config;
|
||||||
using linker.libs;
|
using linker.libs;
|
||||||
using linker.libs.extends;
|
|
||||||
using linker.plugins.client;
|
using linker.plugins.client;
|
||||||
using linker.plugins.messenger;
|
using linker.plugins.messenger;
|
||||||
using linker.plugins.signin.messenger;
|
using linker.plugins.signin.messenger;
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
using linker.config;
|
using linker.config;
|
||||||
using linker.startup;
|
using linker.startup;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace linker.plugins.firewall
|
namespace linker.plugins.firewall
|
||||||
{
|
{
|
||||||
@@ -13,7 +12,7 @@ namespace linker.plugins.firewall
|
|||||||
public string[] Dependent => new string[] { };
|
public string[] Dependent => new string[] { };
|
||||||
public StartupLoadType LoadType => StartupLoadType.Dependent;
|
public StartupLoadType LoadType => StartupLoadType.Dependent;
|
||||||
|
|
||||||
public void AddClient(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddClient(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
//linker.libs.FireWallHelper.Write(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
|
//linker.libs.FireWallHelper.Write(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
@@ -22,15 +21,15 @@ namespace linker.plugins.firewall
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddServer(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddServer(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseClient(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseClient(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseServer(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseServer(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,6 @@
|
|||||||
using linker.plugins.flow.messenger;
|
using linker.plugins.flow.messenger;
|
||||||
using linker.startup;
|
using linker.startup;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace linker.plugins.flow
|
namespace linker.plugins.flow
|
||||||
{
|
{
|
||||||
@@ -14,28 +13,26 @@ namespace linker.plugins.flow
|
|||||||
public string[] Dependent => new string[] { };
|
public string[] Dependent => new string[] { };
|
||||||
public StartupLoadType LoadType => StartupLoadType.Dependent;
|
public StartupLoadType LoadType => StartupLoadType.Dependent;
|
||||||
|
|
||||||
public void AddClient(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddClient(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
serviceCollection.AddSingleton<FlowClientApiController>();
|
serviceCollection.AddSingleton<FlowClientApiController>();
|
||||||
serviceCollection.AddSingleton<FlowTransfer>();
|
serviceCollection.AddSingleton<FlowTransfer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddServer(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddServer(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
serviceCollection.AddSingleton<FlowMessenger>();
|
serviceCollection.AddSingleton<FlowMessenger>();
|
||||||
serviceCollection.AddSingleton<FlowTransfer>();
|
serviceCollection.AddSingleton<FlowTransfer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseClient(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseClient(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
FlowTransfer flowTransfer = serviceProvider.GetService<FlowTransfer>();
|
FlowTransfer flowTransfer = serviceProvider.GetService<FlowTransfer>();
|
||||||
flowTransfer.LoadFlows(assemblies);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseServer(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseServer(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
FlowTransfer flowTransfer = serviceProvider.GetService<FlowTransfer>();
|
FlowTransfer flowTransfer = serviceProvider.GetService<FlowTransfer>();
|
||||||
flowTransfer.LoadFlows(assemblies);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,21 +1,13 @@
|
|||||||
using linker.libs;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using System.Reflection;
|
|
||||||
namespace linker.plugins.flow
|
namespace linker.plugins.flow
|
||||||
{
|
{
|
||||||
public sealed class FlowTransfer
|
public sealed partial class FlowTransfer
|
||||||
{
|
{
|
||||||
private List<IFlow> flows = new List<IFlow>();
|
private List<IFlow> flows = new List<IFlow>();
|
||||||
|
|
||||||
|
|
||||||
private readonly ServiceProvider serviceProvider;
|
|
||||||
public FlowTransfer(ServiceProvider serviceProvider)
|
public FlowTransfer(ServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
this.serviceProvider = serviceProvider;
|
var types = GetSourceGeneratorTypes();
|
||||||
}
|
|
||||||
public void LoadFlows(Assembly[] assemblys)
|
|
||||||
{
|
|
||||||
var types = ReflectionHelper.GetInterfaceSchieves(assemblys, typeof(IFlow)).Distinct();
|
|
||||||
flows = types.Select(c => (IFlow)serviceProvider.GetService(c)).Where(c => c != null).ToList();
|
flows = types.Select(c => (IFlow)serviceProvider.GetService(c)).Where(c => c != null).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,4 +16,5 @@ namespace linker.plugins.flow
|
|||||||
return flows.Select(c => new FlowItemInfo { ReceiveBytes = c.ReceiveBytes, SendtBytes = c.SendtBytes, FlowName = c.FlowName }).ToDictionary(c => c.FlowName);
|
return flows.Select(c => new FlowItemInfo { ReceiveBytes = c.ReceiveBytes, SendtBytes = c.SendtBytes, FlowName = c.FlowName }).ToDictionary(c => c.FlowName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -3,7 +3,6 @@ using linker.plugins.forward.messenger;
|
|||||||
using linker.plugins.forward.proxy;
|
using linker.plugins.forward.proxy;
|
||||||
using linker.startup;
|
using linker.startup;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace linker.plugins.forward
|
namespace linker.plugins.forward
|
||||||
{
|
{
|
||||||
@@ -17,7 +16,7 @@ namespace linker.plugins.forward
|
|||||||
public StartupLoadType LoadType => StartupLoadType.Normal;
|
public StartupLoadType LoadType => StartupLoadType.Normal;
|
||||||
|
|
||||||
|
|
||||||
public void AddClient(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddClient(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
serviceCollection.AddSingleton<ForwardClientApiController>();
|
serviceCollection.AddSingleton<ForwardClientApiController>();
|
||||||
serviceCollection.AddSingleton<ForwardTransfer>();
|
serviceCollection.AddSingleton<ForwardTransfer>();
|
||||||
@@ -27,17 +26,17 @@ namespace linker.plugins.forward
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddServer(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddServer(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
serviceCollection.AddSingleton<ForwardServerMessenger>();
|
serviceCollection.AddSingleton<ForwardServerMessenger>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseClient(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseClient(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
ForwardTransfer forwardTransfer = serviceProvider.GetService<ForwardTransfer>();
|
ForwardTransfer forwardTransfer = serviceProvider.GetService<ForwardTransfer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseServer(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseServer(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,6 +18,7 @@ namespace linker.client.config
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class ForwardInfo
|
public sealed class ForwardInfo
|
||||||
{
|
{
|
||||||
|
public ForwardInfo() { }
|
||||||
public uint Id { get; set; }
|
public uint Id { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 名称
|
/// 名称
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
using linker.config;
|
using linker.config;
|
||||||
using linker.startup;
|
using linker.startup;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace linker.plugins.logger
|
namespace linker.plugins.logger
|
||||||
{
|
{
|
||||||
@@ -17,7 +16,7 @@ namespace linker.plugins.logger
|
|||||||
public StartupLoadType LoadType => StartupLoadType.Normal;
|
public StartupLoadType LoadType => StartupLoadType.Normal;
|
||||||
|
|
||||||
|
|
||||||
public void AddClient(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddClient(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
serviceCollection.AddSingleton<LoggerClientApiController>();
|
serviceCollection.AddSingleton<LoggerClientApiController>();
|
||||||
if (config.Data.Client.HasAccess(ClientApiAccess.LoggerLevel) == false)
|
if (config.Data.Client.HasAccess(ClientApiAccess.LoggerLevel) == false)
|
||||||
@@ -26,18 +25,18 @@ namespace linker.plugins.logger
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddServer(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddServer(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseClient(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseClient(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
LoggerClientApiController logger = serviceProvider.GetService<LoggerClientApiController>();
|
LoggerClientApiController logger = serviceProvider.GetService<LoggerClientApiController>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseServer(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseServer(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,6 @@ using System.Security.Cryptography.X509Certificates;
|
|||||||
using linker.libs.extends;
|
using linker.libs.extends;
|
||||||
using linker.plugins.resolver;
|
using linker.plugins.resolver;
|
||||||
using MemoryPack;
|
using MemoryPack;
|
||||||
using linker.plugins.flow;
|
|
||||||
|
|
||||||
namespace linker.plugins.messenger
|
namespace linker.plugins.messenger
|
||||||
{
|
{
|
||||||
@@ -119,14 +118,13 @@ namespace linker.plugins.messenger
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载所有消息处理器
|
/// 加载所有消息处理器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assemblys"></param>
|
public void LoadMessenger()
|
||||||
public void LoadMessenger(Assembly[] assemblys)
|
|
||||||
{
|
{
|
||||||
Type voidType = typeof(void);
|
Type voidType = typeof(void);
|
||||||
Type midType = typeof(MessengerIdAttribute);
|
Type midType = typeof(MessengerIdAttribute);
|
||||||
var types = ReflectionHelper.GetInterfaceSchieves(assemblys, typeof(IMessenger)).Distinct();
|
IEnumerable<Type> types = MessengerResolverTypes.GetSourceGeneratorTypes();
|
||||||
|
|
||||||
foreach (Type type in types)
|
foreach (Type type in types.Distinct())
|
||||||
{
|
{
|
||||||
object obj = serviceProvider.GetService(type);
|
object obj = serviceProvider.GetService(type);
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
@@ -259,6 +257,10 @@ namespace linker.plugins.messenger
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static partial class MessengerResolverTypes
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
[MemoryPackable]
|
[MemoryPackable]
|
||||||
public sealed partial class MessengerFlowItemInfo
|
public sealed partial class MessengerFlowItemInfo
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
using linker.config;
|
using linker.config;
|
||||||
using linker.plugins.resolver;
|
|
||||||
using linker.startup;
|
using linker.startup;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace linker.plugins.messenger
|
namespace linker.plugins.messenger
|
||||||
{
|
{
|
||||||
@@ -17,7 +15,7 @@ namespace linker.plugins.messenger
|
|||||||
public string[] Dependent => new string[] { };
|
public string[] Dependent => new string[] { };
|
||||||
public StartupLoadType LoadType => StartupLoadType.Normal;
|
public StartupLoadType LoadType => StartupLoadType.Normal;
|
||||||
|
|
||||||
public void AddClient(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddClient(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
|
|
||||||
serviceCollection.AddSingleton<MessengerSender>();
|
serviceCollection.AddSingleton<MessengerSender>();
|
||||||
@@ -26,7 +24,7 @@ namespace linker.plugins.messenger
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddServer(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddServer(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
serviceCollection.AddSingleton<MessengerSender>();
|
serviceCollection.AddSingleton<MessengerSender>();
|
||||||
serviceCollection.AddSingleton<MessengerResolver>();
|
serviceCollection.AddSingleton<MessengerResolver>();
|
||||||
@@ -35,27 +33,27 @@ namespace linker.plugins.messenger
|
|||||||
|
|
||||||
|
|
||||||
private bool loaded = false;
|
private bool loaded = false;
|
||||||
public void UseClient(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseClient(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
if (loaded == false)
|
if (loaded == false)
|
||||||
{
|
{
|
||||||
loaded = true;
|
loaded = true;
|
||||||
|
|
||||||
MessengerResolver messengerResolver = serviceProvider.GetService<MessengerResolver>();
|
MessengerResolver messengerResolver = serviceProvider.GetService<MessengerResolver>();
|
||||||
messengerResolver.LoadMessenger(assemblies);
|
messengerResolver.LoadMessenger();
|
||||||
messengerResolver.Init(config.Data.Client.Certificate, config.Data.Client.Password);
|
messengerResolver.Init(config.Data.Client.Certificate, config.Data.Client.Password);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseServer(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseServer(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
if (loaded == false)
|
if (loaded == false)
|
||||||
{
|
{
|
||||||
loaded = true;
|
loaded = true;
|
||||||
|
|
||||||
MessengerResolver messengerResolver = serviceProvider.GetService<MessengerResolver>();
|
MessengerResolver messengerResolver = serviceProvider.GetService<MessengerResolver>();
|
||||||
messengerResolver.LoadMessenger(assemblies);
|
messengerResolver.LoadMessenger();
|
||||||
messengerResolver.Init(config.Data.Server.Certificate, config.Data.Server.Password);
|
messengerResolver.Init(config.Data.Server.Certificate, config.Data.Server.Password);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,6 @@ using linker.plugins.relay.transport;
|
|||||||
using linker.plugins.relay.validator;
|
using linker.plugins.relay.validator;
|
||||||
using linker.startup;
|
using linker.startup;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace linker.plugins.relay
|
namespace linker.plugins.relay
|
||||||
{
|
{
|
||||||
@@ -22,7 +21,7 @@ namespace linker.plugins.relay
|
|||||||
|
|
||||||
public StartupLoadType LoadType => StartupLoadType.Normal;
|
public StartupLoadType LoadType => StartupLoadType.Normal;
|
||||||
|
|
||||||
public void AddClient(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddClient(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
serviceCollection.AddSingleton<RelayApiController>();
|
serviceCollection.AddSingleton<RelayApiController>();
|
||||||
serviceCollection.AddSingleton<RelayClientMessenger>();
|
serviceCollection.AddSingleton<RelayClientMessenger>();
|
||||||
@@ -32,7 +31,7 @@ namespace linker.plugins.relay
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddServer(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddServer(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
serviceCollection.AddSingleton<RelayServerMessenger>();
|
serviceCollection.AddSingleton<RelayServerMessenger>();
|
||||||
|
|
||||||
@@ -45,13 +44,12 @@ namespace linker.plugins.relay
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseClient(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseClient(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
RelayTransfer relayTransfer = serviceProvider.GetService<RelayTransfer>();
|
RelayTransfer relayTransfer = serviceProvider.GetService<RelayTransfer>();
|
||||||
relayTransfer.Load(assemblies);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseServer(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseServer(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
RelayValidatorTransfer relayValidatorTransfer = serviceProvider.GetService<RelayValidatorTransfer>();
|
RelayValidatorTransfer relayValidatorTransfer = serviceProvider.GetService<RelayValidatorTransfer>();
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,6 @@ using linker.libs.extends;
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection;
|
|
||||||
using linker.plugins.client;
|
using linker.plugins.client;
|
||||||
|
|
||||||
namespace linker.plugins.relay
|
namespace linker.plugins.relay
|
||||||
@@ -15,7 +14,7 @@ namespace linker.plugins.relay
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 中继
|
/// 中继
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class RelayTransfer
|
public sealed partial class RelayTransfer
|
||||||
{
|
{
|
||||||
private List<ITransport> transports;
|
private List<ITransport> transports;
|
||||||
|
|
||||||
@@ -33,6 +32,10 @@ namespace linker.plugins.relay
|
|||||||
this.serviceProvider = serviceProvider;
|
this.serviceProvider = serviceProvider;
|
||||||
InitConfig();
|
InitConfig();
|
||||||
TestTask();
|
TestTask();
|
||||||
|
|
||||||
|
IEnumerable<Type> types = GetSourceGeneratorTypes();
|
||||||
|
transports = types.Select(c => (ITransport)serviceProvider.GetService(c)).Where(c => c != null).Where(c => string.IsNullOrWhiteSpace(c.Name) == false).ToList();
|
||||||
|
LoggerHelper.Instance.Info($"load relay transport:{string.Join(",", transports.Select(c => c.Name))}");
|
||||||
}
|
}
|
||||||
private void InitConfig()
|
private void InitConfig()
|
||||||
{
|
{
|
||||||
@@ -51,17 +54,6 @@ namespace linker.plugins.relay
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 加载中继协议
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="assembs"></param>
|
|
||||||
public void Load(Assembly[] assembs)
|
|
||||||
{
|
|
||||||
IEnumerable<Type> types = ReflectionHelper.GetInterfaceSchieves(assembs, typeof(ITransport));
|
|
||||||
transports = types.Select(c => (ITransport)serviceProvider.GetService(c)).Where(c => c != null).Where(c => string.IsNullOrWhiteSpace(c.Name) == false).ToList();
|
|
||||||
|
|
||||||
LoggerHelper.Instance.Info($"load relay transport:{string.Join(",", transports.Select(c => c.Name))}");
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取所有中继协议
|
/// 获取所有中继协议
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@@ -17,6 +17,7 @@ namespace linker.client.config
|
|||||||
|
|
||||||
public sealed class RelayRunningInfo
|
public sealed class RelayRunningInfo
|
||||||
{
|
{
|
||||||
|
public RelayRunningInfo() { }
|
||||||
public ObjectId Id { get; set; }
|
public ObjectId Id { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 中继服务器列表
|
/// 中继服务器列表
|
||||||
@@ -70,6 +71,7 @@ namespace linker.config
|
|||||||
[MemoryPackable]
|
[MemoryPackable]
|
||||||
public sealed partial class RelayServerInfo
|
public sealed partial class RelayServerInfo
|
||||||
{
|
{
|
||||||
|
public RelayServerInfo() { }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 名称
|
/// 名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@@ -5,13 +5,13 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
|
|
||||||
namespace linker.plugins.relay.validator
|
namespace linker.plugins.relay.validator
|
||||||
{
|
{
|
||||||
public sealed class RelayValidatorTransfer
|
public sealed partial class RelayValidatorTransfer
|
||||||
{
|
{
|
||||||
private List<IRelayValidator> startups;
|
private List<IRelayValidator> startups;
|
||||||
|
|
||||||
public RelayValidatorTransfer(ServiceProvider serviceProvider)
|
public RelayValidatorTransfer(ServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
var types = ReflectionHelper.GetInterfaceSchieves(typeof(IRelayValidator));
|
var types = GetSourceGeneratorTypes();
|
||||||
startups = types.Select(c => serviceProvider.GetService(c) as IRelayValidator).Where(c => c != null).ToList();
|
startups = types.Select(c => serviceProvider.GetService(c) as IRelayValidator).Where(c => c != null).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
using linker.config;
|
using linker.config;
|
||||||
using linker.startup;
|
using linker.startup;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace linker.plugins.resolver
|
namespace linker.plugins.resolver
|
||||||
{
|
{
|
||||||
@@ -16,14 +15,14 @@ namespace linker.plugins.resolver
|
|||||||
public string[] Dependent => new string[] { };
|
public string[] Dependent => new string[] { };
|
||||||
public StartupLoadType LoadType => StartupLoadType.Normal;
|
public StartupLoadType LoadType => StartupLoadType.Normal;
|
||||||
|
|
||||||
public void AddClient(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddClient(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
|
|
||||||
serviceCollection.AddSingleton<ResolverTransfer>();
|
serviceCollection.AddSingleton<ResolverTransfer>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddServer(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddServer(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
serviceCollection.AddSingleton<ResolverTransfer>();
|
serviceCollection.AddSingleton<ResolverTransfer>();
|
||||||
|
|
||||||
@@ -31,26 +30,24 @@ namespace linker.plugins.resolver
|
|||||||
|
|
||||||
|
|
||||||
private bool loaded = false;
|
private bool loaded = false;
|
||||||
public void UseClient(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseClient(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
if (loaded == false)
|
if (loaded == false)
|
||||||
{
|
{
|
||||||
loaded = true;
|
loaded = true;
|
||||||
|
|
||||||
ResolverTransfer resolver = serviceProvider.GetService<ResolverTransfer>();
|
ResolverTransfer resolver = serviceProvider.GetService<ResolverTransfer>();
|
||||||
resolver.LoadResolvers(assemblies);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseServer(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseServer(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
if (loaded == false)
|
if (loaded == false)
|
||||||
{
|
{
|
||||||
loaded = true;
|
loaded = true;
|
||||||
|
|
||||||
ResolverTransfer resolver = serviceProvider.GetService<ResolverTransfer>();
|
ResolverTransfer resolver = serviceProvider.GetService<ResolverTransfer>();
|
||||||
resolver.LoadResolvers(assemblies);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,23 +3,17 @@ using System.Net.Sockets;
|
|||||||
using linker.libs.extends;
|
using linker.libs.extends;
|
||||||
using System.Buffers;
|
using System.Buffers;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Reflection;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
||||||
namespace linker.plugins.resolver
|
namespace linker.plugins.resolver
|
||||||
{
|
{
|
||||||
public sealed class ResolverTransfer
|
public sealed partial class ResolverTransfer
|
||||||
{
|
{
|
||||||
private readonly Dictionary<ResolverType, IResolver> resolvers = new Dictionary<ResolverType, IResolver>();
|
private readonly Dictionary<ResolverType, IResolver> resolvers = new Dictionary<ResolverType, IResolver>();
|
||||||
|
|
||||||
private readonly ServiceProvider serviceProvider;
|
|
||||||
public ResolverTransfer(ServiceProvider serviceProvider)
|
public ResolverTransfer(ServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
this.serviceProvider = serviceProvider;
|
var types = GetSourceGeneratorTypes();
|
||||||
}
|
|
||||||
public void LoadResolvers(Assembly[] assemblys)
|
|
||||||
{
|
|
||||||
var types = ReflectionHelper.GetInterfaceSchieves(assemblys, typeof(IResolver)).Distinct();
|
|
||||||
foreach (Type type in types)
|
foreach (Type type in types)
|
||||||
{
|
{
|
||||||
IResolver resolver = (IResolver)serviceProvider.GetService(type);
|
IResolver resolver = (IResolver)serviceProvider.GetService(type);
|
||||||
@@ -31,7 +25,6 @@ namespace linker.plugins.resolver
|
|||||||
|
|
||||||
resolvers.TryAdd(resolver.Type, resolver);
|
resolvers.TryAdd(resolver.Type, resolver);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public async Task BeginReceive(Socket socket)
|
public async Task BeginReceive(Socket socket)
|
||||||
{
|
{
|
||||||
|
@@ -2,7 +2,6 @@
|
|||||||
using linker.startup;
|
using linker.startup;
|
||||||
using MemoryPack;
|
using MemoryPack;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace linker.plugins.serializes
|
namespace linker.plugins.serializes
|
||||||
{
|
{
|
||||||
@@ -17,24 +16,24 @@ namespace linker.plugins.serializes
|
|||||||
public string[] Dependent => Array.Empty<string>();
|
public string[] Dependent => Array.Empty<string>();
|
||||||
public StartupLoadType LoadType => StartupLoadType.Normal;
|
public StartupLoadType LoadType => StartupLoadType.Normal;
|
||||||
|
|
||||||
public void AddClient(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddClient(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
MemoryPackFormatterProvider.Register(new IPEndPointFormatter());
|
MemoryPackFormatterProvider.Register(new IPEndPointFormatter());
|
||||||
MemoryPackFormatterProvider.Register(new IPAddressFormatter());
|
MemoryPackFormatterProvider.Register(new IPAddressFormatter());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddServer(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddServer(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
MemoryPackFormatterProvider.Register(new IPEndPointFormatter());
|
MemoryPackFormatterProvider.Register(new IPEndPointFormatter());
|
||||||
MemoryPackFormatterProvider.Register(new IPAddressFormatter());
|
MemoryPackFormatterProvider.Register(new IPAddressFormatter());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void UseClient(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseClient(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseServer(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseServer(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,6 @@
|
|||||||
using linker.startup;
|
using linker.startup;
|
||||||
using linker.libs;
|
using linker.libs;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace linker.plugins.server
|
namespace linker.plugins.server
|
||||||
{
|
{
|
||||||
@@ -17,20 +16,20 @@ namespace linker.plugins.server
|
|||||||
public string[] Dependent => new string[] {"messenger", "serialize", "firewall", "signin", "config"};
|
public string[] Dependent => new string[] {"messenger", "serialize", "firewall", "signin", "config"};
|
||||||
public StartupLoadType LoadType => StartupLoadType.Normal;
|
public StartupLoadType LoadType => StartupLoadType.Normal;
|
||||||
|
|
||||||
public void AddClient(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddClient(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddServer(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddServer(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
serviceCollection.AddSingleton<TcpServer>();
|
serviceCollection.AddSingleton<TcpServer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseClient(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseClient(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseServer(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseServer(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
LoggerHelper.Instance.Info($"start server");
|
LoggerHelper.Instance.Info($"start server");
|
||||||
try
|
try
|
||||||
|
@@ -7,6 +7,7 @@ namespace linker.config
|
|||||||
}
|
}
|
||||||
public sealed partial class ConfigServerInfo : IConfig
|
public sealed partial class ConfigServerInfo : IConfig
|
||||||
{
|
{
|
||||||
|
public ConfigServerInfo() { }
|
||||||
public int ServicePort { get; set; } = 1802;
|
public int ServicePort { get; set; } = 1802;
|
||||||
|
|
||||||
public string Certificate { get; set; } = "./snltty.pfx";
|
public string Certificate { get; set; } = "./snltty.pfx";
|
||||||
|
@@ -4,7 +4,6 @@ using linker.plugins.sforward.messenger;
|
|||||||
using linker.plugins.sforward.validator;
|
using linker.plugins.sforward.validator;
|
||||||
using linker.startup;
|
using linker.startup;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Reflection;
|
|
||||||
using linker.plugins.sforward.proxy;
|
using linker.plugins.sforward.proxy;
|
||||||
using linker.libs;
|
using linker.libs;
|
||||||
|
|
||||||
@@ -22,9 +21,9 @@ namespace linker.plugins.sforward
|
|||||||
|
|
||||||
public StartupLoadType LoadType => StartupLoadType.Normal;
|
public StartupLoadType LoadType => StartupLoadType.Normal;
|
||||||
|
|
||||||
public void AddClient(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddClient(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
Add(serviceCollection, config, assemblies);
|
Add(serviceCollection, config);
|
||||||
serviceCollection.AddSingleton<SForwardClientApiController>();
|
serviceCollection.AddSingleton<SForwardClientApiController>();
|
||||||
serviceCollection.AddSingleton<SForwardTransfer>();
|
serviceCollection.AddSingleton<SForwardTransfer>();
|
||||||
serviceCollection.AddSingleton<SForwardClientMessenger>();
|
serviceCollection.AddSingleton<SForwardClientMessenger>();
|
||||||
@@ -34,9 +33,9 @@ namespace linker.plugins.sforward
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddServer(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddServer(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
Add(serviceCollection, config, assemblies);
|
Add(serviceCollection, config);
|
||||||
serviceCollection.AddSingleton<SForwardServerMessenger>();
|
serviceCollection.AddSingleton<SForwardServerMessenger>();
|
||||||
serviceCollection.AddSingleton<ISForwardServerCahing, SForwardServerCahing>();
|
serviceCollection.AddSingleton<ISForwardServerCahing, SForwardServerCahing>();
|
||||||
serviceCollection.AddSingleton<ISForwardValidator, Validator>();
|
serviceCollection.AddSingleton<ISForwardValidator, Validator>();
|
||||||
@@ -45,7 +44,7 @@ namespace linker.plugins.sforward
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool added = false;
|
bool added = false;
|
||||||
private void Add(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
private void Add(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
if (added == false)
|
if (added == false)
|
||||||
{
|
{
|
||||||
@@ -54,12 +53,12 @@ namespace linker.plugins.sforward
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseClient(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseClient(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
SForwardTransfer forwardTransfer = serviceProvider.GetService<SForwardTransfer>();
|
SForwardTransfer forwardTransfer = serviceProvider.GetService<SForwardTransfer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseServer(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseServer(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
SForwardProxy sForwardProxy = serviceProvider.GetService<SForwardProxy>();
|
SForwardProxy sForwardProxy = serviceProvider.GetService<SForwardProxy>();
|
||||||
if (config.Data.Server.SForward.WebPort > 0)
|
if (config.Data.Server.SForward.WebPort > 0)
|
||||||
|
@@ -20,6 +20,7 @@ namespace linker.client.config
|
|||||||
|
|
||||||
public sealed class SForwardInfo
|
public sealed class SForwardInfo
|
||||||
{
|
{
|
||||||
|
public SForwardInfo() { }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 穿透id
|
/// 穿透id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@@ -3,7 +3,6 @@ using linker.plugins.signin.messenger;
|
|||||||
using linker.plugins.signIn.args;
|
using linker.plugins.signIn.args;
|
||||||
using linker.startup;
|
using linker.startup;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace linker.plugins.signin
|
namespace linker.plugins.signin
|
||||||
{
|
{
|
||||||
@@ -19,7 +18,7 @@ namespace linker.plugins.signin
|
|||||||
public StartupLoadType LoadType => StartupLoadType.Normal;
|
public StartupLoadType LoadType => StartupLoadType.Normal;
|
||||||
|
|
||||||
|
|
||||||
public void AddClient(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddClient(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
serviceCollection.AddSingleton<SignInClientMessenger>();
|
serviceCollection.AddSingleton<SignInClientMessenger>();
|
||||||
serviceCollection.AddSingleton<SignInClientApiController>();
|
serviceCollection.AddSingleton<SignInClientApiController>();
|
||||||
@@ -28,7 +27,7 @@ namespace linker.plugins.signin
|
|||||||
serviceCollection.AddSingleton<SignInArgsMachineKeyClient>();
|
serviceCollection.AddSingleton<SignInArgsMachineKeyClient>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddServer(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddServer(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
serviceCollection.AddSingleton<SignCaching>();
|
serviceCollection.AddSingleton<SignCaching>();
|
||||||
serviceCollection.AddSingleton<SignInServerMessenger>();
|
serviceCollection.AddSingleton<SignInServerMessenger>();
|
||||||
@@ -37,11 +36,11 @@ namespace linker.plugins.signin
|
|||||||
serviceCollection.AddSingleton<SignInArgsMachineKeyServer>();
|
serviceCollection.AddSingleton<SignInArgsMachineKeyServer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseClient(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseClient(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseServer(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseServer(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using linker.libs;
|
using linker.libs;
|
||||||
using linker.libs.extends;
|
|
||||||
using linker.plugins.signin.messenger;
|
using linker.plugins.signin.messenger;
|
||||||
|
|
||||||
namespace linker.plugins.signIn.args
|
namespace linker.plugins.signIn.args
|
||||||
|
@@ -1,16 +1,15 @@
|
|||||||
using linker.libs;
|
using linker.plugins.signin.messenger;
|
||||||
using linker.plugins.signin.messenger;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace linker.plugins.signIn.args
|
namespace linker.plugins.signIn.args
|
||||||
{
|
{
|
||||||
public sealed class SignInArgsTransfer
|
public sealed partial class SignInArgsTransfer
|
||||||
{
|
{
|
||||||
private List<ISignInArgs> startups;
|
private List<ISignInArgs> startups;
|
||||||
|
|
||||||
public SignInArgsTransfer(ServiceProvider serviceProvider)
|
public SignInArgsTransfer(ServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
var types = ReflectionHelper.GetInterfaceSchieves(typeof(ISignInArgs));
|
var types = GetSourceGeneratorTypes();
|
||||||
startups = types.Select(c => serviceProvider.GetService(c) as ISignInArgs).Where(c => c != null).ToList();
|
startups = types.Select(c => serviceProvider.GetService(c) as ISignInArgs).Where(c => c != null).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8,7 +8,6 @@ using linker.libs;
|
|||||||
using MemoryPack;
|
using MemoryPack;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection;
|
|
||||||
using linker.tunnel.wanport;
|
using linker.tunnel.wanport;
|
||||||
using linker.plugins.tunnel.excludeip;
|
using linker.plugins.tunnel.excludeip;
|
||||||
|
|
||||||
@@ -28,7 +27,7 @@ namespace linker.plugins.tunnel
|
|||||||
|
|
||||||
public StartupLoadType LoadType => StartupLoadType.Normal;
|
public StartupLoadType LoadType => StartupLoadType.Normal;
|
||||||
|
|
||||||
public void AddClient(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddClient(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
//序列化扩展
|
//序列化扩展
|
||||||
MemoryPackFormatterProvider.Register(new TunnelWanPortInfoFormatter());
|
MemoryPackFormatterProvider.Register(new TunnelWanPortInfoFormatter());
|
||||||
@@ -76,7 +75,7 @@ namespace linker.plugins.tunnel
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddServer(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddServer(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
MemoryPackFormatterProvider.Register(new TunnelWanPortInfoFormatter());
|
MemoryPackFormatterProvider.Register(new TunnelWanPortInfoFormatter());
|
||||||
MemoryPackFormatterProvider.Register(new TunnelTransportWanPortInfoFormatter());
|
MemoryPackFormatterProvider.Register(new TunnelTransportWanPortInfoFormatter());
|
||||||
@@ -85,39 +84,43 @@ namespace linker.plugins.tunnel
|
|||||||
MemoryPackFormatterProvider.Register(new TunnelWanPortProtocolInfoFormatter());
|
MemoryPackFormatterProvider.Register(new TunnelWanPortProtocolInfoFormatter());
|
||||||
|
|
||||||
serviceCollection.AddSingleton<TunnelServerMessenger>();
|
serviceCollection.AddSingleton<TunnelServerMessenger>();
|
||||||
|
|
||||||
serviceCollection.AddSingleton<ExternalResolver>();
|
serviceCollection.AddSingleton<ExternalResolver>();
|
||||||
|
|
||||||
|
|
||||||
serviceCollection.AddSingleton<TunnelUpnpTransfer>();
|
serviceCollection.AddSingleton<TunnelUpnpTransfer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseClient(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseClient(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
ITunnelAdapter tunnelAdapter = serviceProvider.GetService<ITunnelAdapter>();
|
ITunnelAdapter tunnelAdapter = serviceProvider.GetService<ITunnelAdapter>();
|
||||||
|
|
||||||
IEnumerable<Type> types = ReflectionHelper.GetInterfaceSchieves(assemblies.Concat(new Assembly[] { typeof(TunnelWanPortTransfer).Assembly }).ToArray(), typeof(ITunnelWanPortProtocol));
|
IEnumerable<Type> types = new List<Type> {
|
||||||
|
typeof(TunnelWanPortProtocolLinkerUdp),
|
||||||
|
typeof(TunnelWanPortProtocolLinkerTcp),
|
||||||
|
typeof(TunnelWanPortProtocolStun),
|
||||||
|
};
|
||||||
List<ITunnelWanPortProtocol> compacts = types.Select(c => (ITunnelWanPortProtocol)serviceProvider.GetService(c)).Where(c => c != null).Where(c => string.IsNullOrWhiteSpace(c.Name) == false).ToList();
|
List<ITunnelWanPortProtocol> compacts = types.Select(c => (ITunnelWanPortProtocol)serviceProvider.GetService(c)).Where(c => c != null).Where(c => string.IsNullOrWhiteSpace(c.Name) == false).ToList();
|
||||||
TunnelWanPortTransfer compack = serviceProvider.GetService<TunnelWanPortTransfer>();
|
TunnelWanPortTransfer compack = serviceProvider.GetService<TunnelWanPortTransfer>();
|
||||||
compack.Init(compacts);
|
compack.Init(compacts);
|
||||||
|
|
||||||
|
|
||||||
types = ReflectionHelper.GetInterfaceSchieves(assemblies.Concat(new Assembly[] { typeof(TunnelTransfer).Assembly }).ToArray(), typeof(ITunnelTransport));
|
types = new List<Type> {
|
||||||
|
typeof(TunnelTransportTcpNutssb),
|
||||||
|
typeof(TransportMsQuic),
|
||||||
|
typeof(TransportTcpP2PNAT),
|
||||||
|
typeof(TransportTcpPortMap),
|
||||||
|
typeof(TransportUdpPortMap),
|
||||||
|
typeof(TransportUdp),
|
||||||
|
};
|
||||||
List<ITunnelTransport> transports = types.Select(c => (ITunnelTransport)serviceProvider.GetService(c)).Where(c => c != null).Where(c => string.IsNullOrWhiteSpace(c.Name) == false).ToList();
|
List<ITunnelTransport> transports = types.Select(c => (ITunnelTransport)serviceProvider.GetService(c)).Where(c => c != null).Where(c => string.IsNullOrWhiteSpace(c.Name) == false).ToList();
|
||||||
TunnelTransfer tunnel = serviceProvider.GetService<TunnelTransfer>();
|
TunnelTransfer tunnel = serviceProvider.GetService<TunnelTransfer>();
|
||||||
tunnel.Init(compack, tunnelAdapter, transports);
|
tunnel.Init(compack, tunnelAdapter, transports);
|
||||||
|
|
||||||
TunnelConfigTransfer tunnelConfigTransfer = serviceProvider.GetService<TunnelConfigTransfer>();
|
TunnelConfigTransfer tunnelConfigTransfer = serviceProvider.GetService<TunnelConfigTransfer>();
|
||||||
|
|
||||||
|
|
||||||
TunnelExcludeIPTransfer excludeIPTransfer = serviceProvider.GetService<TunnelExcludeIPTransfer>();
|
TunnelExcludeIPTransfer excludeIPTransfer = serviceProvider.GetService<TunnelExcludeIPTransfer>();
|
||||||
excludeIPTransfer.Load(assemblies);
|
|
||||||
|
|
||||||
TunnelUpnpTransfer upnpTransfer = serviceProvider.GetService<TunnelUpnpTransfer>();
|
TunnelUpnpTransfer upnpTransfer = serviceProvider.GetService<TunnelUpnpTransfer>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseServer(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseServer(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -20,6 +20,7 @@ namespace linker.client.config
|
|||||||
|
|
||||||
public sealed class TunnelRunningInfo
|
public sealed class TunnelRunningInfo
|
||||||
{
|
{
|
||||||
|
public TunnelRunningInfo() { }
|
||||||
public ObjectId Id { get; set; }
|
public ObjectId Id { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 外网端口服务器列表
|
/// 外网端口服务器列表
|
||||||
@@ -48,6 +49,7 @@ namespace linker.client.config
|
|||||||
[MemoryPackable]
|
[MemoryPackable]
|
||||||
public sealed partial class ExcludeIPItem
|
public sealed partial class ExcludeIPItem
|
||||||
{
|
{
|
||||||
|
public ExcludeIPItem() { }
|
||||||
[MemoryPackAllowSerialize]
|
[MemoryPackAllowSerialize]
|
||||||
public IPAddress IPAddress { get; set; }
|
public IPAddress IPAddress { get; set; }
|
||||||
public byte Mask { get; set; } = 32;
|
public byte Mask { get; set; } = 32;
|
||||||
|
@@ -4,13 +4,12 @@ using linker.libs;
|
|||||||
using linker.plugins.client;
|
using linker.plugins.client;
|
||||||
using MemoryPack;
|
using MemoryPack;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace linker.plugins.tunnel.excludeip
|
namespace linker.plugins.tunnel.excludeip
|
||||||
{
|
{
|
||||||
public sealed class TunnelExcludeIPTransfer
|
public sealed partial class TunnelExcludeIPTransfer
|
||||||
{
|
{
|
||||||
private List<ITunnelExcludeIP> excludeIPs;
|
private readonly List<ITunnelExcludeIP> excludeIPs;
|
||||||
|
|
||||||
private readonly RunningConfig running;
|
private readonly RunningConfig running;
|
||||||
private readonly ClientSignInState clientSignInState;
|
private readonly ClientSignInState clientSignInState;
|
||||||
@@ -23,13 +22,9 @@ namespace linker.plugins.tunnel.excludeip
|
|||||||
this.clientSignInState = clientSignInState;
|
this.clientSignInState = clientSignInState;
|
||||||
this.fileConfig = fileConfig;
|
this.fileConfig = fileConfig;
|
||||||
this.serviceProvider = serviceProvider;
|
this.serviceProvider = serviceProvider;
|
||||||
}
|
|
||||||
|
|
||||||
public void Load(Assembly[] assembs)
|
IEnumerable<Type> types = GetSourceGeneratorTypes();
|
||||||
{
|
|
||||||
IEnumerable<Type> types = ReflectionHelper.GetInterfaceSchieves(assembs, typeof(ITunnelExcludeIP));
|
|
||||||
excludeIPs = types.Select(c => (ITunnelExcludeIP)serviceProvider.GetService(c)).Where(c => c != null).ToList();
|
excludeIPs = types.Select(c => (ITunnelExcludeIP)serviceProvider.GetService(c)).Where(c => c != null).ToList();
|
||||||
|
|
||||||
LoggerHelper.Instance.Info($"load tunnel excludeips :{string.Join(",", types.Select(c => c.Name))}");
|
LoggerHelper.Instance.Info($"load tunnel excludeips :{string.Join(",", types.Select(c => c.Name))}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,7 +3,6 @@ using linker.plugins.tuntap.messenger;
|
|||||||
using linker.startup;
|
using linker.startup;
|
||||||
using linker.tun;
|
using linker.tun;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace linker.plugins.tuntap
|
namespace linker.plugins.tuntap
|
||||||
{
|
{
|
||||||
@@ -20,7 +19,7 @@ namespace linker.plugins.tuntap
|
|||||||
public StartupLoadType LoadType => StartupLoadType.Normal;
|
public StartupLoadType LoadType => StartupLoadType.Normal;
|
||||||
|
|
||||||
|
|
||||||
public void AddClient(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddClient(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
serviceCollection.AddSingleton<TuntapClientApiController>();
|
serviceCollection.AddSingleton<TuntapClientApiController>();
|
||||||
serviceCollection.AddSingleton<LinkerTunDeviceAdapter>();
|
serviceCollection.AddSingleton<LinkerTunDeviceAdapter>();
|
||||||
@@ -33,18 +32,18 @@ namespace linker.plugins.tuntap
|
|||||||
serviceCollection.AddSingleton<ExcludeIP>();
|
serviceCollection.AddSingleton<ExcludeIP>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddServer(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddServer(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
serviceCollection.AddSingleton<TuntapServerMessenger>();
|
serviceCollection.AddSingleton<TuntapServerMessenger>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseClient(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseClient(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
TuntapProxy tuntapProxy = serviceProvider.GetService<TuntapProxy>();
|
TuntapProxy tuntapProxy = serviceProvider.GetService<TuntapProxy>();
|
||||||
TuntapTransfer tuntapTransfer = serviceProvider.GetService<TuntapTransfer>();
|
TuntapTransfer tuntapTransfer = serviceProvider.GetService<TuntapTransfer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseServer(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseServer(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,6 +9,7 @@ namespace linker.plugins.tuntap.config
|
|||||||
[MemoryPackable]
|
[MemoryPackable]
|
||||||
public sealed partial class TuntapConfigInfo
|
public sealed partial class TuntapConfigInfo
|
||||||
{
|
{
|
||||||
|
public TuntapConfigInfo() { }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 网卡IP
|
/// 网卡IP
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@@ -2,7 +2,6 @@
|
|||||||
using linker.plugins.updater.messenger;
|
using linker.plugins.updater.messenger;
|
||||||
using linker.startup;
|
using linker.startup;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace linker.plugins.updater
|
namespace linker.plugins.updater
|
||||||
{
|
{
|
||||||
@@ -21,7 +20,7 @@ namespace linker.plugins.updater
|
|||||||
|
|
||||||
public StartupLoadType LoadType => StartupLoadType.Normal;
|
public StartupLoadType LoadType => StartupLoadType.Normal;
|
||||||
|
|
||||||
public void AddClient(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddClient(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
serviceCollection.AddSingleton<UpdaterHelper>();
|
serviceCollection.AddSingleton<UpdaterHelper>();
|
||||||
serviceCollection.AddSingleton<UpdaterClientTransfer>();
|
serviceCollection.AddSingleton<UpdaterClientTransfer>();
|
||||||
@@ -30,7 +29,7 @@ namespace linker.plugins.updater
|
|||||||
serviceCollection.AddSingleton<UpdaterClientApiController>();
|
serviceCollection.AddSingleton<UpdaterClientApiController>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddServer(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddServer(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
serviceCollection.AddSingleton<UpdaterHelper>();
|
serviceCollection.AddSingleton<UpdaterHelper>();
|
||||||
serviceCollection.AddSingleton<UpdaterServerTransfer>();
|
serviceCollection.AddSingleton<UpdaterServerTransfer>();
|
||||||
@@ -38,12 +37,12 @@ namespace linker.plugins.updater
|
|||||||
serviceCollection.AddSingleton<UpdaterServerMessenger>();
|
serviceCollection.AddSingleton<UpdaterServerMessenger>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseClient(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseClient(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
_ = serviceProvider.GetService<UpdaterClientTransfer>();
|
_ = serviceProvider.GetService<UpdaterClientTransfer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseServer(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseServer(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
_ = serviceProvider.GetService<UpdaterServerTransfer>();
|
_ = serviceProvider.GetService<UpdaterServerTransfer>();
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
using linker.config;
|
using linker.config;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace linker.startup
|
namespace linker.startup
|
||||||
{
|
{
|
||||||
@@ -27,11 +26,11 @@ namespace linker.startup
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public StartupLoadType LoadType { get; }
|
public StartupLoadType LoadType { get; }
|
||||||
|
|
||||||
public void AddClient(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies);
|
public void AddClient(ServiceCollection serviceCollection, FileConfig config);
|
||||||
public void UseClient(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies);
|
public void UseClient(ServiceProvider serviceProvider, FileConfig config);
|
||||||
|
|
||||||
public void AddServer(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies);
|
public void AddServer(ServiceCollection serviceCollection, FileConfig config);
|
||||||
public void UseServer(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies);
|
public void UseServer(ServiceProvider serviceProvider, FileConfig config);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum StartupLoadType
|
public enum StartupLoadType
|
||||||
|
@@ -1,11 +1,10 @@
|
|||||||
using linker.config;
|
using linker.config;
|
||||||
using linker.libs;
|
using linker.libs;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace linker.startup
|
namespace linker.startup
|
||||||
{
|
{
|
||||||
public static class StartupTransfer
|
public static partial class StartupTransfer
|
||||||
{
|
{
|
||||||
static List<IStartup> startups = new List<IStartup>();
|
static List<IStartup> startups = new List<IStartup>();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -13,10 +12,9 @@ namespace linker.startup
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="config"></param>
|
||||||
/// <param name="assemblies"></param>
|
/// <param name="assemblies"></param>
|
||||||
public static void Init(FileConfig config, Assembly[] assemblies)
|
public static void Init(FileConfig config)
|
||||||
{
|
{
|
||||||
var types = ReflectionHelper.GetInterfaceSchieves(assemblies, typeof(IStartup));
|
List<IStartup> temps = GetSourceGeneratorInstances().OrderByDescending(c => c.Level).ToList();
|
||||||
List<IStartup> temps = types.Select(c => Activator.CreateInstance(c) as IStartup).OrderByDescending(c => c.Level).ToList();
|
|
||||||
TestDependent(temps);
|
TestDependent(temps);
|
||||||
LoadPlugins(config, temps);
|
LoadPlugins(config, temps);
|
||||||
}
|
}
|
||||||
@@ -84,19 +82,19 @@ namespace linker.startup
|
|||||||
/// <param name="serviceCollection"></param>
|
/// <param name="serviceCollection"></param>
|
||||||
/// <param name="config"></param>
|
/// <param name="config"></param>
|
||||||
/// <param name="assemblies"></param>
|
/// <param name="assemblies"></param>
|
||||||
public static void Add(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public static void Add(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
foreach (var startup in startups)
|
foreach (var startup in startups)
|
||||||
{
|
{
|
||||||
if (config.Data.Common.Modes.Contains("client"))
|
if (config.Data.Common.Modes.Contains("client"))
|
||||||
{
|
{
|
||||||
LoggerHelper.Instance.Info($"add startup {startup.Name} client");
|
LoggerHelper.Instance.Info($"add startup {startup.Name} client");
|
||||||
startup.AddClient(serviceCollection, config, assemblies);
|
startup.AddClient(serviceCollection, config);
|
||||||
}
|
}
|
||||||
if (config.Data.Common.Modes.Contains("server"))
|
if (config.Data.Common.Modes.Contains("server"))
|
||||||
{
|
{
|
||||||
LoggerHelper.Instance.Info($"add startup {startup.Name} server");
|
LoggerHelper.Instance.Info($"add startup {startup.Name} server");
|
||||||
startup.AddServer(serviceCollection, config, assemblies);
|
startup.AddServer(serviceCollection, config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -107,19 +105,19 @@ namespace linker.startup
|
|||||||
/// <param name="serviceProvider"></param>
|
/// <param name="serviceProvider"></param>
|
||||||
/// <param name="config"></param>
|
/// <param name="config"></param>
|
||||||
/// <param name="assemblies"></param>
|
/// <param name="assemblies"></param>
|
||||||
public static void Use(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public static void Use(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
foreach (var startup in startups)
|
foreach (var startup in startups)
|
||||||
{
|
{
|
||||||
if (config.Data.Common.Modes.Contains("client"))
|
if (config.Data.Common.Modes.Contains("client"))
|
||||||
{
|
{
|
||||||
LoggerHelper.Instance.Info($"use startup {startup.Name} client");
|
LoggerHelper.Instance.Info($"use startup {startup.Name} client");
|
||||||
startup.UseClient(serviceProvider, config, assemblies);
|
startup.UseClient(serviceProvider, config);
|
||||||
}
|
}
|
||||||
if (config.Data.Common.Modes.Contains("server"))
|
if (config.Data.Common.Modes.Contains("server"))
|
||||||
{
|
{
|
||||||
LoggerHelper.Instance.Info($"use startup {startup.Name} server");
|
LoggerHelper.Instance.Info($"use startup {startup.Name} server");
|
||||||
startup.UseServer(serviceProvider, config, assemblies);
|
startup.UseServer(serviceProvider, config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
using linker.config;
|
using linker.config;
|
||||||
using linker.startup;
|
using linker.startup;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace linker.store
|
namespace linker.store
|
||||||
{
|
{
|
||||||
@@ -17,17 +16,17 @@ namespace linker.store
|
|||||||
public StartupLoadType LoadType => StartupLoadType.Normal;
|
public StartupLoadType LoadType => StartupLoadType.Normal;
|
||||||
|
|
||||||
bool loaded = false;
|
bool loaded = false;
|
||||||
public void AddClient(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddClient(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
Add(serviceCollection, config, assemblies);
|
Add(serviceCollection, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddServer(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
public void AddServer(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
Add(serviceCollection, config, assemblies);
|
Add(serviceCollection, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Add(ServiceCollection serviceCollection, FileConfig config, Assembly[] assemblies)
|
private void Add(ServiceCollection serviceCollection, FileConfig config)
|
||||||
{
|
{
|
||||||
if (loaded == false)
|
if (loaded == false)
|
||||||
{
|
{
|
||||||
@@ -36,11 +35,11 @@ namespace linker.store
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseClient(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseClient(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseServer(ServiceProvider serviceProvider, FileConfig config, Assembly[] assemblies)
|
public void UseServer(ServiceProvider serviceProvider, FileConfig config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,7 @@ image="snltty/linker"
|
|||||||
|
|
||||||
fs=('linker')
|
fs=('linker')
|
||||||
ps=('musl' 'debian')
|
ps=('musl' 'debian')
|
||||||
rs=('x64' 'arm64')
|
rs=('x64' 'arm64' 'arm')
|
||||||
|
|
||||||
cd linker.web
|
cd linker.web
|
||||||
npm install &&
|
npm install &&
|
||||||
@@ -40,5 +40,9 @@ do
|
|||||||
cd public/publish/docker/linux-${p}-arm64/${f}
|
cd public/publish/docker/linux-${p}-arm64/${f}
|
||||||
docker buildx build -f ${target}/public/publish/docker/linux-${p}-arm64/${f}/Dockerfile-${p} --platform="linux/arm64" --force-rm -t "${image}-${p}-arm64" . --push
|
docker buildx build -f ${target}/public/publish/docker/linux-${p}-arm64/${f}/Dockerfile-${p} --platform="linux/arm64" --force-rm -t "${image}-${p}-arm64" . --push
|
||||||
cd ../../../../../
|
cd ../../../../../
|
||||||
|
|
||||||
|
cd public/publish/docker/linux-${p}-arm/${f}
|
||||||
|
docker buildx build -f ${target}/public/publish/docker/linux-${p}-arm/${f}/Dockerfile-${p} --platform="linux/arm/v7" --force-rm -t "${image}-${p}-arm" . --push
|
||||||
|
cd ../../../../../
|
||||||
done
|
done
|
||||||
done
|
done
|
@@ -1,5 +1,3 @@
|
|||||||
v1.4.8
|
v1.4.8
|
||||||
2024-10-08 16:26:23
|
2024-10-10 22:17:27
|
||||||
1. 优化减少信标流量
|
1. 使用原生成器替代反射
|
||||||
2. 增加upnp和NAT-PMP,自动添加端口映射,在无法进路由器时很有用
|
|
||||||
3. 可选禁用UDP广播,可有效减少中继流量消耗
|
|
Reference in New Issue
Block a user