diff --git a/Backend/Handler/ThreadHandler.cs b/Backend/Handler/ThreadHandler.cs index 8d541a6..784c270 100644 --- a/Backend/Handler/ThreadHandler.cs +++ b/Backend/Handler/ThreadHandler.cs @@ -30,27 +30,27 @@ public class ThreadHandler public void Start() { - //Thread scanner = new(StartScanner); + Thread scanner = new(StartScanner); Thread indexer = new(StartContentFilter); Thread database = new(StartDbHandler); Thread discarded = new(StartDiscardedDbHandler); - //Thread filtered = new(StartFilteredDbHandler); + Thread filtered = new(StartFilteredDbHandler); Thread resume = new(StartResumeDbHandler); Thread communication = new(StartCommunicationHandler); - //scanner.Start(); + scanner.Start(); indexer.Start(); database.Start(); discarded.Start(); - //filtered.Start(); + filtered.Start(); resume.Start(); communication.Start(); - //scanner.Join(); + scanner.Join(); indexer.Join(); database.Join(); discarded.Join(); - //filtered.Join(); + filtered.Join(); resume.Join(); communication.Join(); } diff --git a/Models/Filtered.db b/Models/Filtered.db deleted file mode 100644 index a1172a1..0000000 Binary files a/Models/Filtered.db and /dev/null differ diff --git a/Models/ScannerResume.db b/Models/ScannerResume.db deleted file mode 100644 index a44725c..0000000 Binary files a/Models/ScannerResume.db and /dev/null differ diff --git a/Models/mydb.db b/Models/mydb.db deleted file mode 100644 index 1ed87f7..0000000 Binary files a/Models/mydb.db and /dev/null differ diff --git a/Proxy/Program.cs b/Proxy/Program.cs index d7e00e2..f3bb6cd 100644 --- a/Proxy/Program.cs +++ b/Proxy/Program.cs @@ -1,10 +1,11 @@ using System.Text.Json; using System.Text.Json.Serialization; -using MessagePack; -using Microsoft.AspNetCore.Cors.Infrastructure; +using AspNetCoreRateLimit; +using Microsoft.AspNetCore.HttpOverrides; using Models.Model.External; using NetMQ; using NetMQ.Sockets; +const string myAllowSpecificOrigins = "_myAllowSpecificOrigins"; WebApplicationBuilder builder = WebApplication.CreateSlimBuilder(args); @@ -15,16 +16,40 @@ builder.Services.ConfigureHttpJsonOptions(options => builder.Services.AddCors(options => { - options.AddPolicy("CorsPolicy", x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().Build()); + options.AddPolicy(name: myAllowSpecificOrigins, x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); }); +// Add memory cache and rate limiting services +builder.Services.AddMemoryCache(); +builder.Services.Configure(options => +{ + options.GeneralRules = + [ + new() + { + Endpoint = "*", // Apply to all endpoints + Period = "10s", // Rate limiting window of 10 second + Limit = 5 // Maximum 5 requests per 10 seconds + } + ]; +}); + +builder.Services.AddInMemoryRateLimiting(); +builder.Services.AddSingleton(); + WebApplication app = builder.Build(); -app.UseCors(); +app.UseForwardedHeaders(new() +{ + ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto +}); + + +app.UseIpRateLimiting(); // Apply IP-based rate limiting middleware + +app.UseCors(myAllowSpecificOrigins); RouteGroupBuilder progressApi = app.MapGroup("/progress"); -progressApi.AllowAnonymous(); -progressApi.DisableAntiforgery(); progressApi.MapGet("/", () => { CommunicationObject communicationObject = new() @@ -43,8 +68,8 @@ progressApi.MapGet("/", () => return JsonSerializer.Deserialize(msg); }); +/* RouteGroupBuilder searchApi = app.MapGroup("/search"); -progressApi.AllowAnonymous(); searchApi.MapGet("/{term}", (string term) => { CommunicationObject communicationObject = new(); @@ -61,11 +86,11 @@ searchApi.MapGet("/{term}", (string term) => return JsonSerializer.Deserialize(msg); }); - +*/ app.Run(); [JsonSerializable(typeof(ScanningStatus))] -[JsonSerializable(typeof(SearchResults))] +//[JsonSerializable(typeof(SearchResults))] [JsonSerializable(typeof(CommunicationObject))] internal partial class AppJsonSerializerContext : JsonSerializerContext { diff --git a/Proxy/Proxy.csproj b/Proxy/Proxy.csproj index fd6bb2b..9601591 100644 --- a/Proxy/Proxy.csproj +++ b/Proxy/Proxy.csproj @@ -9,6 +9,7 @@ + diff --git a/Proxy/appsettings.json b/Proxy/appsettings.json index 10f68b8..51c11b2 100644 --- a/Proxy/appsettings.json +++ b/Proxy/appsettings.json @@ -1,7 +1,7 @@ { "Logging": { "LogLevel": { - "Default": "Information", + "Default": "Warning", "Microsoft.AspNetCore": "Warning" } }, diff --git a/RSE.sln.DotSettings.user b/RSE.sln.DotSettings.user index e315b01..e2d6b61 100644 --- a/RSE.sln.DotSettings.user +++ b/RSE.sln.DotSettings.user @@ -3,4 +3,5 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded \ No newline at end of file diff --git a/frontend/nuxt.config.ts b/frontend/nuxt.config.ts index ea2d759..08bec8d 100644 --- a/frontend/nuxt.config.ts +++ b/frontend/nuxt.config.ts @@ -1,8 +1,9 @@ // https://nuxt.com/docs/api/configuration/nuxt-config export default defineNuxtConfig({ compatibilityDate: '2024-11-01', - devtools: { enabled: true }, - css: ['~/assets/css/main.css'], + ssr: true, + devtools: { enabled: false }, + css: ['@/assets/css/main.css'], postcss: { plugins: { diff --git a/frontend/pages/progress.vue b/frontend/pages/progress.vue index 7494e6a..17f77f7 100644 --- a/frontend/pages/progress.vue +++ b/frontend/pages/progress.vue @@ -5,44 +5,44 @@ const progress = getProgress();