3.0.0 beta2

This commit is contained in:
Gui.H 2022-07-05 16:59:15 +08:00
parent a2f0ba1e12
commit 7dc576304d
34 changed files with 133 additions and 339 deletions

View File

@ -50,7 +50,7 @@ csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
# Namespace settings
csharp_style_namespace_declarations = file_scoped
csharp_style_namespace_declarations = file_scoped:silent
[*.{xml,config,*proj,nuspec,props,resx,targets,yml,tasks}]
indent_size = 2
@ -213,6 +213,16 @@ file_header_template = Licensed under the Apache License, Version 2.0 (the "Lice
# IDE0161: Convert to file-scoped namespace
dotnet_diagnostic.IDE0161.severity = warning
end_of_line = crlf
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:silent
dotnet_style_qualification_for_event = false:silent
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
dotnet_code_quality_unused_parameters = all:suggestion
dotnet_style_readonly_field = true:suggestion
tab_width = 4
indent_size = 4
[**/{test,samples,perf}/**.{cs,vb}]
# CA1018: Mark attributes with AttributeUsageAttribute
@ -309,6 +319,23 @@ dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
csharp_using_directive_placement = outside_namespace:silent
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_conditional_delegate_call = true:suggestion
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_prefer_static_local_function = true:suggestion
csharp_space_around_binary_operators = before_and_after
csharp_indent_labels = one_less_than_current
[*.vb]
#### ÃüÃûÑùʽ ####

View File

@ -1,11 +1,11 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["FastTunnel.Server/FastTunnel.Server.csproj", "FastTunnel.Server/"]
COPY ["FastTunnel.Api/FastTunnel.Api.csproj", "FastTunnel.Api/"]

View File

@ -4,17 +4,17 @@
// https://github.com/FastTunnel/FastTunnel/edit/v2/LICENSE
// Copyright (c) 2019 Gui.H
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Security.Claims;
using FastTunnel.Api.Models;
using FastTunnel.Core.Config;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Security.Claims;
namespace FastTunnel.Api.Controllers
{

View File

@ -4,14 +4,11 @@
// https://github.com/FastTunnel/FastTunnel/edit/v2/LICENSE
// Copyright (c) 2019 Gui.H
using System;
using System.Linq;
using FastTunnel.Api.Models;
using FastTunnel.Core.Server;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace FastTunnel.Api.Controllers
{

View File

@ -5,22 +5,17 @@
// Copyright (c) 2019 Gui.H
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FastTunnel.Api;
using FastTunnel.Api.Filters;
using FastTunnel.Core.Config;
using FastTunnel.Core.Extensions;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Tokens;
[assembly: HostingStartup(typeof(FastTunnelApiHostingStartup))]

View File

@ -4,6 +4,16 @@
<TargetFramework>net7.0</TargetFramework>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<None Remove="appsettings.Development.json" />
</ItemGroup>
<ItemGroup>
<Content Include="appsettings.Development.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.0-preview.3.22175.4" />

View File

@ -4,13 +4,11 @@
// https://github.com/FastTunnel/FastTunnel/edit/v2/LICENSE
// Copyright (c) 2019 Gui.H
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Serilog;
using FastTunnel.Core.Extensions;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Hosting;
using Serilog;
namespace FastTunnel.Client;
@ -49,12 +47,12 @@ class Program
Host.CreateDefaultBuilder(args)
.UseWindowsService()
.UseSerilog((context, services, configuration) => configuration
.WriteTo.File("logs/log-.txt", rollingInterval: RollingInterval.Day)
.WriteTo.Console())
.ReadFrom.Configuration(context.Configuration)
.WriteTo.Console())
.ConfigureServices((hostContext, services) =>
{
// -------------------FastTunnel START------------------
services.AddFastTunnelClient(hostContext.Configuration.GetSection("ClientSettings"));
services.AddFastTunnelClient(hostContext.Configuration.GetSection("FastTunnel"));
// -------------------FastTunnel EDN--------------------
});
}

View File

@ -0,0 +1,7 @@
{
"Serilog": {
"MinimumLevel": {
"Default": "Debug"
}
}
}

View File

@ -1,15 +1,24 @@
{
"Logging": {
"LogLevel": {
// Trace Debug Information Warning Error
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"WriteTo": [
//{
// "Name": "File",
// "Args": {
// "path": "Logs/log-.log",
// "rollingInterval": 3
// }
//}
]
},
//
"EnableFileLog": false,
"ClientSettings": {
"FastTunnel": {
"Server": {
// [] ip/urls
"ServerAddr": "test.cc",

View File

@ -20,6 +20,9 @@ using Microsoft.Extensions.Options;
namespace FastTunnel.Core.Client;
/// <summary>
/// 客户端
/// </summary>
public class FastTunnelClient : IFastTunnelClient
{
private ClientWebSocket socket;
@ -48,8 +51,7 @@ public class FastTunnelClient : IFastTunnelClient
/// <summary>
/// 启动客户端
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="customLoginMsg">自定义登录信息,可进行扩展业务</param>
/// <param name="cancellationToken"></param>
public async void StartAsync(CancellationToken cancellationToken)
{
_logger.LogInformation("===== FastTunnel Client Start =====");

View File

@ -6,10 +6,7 @@
using System;
using System.Buffers;
using System.Collections.Generic;
using System.IO.Pipelines;
using System.Linq;
using System.Reflection.PortableExecutable;
using System.Text;
using System.Threading.Tasks;
using FastTunnel.Core.Forwarder.Kestrel.Features;
@ -17,7 +14,6 @@ using FastTunnel.Core.Models;
using FastTunnel.Core.Protocol;
using FastTunnel.Core.Server;
using Microsoft.AspNetCore.Connections;
using Microsoft.Extensions.FileSystemGlobbing;
namespace FastTunnel.Core.Forwarder;

View File

@ -4,11 +4,7 @@
// https://github.com/FastTunnel/FastTunnel/edit/v2/LICENSE
// Copyright (c) 2019 Gui.H
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FastTunnel.Core.Models;
namespace FastTunnel.Core.Forwarder.Kestrel.Features;

View File

@ -4,13 +4,8 @@
// https://github.com/FastTunnel/FastTunnel/edit/v2/LICENSE
// Copyright (c) 2019 Gui.H
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FastTunnel.Core.Models;
using FastTunnel.Core.Protocol;
namespace FastTunnel.Core.Forwarder.Kestrel.Features;

View File

@ -5,24 +5,18 @@
// Copyright (c) 2019 Gui.H
using System;
using System.Buffers;
using System.IO;
using System.IO.Pipelines;
using System.Net.WebSockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using FastTunnel.Core.Exceptions;
using FastTunnel.Core.Extensions;
using FastTunnel.Core.Forwarder.Kestrel;
using FastTunnel.Core.Forwarder.Kestrel.Features;
using FastTunnel.Core.Forwarder.Streams;
using FastTunnel.Core.Models.Massage;
using FastTunnel.Core.Protocol;
using FastTunnel.Core.Server;
using FastTunnel.Core.Utilitys;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Connections.Features;
using Microsoft.Extensions.Logging;
namespace FastTunnel.Core.Forwarder.Kestrel.MiddleWare;
@ -132,7 +126,7 @@ internal class ForwarderMiddleware
finally
{
Interlocked.Decrement(ref UserCount);
logger.LogDebug($"=========USER END {requestId}===========");
logger.LogDebug($"=========USER END {requestId} {UserCount}===========");
fastTunnelServer.ResponseTasks.TryRemove(requestId, out _);
await context.Transport.Input.CompleteAsync();
@ -183,7 +177,7 @@ internal class ForwarderMiddleware
finally
{
Interlocked.Decrement(ref ClientCount);
logger.LogDebug($"=========CLINET END {requestId}===========");
logger.LogDebug($"=========CLINET END {requestId} {ClientCount}===========");
await context.Transport.Input.CompleteAsync();
await context.Transport.Output.CompleteAsync();
}

View File

@ -5,7 +5,6 @@
// Copyright (c) 2019 Gui.H
using System.Threading.Tasks;
using FastTunnel.Core.Forwarder.Kestrel;
using FastTunnel.Core.Server;
using Microsoft.AspNetCore.Connections;
using Microsoft.Extensions.Logging;

View File

@ -9,7 +9,6 @@ using System.Buffers;
using System.IO;
using System.IO.Pipelines;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using FastTunnel.Core.Extensions;

View File

@ -5,11 +5,8 @@
// Copyright (c) 2019 Gui.H
using System;
using System.Collections.Generic;
using System.IO.Pipelines;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace FastTunnel.Core.Forwarder.Streams;

View File

@ -46,8 +46,6 @@ public class SwapHandler : IClientHandler
var taskY = localStream.CopyToAsync(serverStream, cancellationToken);
await Task.WhenAny(taskX, taskY).WaitAsync(cancellationToken);
_logger.LogDebug($"[HandlerMsgAsync] success {requestId}");
}
catch (Exception ex)
{
@ -56,7 +54,7 @@ public class SwapHandler : IClientHandler
finally
{
Interlocked.Decrement(ref SwapCount);
_logger.LogDebug($"========Swap End:{requestId}==========");
_logger.LogDebug($"========Swap End:{requestId} {SwapCount}==========");
}
}

View File

@ -6,14 +6,12 @@
using System;
using System.IO;
using System.IO.Pipelines;
using System.Net.Sockets;
using System.Net.WebSockets;
using System.Threading;
using System.Threading.Tasks;
using FastTunnel.Core.Exceptions;
using FastTunnel.Core.Extensions;
using FastTunnel.Core.Forwarder.Streams;
using FastTunnel.Core.Models;
using FastTunnel.Core.Models.Massage;
using FastTunnel.Core.Server;
@ -34,6 +32,8 @@ public class ForwardDispatcher
_config = config;
}
int SwapCount;
/// <summary>
///
/// </summary>
@ -46,6 +46,8 @@ public class ForwardDispatcher
(Stream Stream, CancellationTokenSource TokenSource) res = default;
Interlocked.Increment(ref SwapCount);
try
{
logger.LogDebug($"[Forward]Swap开始 {msgId}|{_config.RemotePort}=>{_config.LocalIp}:{_config.LocalPort}");
@ -53,7 +55,10 @@ public class ForwardDispatcher
var tcs = new TaskCompletionSource<(Stream Stream, CancellationTokenSource TokenSource)>();
tcs.SetTimeOut(10000, () => { logger.LogDebug($"[Dispatch TimeOut]:{msgId}"); });
_server.ResponseTasks.TryAdd(msgId, tcs);
if (!_server.ResponseTasks.TryAdd(msgId, tcs))
{
return;
}
try
{
@ -88,8 +93,9 @@ public class ForwardDispatcher
}
finally
{
Interlocked.Decrement(ref SwapCount);
res.TokenSource?.Cancel();
logger.LogDebug($"[Forward]Swap OK {msgId}");
logger.LogDebug($"[Forward]Swap OK {msgId} {SwapCount}");
_server.ResponseTasks.TryRemove(msgId, out _);
}
}

View File

@ -43,7 +43,7 @@ public class LoginHandler : ILoginHandler
var hostName = $"{item.SubDomain}.{server.ServerOption.CurrentValue.WebDomain}".Trim().ToLower();
var info = new WebInfo { Socket = client.webSocket, WebConfig = item };
logger.LogDebug($"new domain '{hostName}'");
logger.LogDebug($"New Http '{hostName}'");
server.WebList.AddOrUpdate(hostName, info, (key, oldInfo) => { return info; });
await client.webSocket.SendCmdAsync(MessageType.Log, $" HTTP | http://{hostName}:{client.ConnectionPort} => {item.LocalIp}:{item.LocalPort}", CancellationToken.None);

View File

@ -54,7 +54,6 @@ public class PortProxyListener
private void StartAccept(SocketAsyncEventArgs acceptEventArg)
{
_logerr.LogDebug($"【{ListenIp}:{ListenPort}】: StartAccept");
if (acceptEventArg == null)
{
acceptEventArg = new SocketAsyncEventArgs();

View File

@ -4,7 +4,6 @@
// https://github.com/FastTunnel/FastTunnel/edit/v2/LICENSE
// Copyright (c) 2019 Gui.H
using System;
using System.Net.WebSockets;
namespace FastTunnel.Core.Models;

View File

@ -1,173 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Buffers;
using System.IO;
using System.IO.Pipelines;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using FastTunnel.Core.Extensions;
using Microsoft.AspNetCore.Internal;
#nullable enable
namespace FastTunnel.Core.Refs;
internal class DuplexPipeStream : Stream
{
private readonly PipeReader _input;
private readonly PipeWriter _output;
private readonly bool _throwOnCancelled;
private volatile bool _cancelCalled;
public DuplexPipeStream(PipeReader input, PipeWriter output, bool throwOnCancelled = false)
{
_input = input;
_output = output;
_throwOnCancelled = throwOnCancelled;
}
public void CancelPendingRead()
{
_cancelCalled = true;
_input.CancelPendingRead();
}
public override bool CanRead => true;
public override bool CanSeek => false;
public override bool CanWrite => true;
public override long Length
{
get
{
throw new NotSupportedException();
}
}
public override long Position
{
get
{
throw new NotSupportedException();
}
set
{
throw new NotSupportedException();
}
}
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotSupportedException();
}
public override void SetLength(long value)
{
throw new NotSupportedException();
}
public override int Read(byte[] buffer, int offset, int count)
{
var vt = ReadAsyncInternal(new Memory<byte>(buffer, offset, count), default);
return vt.IsCompleted ?
vt.Result :
vt.AsTask().GetAwaiter().GetResult();
}
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken = default)
{
return ReadAsyncInternal(new Memory<byte>(buffer, offset, count), cancellationToken).AsTask();
}
public override ValueTask<int> ReadAsync(Memory<byte> destination, CancellationToken cancellationToken = default)
{
return ReadAsyncInternal(destination, cancellationToken);
}
public override void Write(byte[] buffer, int offset, int count)
{
WriteAsync(buffer, offset, count).GetAwaiter().GetResult();
}
public override Task WriteAsync(byte[]? buffer, int offset, int count, CancellationToken cancellationToken)
{
return _output.WriteAsync(buffer.AsMemory(offset, count), cancellationToken).GetAsTask();
}
public override ValueTask WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default)
{
return _output.WriteAsync(source, cancellationToken).GetAsValueTask();
}
public override void Flush()
{
FlushAsync(CancellationToken.None).GetAwaiter().GetResult();
}
public override Task FlushAsync(CancellationToken cancellationToken)
{
return _output.FlushAsync(cancellationToken).GetAsTask();
}
[AsyncMethodBuilder(typeof(PoolingAsyncValueTaskMethodBuilder<>))]
private async ValueTask<int> ReadAsyncInternal(Memory<byte> destination, CancellationToken cancellationToken)
{
while (true)
{
var result = await _input.ReadAsync(cancellationToken);
var readableBuffer = result.Buffer;
try
{
if (_throwOnCancelled && result.IsCanceled && _cancelCalled)
{
// Reset the bool
_cancelCalled = false;
throw new OperationCanceledException();
}
if (!readableBuffer.IsEmpty)
{
// buffer.Count is int
var count = (int)Math.Min(readableBuffer.Length, destination.Length);
readableBuffer = readableBuffer.Slice(0, count);
readableBuffer.CopyTo(destination.Span);
return count;
}
if (result.IsCompleted)
{
return 0;
}
}
finally
{
_input.AdvanceTo(readableBuffer.End, readableBuffer.End);
}
}
}
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback? callback, object? state)
{
return TaskToApm.Begin(ReadAsync(buffer, offset, count), callback, state);
}
public override int EndRead(IAsyncResult asyncResult)
{
return TaskToApm.End<int>(asyncResult);
}
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback? callback, object? state)
{
return TaskToApm.Begin(WriteAsync(buffer, offset, count), callback, state);
}
public override void EndWrite(IAsyncResult asyncResult)
{
TaskToApm.End(asyncResult);
}
}

View File

@ -1,57 +0,0 @@
using System;
using System.IO;
using System.IO.Pipelines;
using System.Threading.Tasks;
namespace FastTunnel.Core.Refs;
/// <summary>
/// A helper for wrapping a Stream decorator from an <see cref="IDuplexPipe"/>.
/// </summary>
/// <typeparam name="TStream"></typeparam>
internal class DuplexPipeStreamAdapter<TStream> : DuplexPipeStream, IDuplexPipe where TStream : Stream
{
private bool _disposed;
private readonly object _disposeLock = new object();
public DuplexPipeStreamAdapter(IDuplexPipe duplexPipe, Func<Stream, TStream> createStream) :
this(duplexPipe, new StreamPipeReaderOptions(leaveOpen: true), new StreamPipeWriterOptions(leaveOpen: true), createStream)
{
}
public DuplexPipeStreamAdapter(IDuplexPipe duplexPipe, StreamPipeReaderOptions readerOptions, StreamPipeWriterOptions writerOptions, Func<Stream, TStream> createStream) :
base(duplexPipe.Input, duplexPipe.Output)
{
var stream = createStream(this);
Stream = stream;
Input = PipeReader.Create(stream, readerOptions);
Output = PipeWriter.Create(stream, writerOptions);
}
public TStream Stream { get; }
public PipeReader Input { get; }
public PipeWriter Output { get; }
public override async ValueTask DisposeAsync()
{
lock (_disposeLock)
{
if (_disposed)
{
return;
}
_disposed = true;
}
await Input.CompleteAsync();
await Output.CompleteAsync();
}
protected override void Dispose(bool disposing)
{
throw new NotSupportedException();
}
}

View File

@ -8,7 +8,6 @@ using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.IO.Pipelines;
using System.Threading;
using System.Threading.Tasks;
using FastTunnel.Core.Config;

View File

@ -4,12 +4,8 @@
// https://github.com/FastTunnel/FastTunnel/edit/v2/LICENSE
// Copyright (c) 2019 Gui.H
using System;
using System.Buffers;
using System.Collections.Generic;
using System.IO.Pipelines;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@ -40,7 +36,7 @@ internal class SwapUtility
result = await pipe.Input.ReadAsync(cancellationToken);
readableBuffer = result.Buffer;
}
}
}

View File

@ -4,9 +4,9 @@
// https://github.com/FastTunnel/FastTunnel/edit/v2/LICENSE
// Copyright (c) 2019 Gui.H
using FastTunnel.Core.Extensions;
using FastTunnel.Hosting;
using Microsoft.AspNetCore.Hosting;
using FastTunnel.Core.Extensions;
using Microsoft.Extensions.Configuration;
[assembly: HostingStartup(typeof(FastTunnelHostingStartup))]
@ -24,7 +24,7 @@ public class FastTunnelHostingStartup : IHostingStartup
builder.UseKestrel((context, options) =>
{
var basePort = context.Configuration.GetValue<int?>("FastTunnel:BasePort") ?? 1270;
var basePort = context.Configuration.GetValue<int?>("FastTunnel:BinPort") ?? 1270;
options.ListenAnyIP(basePort, listenOptions =>
{
listenOptions.UseConnectionFastTunnel();

View File

@ -35,6 +35,9 @@
</ItemGroup>
<ItemGroup>
<None Update="install.bat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="uninstall.bat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>

View File

@ -4,13 +4,11 @@
// https://github.com/FastTunnel/FastTunnel/edit/v2/LICENSE
// Copyright (c) 2019 Gui.H
using System;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using FastTunnel.Core.Extensions;
using Serilog;
using System;
namespace FastTunnel.Server;
@ -49,7 +47,9 @@ public class Program
Host.CreateDefaultBuilder(args)
.UseWindowsService()
.UseSerilog((context, services, configuration) => configuration
.WriteTo.File("logs/log-.txt", rollingInterval: RollingInterval.Day)
.ReadFrom.Configuration(context.Configuration)
.ReadFrom.Services(services)
.Enrich.FromLogContext()
.WriteTo.Console())
.ConfigureWebHost(webHostBuilder =>
{

View File

@ -5,16 +5,12 @@
// Copyright (c) 2019 Gui.H
using FastTunnel.Core.Extensions;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.IdentityModel.Tokens;
using System;
using FastTunnel.Core.Config;
using System.Text;
#if DEBUG

View File

@ -1,12 +1,7 @@
{
"Logging": {
"LogLevel": {
// Trace Debug Information Warning Error
"Default": "Debug",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
"Serilog": {
"MinimumLevel": {
"Default": "Debug"
}
},
"AllowedHosts": "*",
"EnableFileLog": false
}
}

View File

@ -1,18 +1,30 @@
{
"Logging": {
"LogLevel": {
// Trace Debug Information Warning Error
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
"MinimumLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
"Override": {
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"WriteTo": [
//{
// "Name": "File",
// "Args": {
// "path": "Logs/log-.log",
// "rollingInterval": 3
// }
//}
]
},
"AllowedHosts": "*",
// Http&
"urls": "http://*:1270",
//
"EnableFileLog": false,
"FastTunnel": {
//
"BinPort": 1270,
//
// SubDomain ${SubDomain}.${WebDomain}访访
"WebDomain": "test.cc",

View File

@ -4,7 +4,7 @@ color 0e
@echo ==================================
@echo 提醒:请右键本文件,用管理员方式打开。
@echo ==================================
@echo Start Install ./../FastTunnel.Server
@echo Start Install FastTunnel.Server
sc create FastTunnel.Server binPath=%~dp0\FastTunnel.Server.exe start= auto
sc description FastTunnel.Server "FastTunnel-开源内网穿透服务仓库地址https://github.com/SpringHgui/FastTunnel star项目以支持作者"

View File

@ -4,7 +4,7 @@ color 0e
@echo ==================================
@echo 提醒:请右键本文件,用管理员方式打开。
@echo ==================================
@echo Start Remove ./../FastTunnel.Server
@echo Start Remove FastTunnel.Server
Net stop FastTunnel.Server
sc delete FastTunnel.Server