精简客户端代码

This commit is contained in:
SpringHgui 2020-11-01 12:34:51 +08:00
parent f64ab45332
commit 8a1d14dfd0
4 changed files with 22 additions and 13 deletions

View File

@ -9,6 +9,7 @@ using FastTunnel.Core.Config;
using FastTunnel.Core.Handlers.Client;
using Microsoft.Extensions.Logging;
using NLog.Web;
using FastTunnel.Core.Extensions;
namespace FastTunnel.Client
{
@ -39,13 +40,7 @@ namespace FastTunnel.Client
.ConfigureServices((hostContext, services) =>
{
// -------------------FastTunnel START------------------
services.AddSingleton<FastTunnelClient>()
.AddSingleton<ClientHeartHandler>()
.AddSingleton<LogHandler>()
.AddSingleton<HttpRequestHandler>()
.AddSingleton<NewSSHHandler>();
services.AddHostedService<ServiceFastTunnelClient>();
services.AddFastTunnelClient();
// -------------------FastTunnel EDN--------------------
})
.ConfigureLogging((HostBuilderContext context, ILoggingBuilder logging) =>

View File

@ -2,7 +2,7 @@
"Logging": {
"LogLevel": {
// Trace Debug Information Warning Error
"Default": "Trace",
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}

View File

@ -1,4 +1,7 @@
using FastTunnel.Core.Filters;
using FastTunnel.Core.Core;
using FastTunnel.Core.Filters;
using FastTunnel.Core.Handlers.Client;
using FastTunnel.Core.Services;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
@ -8,9 +11,21 @@ namespace FastTunnel.Core.Extensions
{
public static class ServicesExtensions
{
public static void AddFastTunnel(this IServiceCollection service)
public static void AddFastTunnelServer(this IServiceCollection services)
{
service.AddTransient<IAuthenticationFilter, DefaultAuthenticationFilter>();
services.AddTransient<IAuthenticationFilter, DefaultAuthenticationFilter>();
services.AddHostedService<ServiceFastTunnelServer>();
}
public static void AddFastTunnelClient(this IServiceCollection services) {
services.AddSingleton<FastTunnelClient>()
.AddSingleton<ClientHeartHandler>()
.AddSingleton<LogHandler>()
.AddSingleton<HttpRequestHandler>()
.AddSingleton<NewSSHHandler>();
services.AddHostedService<ServiceFastTunnelClient>();
}
}
}

View File

@ -36,8 +36,7 @@ namespace FastTunnel.Server
.ConfigureServices((hostContext, services) =>
{
// -------------------FastTunnel START------------------
services.AddFastTunnel();
services.AddHostedService<ServiceFastTunnelServer>();
services.AddFastTunnelServer();
// -------------------FastTunnel END--------------------
})
.ConfigureWebHostDefaults(webBuilder =>