From 5953a003dc76da234e14e536260d4935a1ccd911 Mon Sep 17 00:00:00 2001 From: immisterio <96652250+immisterio@users.noreply.github.com> Date: Sun, 1 Jan 2023 12:59:12 +0200 Subject: [PATCH] shutdown --- Engine/Middlewares/Accs.cs | 6 ------ Engine/Middlewares/TorAPI.cs | 9 +++++++++ Models/UserData.cs | 3 +++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Engine/Middlewares/Accs.cs b/Engine/Middlewares/Accs.cs index 8162709..4f8308a 100644 --- a/Engine/Middlewares/Accs.cs +++ b/Engine/Middlewares/Accs.cs @@ -61,12 +61,6 @@ public Task Invoke(HttpContext httpContext) return _next(httpContext); #endregion - #region Методы работающие без авторизации - if (httpContext.Request.Path.Value.StartsWith("/shutdown")) - return httpContext.Response.WriteAsync(""); - #endregion - - if (Startup.settings.AuthorizationRequired) { #region Авторизация по домену diff --git a/Engine/Middlewares/TorAPI.cs b/Engine/Middlewares/TorAPI.cs index 79bd945..495a021 100644 --- a/Engine/Middlewares/TorAPI.cs +++ b/Engine/Middlewares/TorAPI.cs @@ -87,6 +87,9 @@ async public Task InvokeAsync(HttpContext httpContext) var userData = httpContext.Features.Get(); + if (!userData.shutdown && httpContext.Request.Path.Value.StartsWith("/shutdown")) + return; + string dbKeyOrLogin = userData.login; if (userData.IsShared) dbKeyOrLogin = $"{userData.login}:{httpContext.Connection.RemoteIpAddress}"; @@ -280,6 +283,12 @@ async public Task InvokeAsync(HttpContext httpContext) await CopyProxyHttpResponse(httpContext, response, info); } #endregion + + if (httpContext.Request.Path.Value.StartsWith("/shutdown")) + { + db.TryRemove(dbKeyOrLogin, out _); + info.Dispose(); + } } diff --git a/Models/UserData.cs b/Models/UserData.cs index c320441..a52d5a6 100644 --- a/Models/UserData.cs +++ b/Models/UserData.cs @@ -21,6 +21,9 @@ public class UserData [JsonIgnore] public bool IsShared { get; set; } + [JsonIgnore] + public bool shutdown { get; set; } + [JsonIgnore] public byte maxiptoIsLockHostOrUser { get; set; } }