diff --git a/Dockerfile.Client b/Dockerfile.Client new file mode 100644 index 0000000..59ba713 --- /dev/null +++ b/Dockerfile.Client @@ -0,0 +1,23 @@ +#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:7.0 AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +WORKDIR /src +COPY ["FastTunnel.Client/FastTunnel.Client.csproj", "FastTunnel.Client/"] +COPY ["FastTunnel.Core.Client/FastTunnel.Core.Client.csproj", "FastTunnel.Core.Client/"] +RUN dotnet restore "FastTunnel.Client/FastTunnel.Client.csproj" +COPY . . +WORKDIR "/src/FastTunnel.Client" +RUN dotnet build "FastTunnel.Client.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "FastTunnel.Client.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "FastTunnel.Client.dll"] diff --git a/FastTunnel.Core/Handlers/Server/ForwardDispatcher.cs b/FastTunnel.Core/Handlers/ForwardDispatcher.cs similarity index 98% rename from FastTunnel.Core/Handlers/Server/ForwardDispatcher.cs rename to FastTunnel.Core/Handlers/ForwardDispatcher.cs index e32ea52..c0ec8c4 100644 --- a/FastTunnel.Core/Handlers/Server/ForwardDispatcher.cs +++ b/FastTunnel.Core/Handlers/ForwardDispatcher.cs @@ -20,7 +20,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -namespace FastTunnel.Core.Handlers.Server +namespace FastTunnel.Core.Handlers { public class ForwardDispatcher { diff --git a/FastTunnel.Core/Handlers/Server/IClientMessageHandler.cs b/FastTunnel.Core/Handlers/IClientMessageHandler.cs similarity index 100% rename from FastTunnel.Core/Handlers/Server/IClientMessageHandler.cs rename to FastTunnel.Core/Handlers/IClientMessageHandler.cs diff --git a/FastTunnel.Core/Handlers/Server/ILoginHandler.cs b/FastTunnel.Core/Handlers/ILoginHandler.cs similarity index 100% rename from FastTunnel.Core/Handlers/Server/ILoginHandler.cs rename to FastTunnel.Core/Handlers/ILoginHandler.cs diff --git a/FastTunnel.Core/Handlers/Server/LoginHandler.cs b/FastTunnel.Core/Handlers/LoginHandler.cs similarity index 100% rename from FastTunnel.Core/Handlers/Server/LoginHandler.cs rename to FastTunnel.Core/Handlers/LoginHandler.cs diff --git a/FastTunnel.Core/Listener/PortProxyListener.cs b/FastTunnel.Core/Listener/PortProxyListener.cs index e27e9de..87d24e6 100644 --- a/FastTunnel.Core/Listener/PortProxyListener.cs +++ b/FastTunnel.Core/Listener/PortProxyListener.cs @@ -4,6 +4,7 @@ // https://github.com/FastTunnel/FastTunnel/edit/v2/LICENSE // Copyright (c) 2019 Gui.H +using FastTunnel.Core.Handlers; using FastTunnel.Core.Handlers.Server; using Microsoft.Extensions.Logging; using System; diff --git a/FastTunnel.Core/Models/TunnelClient.cs b/FastTunnel.Core/Models/TunnelClient.cs index 8de31b4..31be5ce 100644 --- a/FastTunnel.Core/Models/TunnelClient.cs +++ b/FastTunnel.Core/Models/TunnelClient.cs @@ -48,8 +48,11 @@ public class TunnelClient this.fastTunnelServer = fastTunnelServer; this.loginHandler = loginHandler; this.RemoteIpAddress = remoteIpAddress; + StartTime = DateTime.Now; } + public DateTime StartTime { get; } + internal void AddWeb(WebInfo info) { webInfos.Add(info); diff --git a/FastTunnel.Server/Controllers/SystemController.cs b/FastTunnel.Server/Controllers/SystemController.cs index 0f6c9f5..2681293 100644 --- a/FastTunnel.Server/Controllers/SystemController.cs +++ b/FastTunnel.Server/Controllers/SystemController.cs @@ -97,4 +97,15 @@ public class SystemController : BaseController ApiResponse.data = fastTunnelServer.ConnectedClientCount; return ApiResponse; } + + [HttpGet] + public ApiResponse Clients() + { + ApiResponse.data = fastTunnelServer.Clients.Select(x => new + { + RemoteIpAddress = x.RemoteIpAddress.ToString(), + StartTime = x.StartTime.ToString("yyyyy-MM-dd HH:mm:ss") + }); + return ApiResponse; + } }