mirror of
https://github.com/FastTunnel/FastTunnel.git
synced 2025-02-07 18:19:34 +08:00
升级依赖
This commit is contained in:
parent
38032531a2
commit
d10123fad7
|
@ -1,15 +1,18 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<InvariantGlobalization>true</InvariantGlobalization>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="8.0.0" />
|
||||||
<PackageReference Include="Serilog.Extensions.Hosting" Version="5.0.1" />
|
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
|
||||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.5.0-dev-00359" />
|
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.1-dev-00561" />
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.1-dev-00896" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.1-dev-00947" />
|
<PackageReference Include="Serilog.Sinks.File" Version="5.0.1-dev-00972" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -11,6 +11,8 @@ using Microsoft.Extensions.Configuration;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using FastTunnel.Core.Client.Extensions;
|
using FastTunnel.Core.Client.Extensions;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using FastTunnel.Core.Config;
|
||||||
|
|
||||||
namespace FastTunnel.Client;
|
namespace FastTunnel.Client;
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ namespace FastTunnel.Core.Config
|
||||||
{
|
{
|
||||||
public class DefaultClientConfig : IClientConfig
|
public class DefaultClientConfig : IClientConfig
|
||||||
{
|
{
|
||||||
|
public DefaultClientConfig() { }
|
||||||
public SuiDaoServer Server { get; set; }
|
public SuiDaoServer Server { get; set; }
|
||||||
|
|
||||||
public string Token { get; set; }
|
public string Token { get; set; }
|
||||||
|
|
|
@ -10,24 +10,23 @@ using FastTunnel.Core.Services;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace FastTunnel.Core.Client.Extensions
|
namespace FastTunnel.Core.Client.Extensions;
|
||||||
|
|
||||||
|
public static class ServicesExtensions
|
||||||
{
|
{
|
||||||
public static class ServicesExtensions
|
/// <summary>
|
||||||
|
/// 客户端依赖及HostedService
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
public static void AddFastTunnelClient(this IServiceCollection services, IConfigurationSection configurationSection)
|
||||||
{
|
{
|
||||||
/// <summary>
|
services.Configure<DefaultClientConfig>(configurationSection);
|
||||||
/// 客户端依赖及HostedService
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="services"></param>
|
|
||||||
public static void AddFastTunnelClient(this IServiceCollection services, IConfigurationSection configurationSection)
|
|
||||||
{
|
|
||||||
services.Configure<DefaultClientConfig>(configurationSection);
|
|
||||||
|
|
||||||
services.AddTransient<IFastTunnelClient, FastTunnelClient>()
|
services.AddTransient<IFastTunnelClient, FastTunnelClient>()
|
||||||
.AddSingleton<LogHandler>()
|
.AddSingleton<LogHandler>()
|
||||||
.AddSingleton<SwapHandler>();
|
.AddSingleton<SwapHandler>();
|
||||||
|
|
||||||
services.AddHostedService<ServiceFastTunnelClient>();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
services.AddHostedService<ServiceFastTunnelClient>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License").
|
|
||||||
// You may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
// https://github.com/FastTunnel/FastTunnel/edit/v2/LICENSE
|
|
||||||
// Copyright (c) 2019 Gui.H
|
|
||||||
|
|
||||||
using FastTunnel.Core.Models;
|
|
||||||
using FastTunnel.Core.Models.Massage;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Net.Sockets;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace FastTunnel.Core.Extensions
|
|
||||||
{
|
|
||||||
public static class SocketExtensions
|
|
||||||
{
|
|
||||||
public static void SendCmd<T>(this Socket socket, Message<T> message)
|
|
||||||
where T : TunnelMassage
|
|
||||||
{
|
|
||||||
socket.Send(Encoding.UTF8.GetBytes(message.ToJson() + "\n"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,15 +2,15 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>2.1.2</Version>
|
<Version>2.1.2</Version>
|
||||||
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0;net7.0;</TargetFrameworks>
|
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<LangVersion>preview</LangVersion>
|
<LangVersion>preview</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="..\FastTunnel.Core\Extensions\ObjectExtensions.cs" Link="Extensions\ObjectExtensions.cs" />
|
||||||
<Compile Include="..\FastTunnel.Core\Exceptions\SocketClosedException.cs" Link="Exceptions\SocketClosedException.cs" />
|
<Compile Include="..\FastTunnel.Core\Exceptions\SocketClosedException.cs" Link="Exceptions\SocketClosedException.cs" />
|
||||||
<Compile Include="..\FastTunnel.Core\Extensions\LoggerExtentions.cs" Link="Extensions\LoggerExtentions.cs" />
|
<Compile Include="..\FastTunnel.Core\Extensions\LoggerExtentions.cs" Link="Extensions\LoggerExtentions.cs" />
|
||||||
<Compile Include="..\FastTunnel.Core\Extensions\ObjectExtensions.cs" Link="Extensions\ObjectExtensions.cs" />
|
|
||||||
<Compile Include="..\FastTunnel.Core\Extensions\WebSocketExtensions.cs" Link="Extensions\WebSocketExtensions.cs" />
|
<Compile Include="..\FastTunnel.Core\Extensions\WebSocketExtensions.cs" Link="Extensions\WebSocketExtensions.cs" />
|
||||||
<Compile Include="..\FastTunnel.Core\FastTunnelConst.cs" Link="FastTunnelConst.cs" />
|
<Compile Include="..\FastTunnel.Core\FastTunnelConst.cs" Link="FastTunnelConst.cs" />
|
||||||
<Compile Include="..\FastTunnel.Core\Models\ForwardConfig.cs" Link="Models\ForwardConfig.cs" />
|
<Compile Include="..\FastTunnel.Core\Models\ForwardConfig.cs" Link="Models\ForwardConfig.cs" />
|
||||||
|
@ -22,14 +22,13 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="5.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.0" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="5.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
|
||||||
|
<PackageReference Include="System.IO.Pipelines" Version="8.0.0" />
|
||||||
<PackageReference Include="System.IO.Pipelines" Version="5.0.2" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -9,6 +9,8 @@ using System.Buffers;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Net.WebSockets;
|
using System.Net.WebSockets;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using FastTunnel.Core.Config;
|
using FastTunnel.Core.Config;
|
||||||
|
@ -22,6 +24,15 @@ using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace FastTunnel.Core.Client;
|
namespace FastTunnel.Core.Client;
|
||||||
|
|
||||||
|
#if NET6_0_OR_GREATER
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = false)]
|
||||||
|
[JsonSerializable(typeof(LogInMassage))]
|
||||||
|
[JsonSerializable(typeof(Message<TunnelMassage>))]
|
||||||
|
public partial class SourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
public class FastTunnelClient : IFastTunnelClient
|
public class FastTunnelClient : IFastTunnelClient
|
||||||
{
|
{
|
||||||
private ClientWebSocket socket;
|
private ClientWebSocket socket;
|
||||||
|
@ -99,14 +110,25 @@ public class FastTunnelClient : IFastTunnelClient
|
||||||
await socket.SendCmdAsync(MessageType.LogIn, logMsg, cancellationToken);
|
await socket.SendCmdAsync(MessageType.LogIn, logMsg, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected virtual string GetLoginMsg(CancellationToken cancellationToken)
|
protected virtual string GetLoginMsg(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
Server = ClientConfig.Server;
|
Server = ClientConfig.Server;
|
||||||
|
|
||||||
|
# if NET8_0_OR_GREATER
|
||||||
|
return new LogInMassage
|
||||||
|
{
|
||||||
|
Webs = ClientConfig.Webs,
|
||||||
|
Forwards = ClientConfig.Forwards,
|
||||||
|
}.ToJson(jsonTypeInfo: SourceGenerationContext.Default.LogInMassage);
|
||||||
|
|
||||||
|
#else
|
||||||
return new LogInMassage
|
return new LogInMassage
|
||||||
{
|
{
|
||||||
Webs = ClientConfig.Webs,
|
Webs = ClientConfig.Webs,
|
||||||
Forwards = ClientConfig.Forwards,
|
Forwards = ClientConfig.Forwards,
|
||||||
}.ToJson();
|
}.ToJson();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,25 @@
|
||||||
// Copyright (c) 2019 Gui.H
|
// Copyright (c) 2019 Gui.H
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
|
#if NET8_0_OR_GREATER
|
||||||
|
using System.Text.Json.Serialization.Metadata;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace FastTunnel.Core.Extensions
|
namespace FastTunnel.Core.Extensions
|
||||||
{
|
{
|
||||||
public static class ObjectExtensions
|
public static class ObjectExtensions
|
||||||
{
|
{
|
||||||
|
#if NET8_0_OR_GREATER
|
||||||
|
public static string ToJson<T>(this T message, JsonTypeInfo<T> jsonTypeInfo)
|
||||||
|
{
|
||||||
|
if (message == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return JsonSerializer.Serialize(message, jsonTypeInfo: jsonTypeInfo);
|
||||||
|
}
|
||||||
|
#else
|
||||||
public static string ToJson(this object message)
|
public static string ToJson(this object message)
|
||||||
{
|
{
|
||||||
if (message == null)
|
if (message == null)
|
||||||
|
@ -19,5 +34,6 @@ namespace FastTunnel.Core.Extensions
|
||||||
var jsonOptions = new JsonSerializerOptions { WriteIndented = false };
|
var jsonOptions = new JsonSerializerOptions { WriteIndented = false };
|
||||||
return JsonSerializer.Serialize(message, message.GetType(), jsonOptions);
|
return JsonSerializer.Serialize(message, message.GetType(), jsonOptions);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
|
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
|
||||||
<Version>2.1.2</Version>
|
<Version>2.1.2</Version>
|
||||||
<PackageProjectUrl>https://github.com/SpringHgui/FastTunnel</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/SpringHgui/FastTunnel</PackageProjectUrl>
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
|
@ -24,17 +24,13 @@
|
||||||
<Compile Remove="Listener\PortProxyListenerV2.cs" />
|
<Compile Remove="Listener\PortProxyListenerV2.cs" />
|
||||||
<Compile Remove="Listener\TcpServerHandler.cs" />
|
<Compile Remove="Listener\TcpServerHandler.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="5.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
|
||||||
</ItemGroup>
|
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
|
<PackageReference Include="Yarp.ReverseProxy" Version="2.1.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="7.0.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup >
|
|
||||||
<PackageReference Include="Yarp.ReverseProxy" Version="2.0.1" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Update="TunnelResource.Designer.cs">
|
<Compile Update="TunnelResource.Designer.cs">
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
|
|
|
@ -8,6 +8,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using FastTunnel.Core.Client;
|
using FastTunnel.Core.Client;
|
||||||
|
@ -21,6 +22,13 @@ using Yarp.ReverseProxy.Configuration;
|
||||||
|
|
||||||
namespace FastTunnel.Core.Handlers.Server;
|
namespace FastTunnel.Core.Handlers.Server;
|
||||||
|
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = false)]
|
||||||
|
[JsonSerializable(typeof(LogInMassage))]
|
||||||
|
internal partial class SourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public class LoginHandler : ILoginHandler
|
public class LoginHandler : ILoginHandler
|
||||||
{
|
{
|
||||||
private readonly ILogger logger;
|
private readonly ILogger logger;
|
||||||
|
@ -133,9 +141,11 @@ public class LoginHandler : ILoginHandler
|
||||||
await client.webSocket.SendCmdAsync(MessageType.Log, TunnelResource.NoTunnel, CancellationToken.None);
|
await client.webSocket.SendCmdAsync(MessageType.Log, TunnelResource.NoTunnel, CancellationToken.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public virtual async Task<bool> HandlerMsg(FastTunnelServer fastTunnelServer, TunnelClient tunnelClient, string lineCmd, CancellationToken cancellationToken)
|
public virtual async Task<bool> HandlerMsg(FastTunnelServer fastTunnelServer, TunnelClient tunnelClient, string lineCmd, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var msg = JsonSerializer.Deserialize<LogInMassage>(lineCmd);
|
var msg = JsonSerializer.Deserialize<LogInMassage>(lineCmd, SourceGenerationContext.Default.LogInMassage);
|
||||||
|
|
||||||
await HandleLoginAsync(fastTunnelServer, tunnelClient, msg, cancellationToken);
|
await HandleLoginAsync(fastTunnelServer, tunnelClient, msg, cancellationToken);
|
||||||
return NeedRecive;
|
return NeedRecive;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<InvariantGlobalization>true</InvariantGlobalization>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -12,17 +15,17 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="8.0.0" />
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="6.1.0" />
|
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(Configuration)'=='Debug'">
|
<!--<ItemGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.5.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.5.0" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.5.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.5.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>-->
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\FastTunnel.Core\FastTunnel.Core.csproj" />
|
<ProjectReference Include="..\FastTunnel.Core\FastTunnel.Core.csproj" />
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
// Copyright (c) 2019 Gui.H
|
// Copyright (c) 2019 Gui.H
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -28,17 +29,18 @@ namespace FastTunnel.Server;
|
||||||
|
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
|
[RequiresUnreferencedCode("")]
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
Log.Logger = new LoggerConfiguration()
|
Log.Logger = new LoggerConfiguration()
|
||||||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
|
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
|
||||||
.Enrich.FromLogContext()
|
.Enrich.FromLogContext()
|
||||||
.WriteTo.Console().WriteTo.File("Logs/log-.log", rollingInterval: RollingInterval.Day)
|
.WriteTo.Console().WriteTo.File("Logs/log-.log", rollingInterval: RollingInterval.Day)
|
||||||
.CreateBootstrapLogger();
|
.CreateBootstrapLogger();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var builder = WebApplication.CreateBuilder(new WebApplicationOptions
|
var builder = WebApplication.CreateSlimBuilder(new WebApplicationOptions
|
||||||
{
|
{
|
||||||
Args = args
|
Args = args
|
||||||
});
|
});
|
||||||
|
@ -48,9 +50,9 @@ public class Program
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
#if DEBUG
|
//#if DEBUG
|
||||||
builder.Services.AddSwaggerGen();
|
// builder.Services.AddSwaggerGen();
|
||||||
#endif
|
//#endif
|
||||||
builder.Services.AddCors(options =>
|
builder.Services.AddCors(options =>
|
||||||
{
|
{
|
||||||
options.AddPolicy("corsPolicy", policy =>
|
options.AddPolicy("corsPolicy", policy =>
|
||||||
|
@ -111,10 +113,10 @@ public class Program
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
#if DEBUG
|
//#if DEBUG
|
||||||
app.UseSwagger();
|
// app.UseSwagger();
|
||||||
app.UseSwaggerUI();
|
// app.UseSwaggerUI();
|
||||||
#endif
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseCors("corsPolicy");
|
app.UseCors("corsPolicy");
|
||||||
|
|
|
@ -4,13 +4,17 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||||
-->
|
-->
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<DeleteExistingFiles>False</DeleteExistingFiles>
|
<DeleteExistingFiles>false</DeleteExistingFiles>
|
||||||
<ExcludeApp_Data>False</ExcludeApp_Data>
|
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||||
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
|
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
|
||||||
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||||
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||||
<PublishProvider>FileSystem</PublishProvider>
|
<PublishProvider>FileSystem</PublishProvider>
|
||||||
<PublishUrl>bin\Release\net5.0\publish\</PublishUrl>
|
<PublishUrl>bin\Release\net5.0\publish\</PublishUrl>
|
||||||
<WebPublishMethod>FileSystem</WebPublishMethod>
|
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||||
|
<SiteUrlToLaunchAfterPublish />
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ProjectGuid>def2e322-9075-4c3f-9967-7eaf0ee28ceb</ProjectGuid>
|
||||||
|
<SelfContained>false</SelfContained>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -11,7 +11,7 @@
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"FastTunnel.Server": {
|
"FastTunnel.Server": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"launchBrowser": true,
|
"launchBrowser": false,
|
||||||
"launchUrl": "http://localhost:1270/swagger",
|
"launchUrl": "http://localhost:1270/swagger",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user