diff --git a/FastTunnel.Api/FastTunnel.Api.csproj b/FastTunnel.Api/FastTunnel.Api.csproj index d598b3d..b1b5bb0 100644 --- a/FastTunnel.Api/FastTunnel.Api.csproj +++ b/FastTunnel.Api/FastTunnel.Api.csproj @@ -1,6 +1,6 @@ - net5.0;net6.0 + net6.0 1.1.0 https://github.com/FastTunnel/FastTunnel/tree/v2/FastTunnel.Api https://github.com/FastTunnel/FastTunnel/tree/v2/FastTunnel.Api diff --git a/FastTunnel.Client/Program.cs b/FastTunnel.Client/Program.cs index e78307e..e964643 100644 --- a/FastTunnel.Client/Program.cs +++ b/FastTunnel.Client/Program.cs @@ -8,9 +8,9 @@ using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using System; using Microsoft.AspNetCore.Builder; -using FastTunnel.Core; using Microsoft.Extensions.Configuration; using Serilog; +using FastTunnel.Core.Extensions; namespace FastTunnel.Client; diff --git a/FastTunnel.Client/appsettings.json b/FastTunnel.Client/appsettings.json index 149f728..5573d35 100644 --- a/FastTunnel.Client/appsettings.json +++ b/FastTunnel.Client/appsettings.json @@ -12,7 +12,7 @@ "ClientSettings": { "Server": { // [必选] 服务端ip/域名(来自服务端配置文件的urls参数) - "ServerAddr": "test.cc", + "ServerAddr": "127.0.0.1", // [必选] 服务端监听的通信端口(来自服务端配置文件的urls参数) "ServerPort": 1270 }, diff --git a/FastTunnel.Core/Client/FastTunnelClient.cs b/FastTunnel.Core/Client/FastTunnelClient.cs index 24546c3..b42947b 100644 --- a/FastTunnel.Core/Client/FastTunnelClient.cs +++ b/FastTunnel.Core/Client/FastTunnelClient.cs @@ -1,4 +1,4 @@ -// Licensed under the Apache License, Version 2.0 (the "License"). +// 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 @@ -16,6 +16,7 @@ using FastTunnel.Core.Handlers.Client; using Microsoft.Extensions.Options; using System.Net.WebSockets; using FastTunnel.Core.Utilitys; +using FastTunnel.Core.Models.Massage; namespace FastTunnel.Core.Client { diff --git a/FastTunnel.Core/Extensions/ServicesExtensions.cs b/FastTunnel.Core/Extensions/ServicesExtensions.cs index d5e3070..f9e0a37 100644 --- a/FastTunnel.Core/Extensions/ServicesExtensions.cs +++ b/FastTunnel.Core/Extensions/ServicesExtensions.cs @@ -9,12 +9,10 @@ using FastTunnel.Core.Config; using FastTunnel.Core.Forwarder.MiddleWare; using FastTunnel.Core.Forwarder; using FastTunnel.Core.Handlers.Client; -using FastTunnel.Core.MiddleWares; using FastTunnel.Core.Services; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Yarp.ReverseProxy.Forwarder; -using Yarp.Sample; using Microsoft.AspNetCore.Builder; using FastTunnel.Core.Filters; using Microsoft.AspNetCore.Mvc.Filters; @@ -24,9 +22,23 @@ using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.Options; using System.Threading.Tasks; using System.Threading; + +/* 项目“FastTunnel.Core (net5.0)”的未合并的更改 +在此之前: using Microsoft.AspNetCore.Http; namespace FastTunnel.Core +在此之后: +using Microsoft.AspNetCore.Http; +using FastTunnel.Core.Extensions; +using FastTunnel; +using FastTunnel.Core; + +namespace FastTunnel.Core +*/ +using Microsoft.AspNetCore.Http; + +namespace FastTunnel.Core.Extensions { public static class ServicesExtensions { diff --git a/FastTunnel.Core/Extensions/SocketExtensions.cs b/FastTunnel.Core/Extensions/SocketExtensions.cs index b5710fe..565b32f 100644 --- a/FastTunnel.Core/Extensions/SocketExtensions.cs +++ b/FastTunnel.Core/Extensions/SocketExtensions.cs @@ -5,6 +5,7 @@ // Copyright (c) 2019 Gui.H using FastTunnel.Core.Models; +using FastTunnel.Core.Models.Massage; using System; using System.Collections.Generic; using System.Net.Sockets; diff --git a/FastTunnel.Core/FastTunnel.Core.csproj b/FastTunnel.Core/FastTunnel.Core.csproj index f26b847..7b4eec4 100644 --- a/FastTunnel.Core/FastTunnel.Core.csproj +++ b/FastTunnel.Core/FastTunnel.Core.csproj @@ -1,43 +1,45 @@ - - net5.0;net6.0 - 2.1.0 - https://github.com/SpringHgui/FastTunnel - MIT - FastTunnel - expose a local server behind a NAT or firewall to the internet like ngrok and frp - Gui.H - FastTunnel - FastTunnel - false - true - https://github.com/SpringHgui/FastTunnel - git - FastTunnel.Core - true - FastTunnel.Core - + + net6.0 + 2.1.0 + https://github.com/SpringHgui/FastTunnel + MIT + FastTunnel + expose a local server behind a NAT or firewall to the internet like ngrok and frp + Gui.H + FastTunnel + FastTunnel + false + true + https://github.com/SpringHgui/FastTunnel + git + FastTunnel.Core + true + FastTunnel.Core + + + + + + + + + - - - - - + + + True + True + TunnelResource.resx + + - - - True - True - TunnelResource.resx - - - - - - PublicResXFileCodeGenerator - TunnelResource.Designer.cs - - + + + PublicResXFileCodeGenerator + TunnelResource.Designer.cs + + diff --git a/FastTunnel.Core/Forwarder/InMemoryConfigProvider.cs b/FastTunnel.Core/Forwarder/InMemoryConfigProvider.cs index 903f3a5..3ce8549 100644 --- a/FastTunnel.Core/Forwarder/InMemoryConfigProvider.cs +++ b/FastTunnel.Core/Forwarder/InMemoryConfigProvider.cs @@ -9,7 +9,7 @@ using Microsoft.Extensions.Primitives; using Yarp.ReverseProxy.Configuration; using System.Linq; -namespace Yarp.Sample +namespace FastTunnel.Core.Forwarder { /// /// Extends the IReverseProxyBuilder to support the InMemoryConfigProvider @@ -19,7 +19,7 @@ namespace Yarp.Sample public static IReverseProxyBuilder LoadFromMemory(this IReverseProxyBuilder builder) { builder.Services.AddSingleton( - new InMemoryConfigProvider(Array.Empty(), Array.Empty())); + new FastTunnelInMemoryConfigProvider(Array.Empty(), Array.Empty())); return builder; } @@ -28,13 +28,13 @@ namespace Yarp.Sample /// /// Provides an implementation of IProxyConfigProvider to support config being generated by code. /// - public class InMemoryConfigProvider : IProxyConfigProvider + public class FastTunnelInMemoryConfigProvider : IProxyConfigProvider { // Marked as volatile so that updates are atomic private volatile InMemoryConfig _config; private object locker = new object(); - public InMemoryConfigProvider(IReadOnlyList routes, IReadOnlyList clusters) + public FastTunnelInMemoryConfigProvider(IReadOnlyList routes, IReadOnlyList clusters) { _config = new InMemoryConfig(routes, clusters); } diff --git a/FastTunnel.Core/Forwarder/MiddleWare/FastTunnelClientHandler.cs b/FastTunnel.Core/Forwarder/MiddleWare/FastTunnelClientHandler.cs index 1993585..3046b34 100644 --- a/FastTunnel.Core/Forwarder/MiddleWare/FastTunnelClientHandler.cs +++ b/FastTunnel.Core/Forwarder/MiddleWare/FastTunnelClientHandler.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2022 Gui.H. https://github.com/FastTunnel/FastTunnel +// Copyright (c) 2019-2022 Gui.H. https://github.com/FastTunnel/FastTunnel // The FastTunnel licenses this file to you under the Apache License Version 2.0. // For more details,You may obtain License file at: https://github.com/FastTunnel/FastTunnel/blob/v2/LICENSE @@ -13,7 +13,7 @@ using System.Net.WebSockets; using System.Threading; using System.Threading.Tasks; -namespace FastTunnel.Core.MiddleWares +namespace FastTunnel.Core.Forwarder.MiddleWare { public class FastTunnelClientHandler { @@ -91,7 +91,7 @@ namespace FastTunnel.Core.MiddleWares private bool checkToken(HttpContext context) { - bool checkToken = false; + var checkToken = false; if (fastTunnelServer.ServerOption.CurrentValue.Tokens != null && fastTunnelServer.ServerOption.CurrentValue.Tokens.Count != 0) { checkToken = true; diff --git a/FastTunnel.Core/Forwarder/MiddleWare/FastTunnelSwapHandler.cs b/FastTunnel.Core/Forwarder/MiddleWare/FastTunnelSwapHandler.cs index 040e1a4..c7f35de 100644 --- a/FastTunnel.Core/Forwarder/MiddleWare/FastTunnelSwapHandler.cs +++ b/FastTunnel.Core/Forwarder/MiddleWare/FastTunnelSwapHandler.cs @@ -1,6 +1,5 @@ using FastTunnel.Core.Client; using FastTunnel.Core.Extensions; -using FastTunnel.Core.MiddleWares; using Microsoft.AspNetCore.Connections.Features; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; diff --git a/FastTunnel.Core/Handlers/Server/ForwardDispatcher.cs b/FastTunnel.Core/Handlers/Server/ForwardDispatcher.cs index 3eedd4d..31bb54d 100644 --- a/FastTunnel.Core/Handlers/Server/ForwardDispatcher.cs +++ b/FastTunnel.Core/Handlers/Server/ForwardDispatcher.cs @@ -5,7 +5,6 @@ // Copyright (c) 2019 Gui.H using FastTunnel.Core.Client; -using FastTunnel.Core.Dispatchers; using FastTunnel.Core.Exceptions; using FastTunnel.Core.Extensions; using FastTunnel.Core.Models; @@ -21,7 +20,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -namespace FastTunnel.Core.Dispatchers +namespace FastTunnel.Core.Handlers.Server { public class ForwardDispatcher { diff --git a/FastTunnel.Core/Handlers/Server/IClientMessageHandler.cs b/FastTunnel.Core/Handlers/Server/IClientMessageHandler.cs index 2c65214..221b181 100644 --- a/FastTunnel.Core/Handlers/Server/IClientMessageHandler.cs +++ b/FastTunnel.Core/Handlers/Server/IClientMessageHandler.cs @@ -13,7 +13,7 @@ using System.Net.WebSockets; using System.Text; using System.Threading.Tasks; -namespace FastTunnel.Core.Handlers +namespace FastTunnel.Core.Handlers.Server { public interface IClientMessageHandler { diff --git a/FastTunnel.Core/Handlers/Server/LoginHandler.cs b/FastTunnel.Core/Handlers/Server/LoginHandler.cs index 41a2219..702a6e0 100644 --- a/FastTunnel.Core/Handlers/Server/LoginHandler.cs +++ b/FastTunnel.Core/Handlers/Server/LoginHandler.cs @@ -5,10 +5,11 @@ // Copyright (c) 2019 Gui.H using FastTunnel.Core.Client; -using FastTunnel.Core.Dispatchers; using FastTunnel.Core.Extensions; +using FastTunnel.Core.Forwarder; using FastTunnel.Core.Listener; using FastTunnel.Core.Models; +using FastTunnel.Core.Models.Massage; using Microsoft.Extensions.Logging; using System; using System.Linq; @@ -16,7 +17,6 @@ using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Yarp.ReverseProxy.Configuration; -using Yarp.Sample; namespace FastTunnel.Core.Handlers.Server { @@ -49,7 +49,7 @@ namespace FastTunnel.Core.Handlers.Server logger.LogDebug($"new domain '{hostName}'"); server.WebList.AddOrUpdate(hostName, info, (key, oldInfo) => { return info; }); - (proxyConfig as InMemoryConfigProvider).AddWeb(hostName); + (proxyConfig as FastTunnelInMemoryConfigProvider).AddWeb(hostName); await client.webSocket.SendCmdAsync(MessageType.Log, $" HTTP | http://{hostName}:{client.ConnectionPort} => {item.LocalIp}:{item.LocalPort}", CancellationToken.None); client.AddWeb(info); @@ -61,7 +61,7 @@ namespace FastTunnel.Core.Handlers.Server // TODO:validateDomain hostName = www.Trim().ToLower(); server.WebList.AddOrUpdate(www, info, (key, oldInfo) => { return info; }); - (proxyConfig as InMemoryConfigProvider).AddWeb(www); + (proxyConfig as FastTunnelInMemoryConfigProvider).AddWeb(www); await client.webSocket.SendCmdAsync(MessageType.Log, $" HTTP | http://{www}:{client.ConnectionPort} => {item.LocalIp}:{item.LocalPort}", CancellationToken.None); client.AddWeb(info); diff --git a/FastTunnel.Core/Listener/PortProxyListener.cs b/FastTunnel.Core/Listener/PortProxyListener.cs index 17b0e0b..1cf33c5 100644 --- a/FastTunnel.Core/Listener/PortProxyListener.cs +++ b/FastTunnel.Core/Listener/PortProxyListener.cs @@ -4,7 +4,7 @@ // https://github.com/FastTunnel/FastTunnel/edit/v2/LICENSE // Copyright (c) 2019 Gui.H -using FastTunnel.Core.Dispatchers; +using FastTunnel.Core.Handlers.Server; using Microsoft.Extensions.Logging; using System; using System.Net; diff --git a/FastTunnel.Core/Models/Massage/LogInMassage.cs b/FastTunnel.Core/Models/Massage/LogInMassage.cs index a685c4a..fcb236d 100644 --- a/FastTunnel.Core/Models/Massage/LogInMassage.cs +++ b/FastTunnel.Core/Models/Massage/LogInMassage.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; -namespace FastTunnel.Core.Models +namespace FastTunnel.Core.Models.Massage { public class LogInMassage : TunnelMassage { diff --git a/FastTunnel.Core/Models/Massage/TunnelMassage.cs b/FastTunnel.Core/Models/Massage/TunnelMassage.cs index 86ac135..84dd4f0 100644 --- a/FastTunnel.Core/Models/Massage/TunnelMassage.cs +++ b/FastTunnel.Core/Models/Massage/TunnelMassage.cs @@ -4,7 +4,7 @@ // https://github.com/FastTunnel/FastTunnel/edit/v2/LICENSE // Copyright (c) 2019 Gui.H -namespace FastTunnel.Core.Models +namespace FastTunnel.Core.Models.Massage { public class TunnelMassage { diff --git a/FastTunnel.Server/Startup.cs b/FastTunnel.Server/Startup.cs index a40f7f3..bc0942f 100644 --- a/FastTunnel.Server/Startup.cs +++ b/FastTunnel.Server/Startup.cs @@ -4,7 +4,6 @@ // https://github.com/FastTunnel/FastTunnel/edit/v2/LICENSE // Copyright (c) 2019 Gui.H -using FastTunnel.Core; using FastTunnel.Core.Extensions; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Builder;