Compare commits
No commits in common. "23d0a8b978bfa9afb11b152430e79548efe8ac6d" and "cd49d32dd778ee6e92149d640512bb1c63a96dfc" have entirely different histories.
23d0a8b978
...
cd49d32dd7
@ -1,11 +1,10 @@
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using AspNetCoreRateLimit;
|
using MessagePack;
|
||||||
using Microsoft.AspNetCore.HttpOverrides;
|
using Microsoft.AspNetCore.Cors.Infrastructure;
|
||||||
using Models.Model.External;
|
using Models.Model.External;
|
||||||
using NetMQ;
|
using NetMQ;
|
||||||
using NetMQ.Sockets;
|
using NetMQ.Sockets;
|
||||||
const string myAllowSpecificOrigins = "_myAllowSpecificOrigins";
|
|
||||||
|
|
||||||
WebApplicationBuilder builder = WebApplication.CreateSlimBuilder(args);
|
WebApplicationBuilder builder = WebApplication.CreateSlimBuilder(args);
|
||||||
|
|
||||||
@ -16,40 +15,16 @@ builder.Services.ConfigureHttpJsonOptions(options =>
|
|||||||
|
|
||||||
builder.Services.AddCors(options =>
|
builder.Services.AddCors(options =>
|
||||||
{
|
{
|
||||||
options.AddPolicy(name: myAllowSpecificOrigins, x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
|
options.AddPolicy("CorsPolicy", x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().Build());
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add memory cache and rate limiting services
|
|
||||||
builder.Services.AddMemoryCache();
|
|
||||||
builder.Services.Configure<IpRateLimitOptions>(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<IRateLimitConfiguration, RateLimitConfiguration>();
|
|
||||||
|
|
||||||
WebApplication app = builder.Build();
|
WebApplication app = builder.Build();
|
||||||
|
|
||||||
app.UseForwardedHeaders(new()
|
app.UseCors();
|
||||||
{
|
|
||||||
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
app.UseIpRateLimiting(); // Apply IP-based rate limiting middleware
|
|
||||||
|
|
||||||
app.UseCors(myAllowSpecificOrigins);
|
|
||||||
|
|
||||||
RouteGroupBuilder progressApi = app.MapGroup("/progress");
|
RouteGroupBuilder progressApi = app.MapGroup("/progress");
|
||||||
|
progressApi.AllowAnonymous();
|
||||||
|
progressApi.DisableAntiforgery();
|
||||||
progressApi.MapGet("/", () =>
|
progressApi.MapGet("/", () =>
|
||||||
{
|
{
|
||||||
CommunicationObject communicationObject = new()
|
CommunicationObject communicationObject = new()
|
||||||
@ -68,8 +43,8 @@ progressApi.MapGet("/", () =>
|
|||||||
return JsonSerializer.Deserialize<ScanningStatus>(msg);
|
return JsonSerializer.Deserialize<ScanningStatus>(msg);
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
|
||||||
RouteGroupBuilder searchApi = app.MapGroup("/search");
|
RouteGroupBuilder searchApi = app.MapGroup("/search");
|
||||||
|
progressApi.AllowAnonymous();
|
||||||
searchApi.MapGet("/{term}", (string term) =>
|
searchApi.MapGet("/{term}", (string term) =>
|
||||||
{
|
{
|
||||||
CommunicationObject communicationObject = new();
|
CommunicationObject communicationObject = new();
|
||||||
@ -86,11 +61,11 @@ searchApi.MapGet("/{term}", (string term) =>
|
|||||||
|
|
||||||
return JsonSerializer.Deserialize<SearchResults?>(msg);
|
return JsonSerializer.Deserialize<SearchResults?>(msg);
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|
||||||
[JsonSerializable(typeof(ScanningStatus))]
|
[JsonSerializable(typeof(ScanningStatus))]
|
||||||
//[JsonSerializable(typeof(SearchResults))]
|
[JsonSerializable(typeof(SearchResults))]
|
||||||
[JsonSerializable(typeof(CommunicationObject))]
|
[JsonSerializable(typeof(CommunicationObject))]
|
||||||
internal partial class AppJsonSerializerContext : JsonSerializerContext
|
internal partial class AppJsonSerializerContext : JsonSerializerContext
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
|
|
||||||
<PackageReference Include="NetMQ" Version="4.0.1.13" />
|
<PackageReference Include="NetMQ" Version="4.0.1.13" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Warning",
|
"Default": "Information",
|
||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -3,5 +3,4 @@
|
|||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003A02000011pdb3Low_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003FILViewer_003F7c3ed02c2ce44598b7f304f8ac45e58f8600_003F6d_003F99b875d1_003F02000011pdb3Low_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003A02000011pdb3Low_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003FILViewer_003F7c3ed02c2ce44598b7f304f8ac45e58f8600_003F6d_003F99b875d1_003F02000011pdb3Low_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADirectoryInfo_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fe4ec446cfe0489bc3ef68a45c6766d183e999ebdc657e94fb1ad059de2bb9_003FDirectoryInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADirectoryInfo_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fe4ec446cfe0489bc3ef68a45c6766d183e999ebdc657e94fb1ad059de2bb9_003FDirectoryInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AHttpResponseMessage_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F85e97f467d698c9e98eae9e3a1b39d58541173e57992d8f7111eabdd3db3526_003FHttpResponseMessage_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AHttpResponseMessage_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F85e97f467d698c9e98eae9e3a1b39d58541173e57992d8f7111eabdd3db3526_003FHttpResponseMessage_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARateLimitRule_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F8fbca8b1bca27d45830c443b2c773d979015ea216430366f285514a39fc0b9_003FRateLimitRule_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThread_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F693e634d7742afaf486acd69d84fe2a9e1ee1b11ba84f29cd1d67668d20dd59_003FThread_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThread_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F693e634d7742afaf486acd69d84fe2a9e1ee1b11ba84f29cd1d67668d20dd59_003FThread_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
|
24
frontend/.gitignore
vendored
24
frontend/.gitignore
vendored
@ -1,24 +0,0 @@
|
|||||||
# Nuxt dev/build outputs
|
|
||||||
.output
|
|
||||||
.data
|
|
||||||
.nuxt
|
|
||||||
.nitro
|
|
||||||
.cache
|
|
||||||
dist
|
|
||||||
|
|
||||||
# Node dependencies
|
|
||||||
node_modules
|
|
||||||
|
|
||||||
# Logs
|
|
||||||
logs
|
|
||||||
*.log
|
|
||||||
|
|
||||||
# Misc
|
|
||||||
.DS_Store
|
|
||||||
.fleet
|
|
||||||
.idea
|
|
||||||
|
|
||||||
# Local env files
|
|
||||||
.env
|
|
||||||
.env.*
|
|
||||||
!.env.example
|
|
@ -1,75 +0,0 @@
|
|||||||
# Nuxt Minimal Starter
|
|
||||||
|
|
||||||
Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
|
|
||||||
|
|
||||||
## Setup
|
|
||||||
|
|
||||||
Make sure to install dependencies:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# npm
|
|
||||||
npm install
|
|
||||||
|
|
||||||
# pnpm
|
|
||||||
pnpm install
|
|
||||||
|
|
||||||
# yarn
|
|
||||||
yarn install
|
|
||||||
|
|
||||||
# bun
|
|
||||||
bun install
|
|
||||||
```
|
|
||||||
|
|
||||||
## Development Server
|
|
||||||
|
|
||||||
Start the development server on `http://localhost:3000`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# npm
|
|
||||||
npm run dev
|
|
||||||
|
|
||||||
# pnpm
|
|
||||||
pnpm dev
|
|
||||||
|
|
||||||
# yarn
|
|
||||||
yarn dev
|
|
||||||
|
|
||||||
# bun
|
|
||||||
bun run dev
|
|
||||||
```
|
|
||||||
|
|
||||||
## Production
|
|
||||||
|
|
||||||
Build the application for production:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# npm
|
|
||||||
npm run build
|
|
||||||
|
|
||||||
# pnpm
|
|
||||||
pnpm build
|
|
||||||
|
|
||||||
# yarn
|
|
||||||
yarn build
|
|
||||||
|
|
||||||
# bun
|
|
||||||
bun run build
|
|
||||||
```
|
|
||||||
|
|
||||||
Locally preview production build:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# npm
|
|
||||||
npm run preview
|
|
||||||
|
|
||||||
# pnpm
|
|
||||||
pnpm preview
|
|
||||||
|
|
||||||
# yarn
|
|
||||||
yarn preview
|
|
||||||
|
|
||||||
# bun
|
|
||||||
bun run preview
|
|
||||||
```
|
|
||||||
|
|
||||||
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
|
|
@ -1,7 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<NuxtRouteAnnouncer />
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<NuxtPage />
|
|
||||||
</template>
|
|
@ -1,3 +0,0 @@
|
|||||||
@tailwind base;
|
|
||||||
@tailwind components;
|
|
||||||
@tailwind utilities;
|
|
@ -1,22 +0,0 @@
|
|||||||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
|
||||||
export default defineNuxtConfig({
|
|
||||||
compatibilityDate: '2024-12-16',
|
|
||||||
ssr: true,
|
|
||||||
|
|
||||||
devtools: { enabled: true },
|
|
||||||
css: ['@/assets/css/main.css'],
|
|
||||||
|
|
||||||
postcss: {
|
|
||||||
plugins: {
|
|
||||||
tailwindcss: {},
|
|
||||||
autoprefixer: {},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
routeRules: {
|
|
||||||
"/": {isr: true},
|
|
||||||
"/progress": {isr: true},
|
|
||||||
},
|
|
||||||
|
|
||||||
modules: ['@nuxtjs/tailwindcss'],
|
|
||||||
})
|
|
10904
frontend/package-lock.json
generated
10904
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "nuxt-app",
|
|
||||||
"private": true,
|
|
||||||
"type": "module",
|
|
||||||
"scripts": {
|
|
||||||
"build": "nuxt build",
|
|
||||||
"dev": "nuxt dev",
|
|
||||||
"generate": "nuxt generate",
|
|
||||||
"preview": "nuxt preview",
|
|
||||||
"postinstall": "nuxt prepare"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@nuxtjs/partytown": "^1.5.0",
|
|
||||||
"nuxt": "^3.14.1592",
|
|
||||||
"vue": "latest",
|
|
||||||
"vue-router": "latest"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@nuxtjs/tailwindcss": "^6.12.2",
|
|
||||||
"autoprefixer": "^10.4.20",
|
|
||||||
"postcss": "^8.4.49",
|
|
||||||
"tailwindcss": "^3.4.16"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
const route = useRoute()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
<h1>Nuxt Routing set up successfully!</h1>
|
|
||||||
<p>Current route: {{ route.path }}</p>
|
|
||||||
<a href="https://nuxt.com/docs/getting-started/routing" target="_blank">Learn more about Nuxt Routing</a>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
@ -1,63 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { fetchWithCache } from '~/utils/cacheUtil';
|
|
||||||
import { progressTypeToDictionary } from '~/utils/convertProgressTypeToDictionary';
|
|
||||||
|
|
||||||
const data = ref<ProgressType | null>(null);
|
|
||||||
const loading = ref<boolean>(true);
|
|
||||||
const error = ref<string | null>(null);
|
|
||||||
let dict = ref<ProgressDictionary[] | null>(null);
|
|
||||||
|
|
||||||
const fetchMyData = async () => {
|
|
||||||
try {
|
|
||||||
loading.value = true;
|
|
||||||
|
|
||||||
// Use the caching utility
|
|
||||||
data.value = await fetchWithCache<ProgressType>(
|
|
||||||
'Progress',
|
|
||||||
async () => {
|
|
||||||
const response = await fetch('https://proxy.rbwr.dk/progress');
|
|
||||||
if (!response.ok) throw new Error('API fetch failed');
|
|
||||||
return (await response.json()) as ProgressType;
|
|
||||||
},
|
|
||||||
5 // Cache max age in seconds
|
|
||||||
);
|
|
||||||
} catch (err) {
|
|
||||||
error.value = (err as Error).message;
|
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
|
||||||
|
|
||||||
if (data.value !== null) {
|
|
||||||
dict.value = progressTypeToDictionary(data.value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
fetchMyData();
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="h-screen grid place-items-center">
|
|
||||||
<div v-if="dict">
|
|
||||||
<table class="table-auto border-gray-300">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th class="px-4 py-2">Metric</th>
|
|
||||||
<th class="px-4 py-2">Value</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
|
|
||||||
<tbody>
|
|
||||||
<tr v-for="d in dict">
|
|
||||||
<td class="px-4 py-2">{{d.description}}</td>
|
|
||||||
<td class="px-4 py-2">{{d.value}}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
</style>
|
|
Binary file not shown.
Before Width: | Height: | Size: 4.2 KiB |
@ -1 +0,0 @@
|
|||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "../.nuxt/tsconfig.server.json"
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
/** @type {import('tailwindcss').Config} */
|
|
||||||
export default {
|
|
||||||
content: [
|
|
||||||
"./components/**/*.{js,vue,ts}",
|
|
||||||
"./layouts/**/*.vue",
|
|
||||||
"./pages/**/*.vue",
|
|
||||||
"./plugins/**/*.{js,ts}",
|
|
||||||
"./app.vue",
|
|
||||||
"./error.vue",
|
|
||||||
],
|
|
||||||
theme: {
|
|
||||||
extend: {},
|
|
||||||
},
|
|
||||||
plugins: [],
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
// https://nuxt.com/docs/guide/concepts/typescript
|
|
||||||
"extends": "./.nuxt/tsconfig.json"
|
|
||||||
}
|
|
19
frontend/types/global.d.ts
vendored
19
frontend/types/global.d.ts
vendored
@ -1,19 +0,0 @@
|
|||||||
interface ProgressType {
|
|
||||||
percentageOfIpv4Scanned: number; // assuming this is a number
|
|
||||||
totalFiltered: bigint;
|
|
||||||
amountOfIpv4Left: bigint;
|
|
||||||
totalDiscarded: bigint;
|
|
||||||
discardedDbSize: bigint;
|
|
||||||
filteredDbSize: bigint;
|
|
||||||
myDbSize: bigint;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ProgressDictionary {
|
|
||||||
description: string;
|
|
||||||
value: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
type CacheEntry<T> = {
|
|
||||||
data: T;
|
|
||||||
timestamp: number;
|
|
||||||
};
|
|
@ -1,34 +0,0 @@
|
|||||||
export function fetchWithCache<Type>(
|
|
||||||
cacheKey: string,
|
|
||||||
fetchFunction: () => Promise<Type>,
|
|
||||||
maxAge: number = 5 // 30 seconds
|
|
||||||
): Promise<Type> {
|
|
||||||
return new Promise(async (resolve, reject) => {
|
|
||||||
try {
|
|
||||||
const cachedData = localStorage.getItem(cacheKey);
|
|
||||||
|
|
||||||
if (cachedData) {
|
|
||||||
const { data, timestamp } = JSON.parse(cachedData) as CacheEntry<Type>;
|
|
||||||
const now = Date.now();
|
|
||||||
const ageInSeconds = (now - timestamp) / 1000;
|
|
||||||
|
|
||||||
// Check if cache is still valid
|
|
||||||
if (ageInSeconds < maxAge) {
|
|
||||||
return resolve(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cache is missing or expired, fetch fresh data
|
|
||||||
const freshData = await fetchFunction();
|
|
||||||
const cacheEntry: CacheEntry<Type> = {
|
|
||||||
data: freshData,
|
|
||||||
timestamp: Date.now(),
|
|
||||||
};
|
|
||||||
|
|
||||||
localStorage.setItem(cacheKey, JSON.stringify(cacheEntry));
|
|
||||||
resolve(freshData);
|
|
||||||
} catch (error) {
|
|
||||||
reject(error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
export function progressTypeToDictionary(progress: ProgressType) {
|
|
||||||
return [
|
|
||||||
{ description: "Percentage of Ipv4 scanned", value: progress.percentageOfIpv4Scanned.toString() },
|
|
||||||
{ description: "Total filtered", value: progress.totalFiltered.toString() },
|
|
||||||
{ description: "Total Discarded", value: progress.totalDiscarded.toString() },
|
|
||||||
{ description: "Amount of Ipv4 left", value: progress.amountOfIpv4Left.toString() },
|
|
||||||
{ description: "Discarded db size", value: progress.discardedDbSize.toString() },
|
|
||||||
{ description: "Filtered db size", value: progress.filteredDbSize.toString() },
|
|
||||||
{ description: "Unfiltered db size", value: progress.myDbSize.toString() },
|
|
||||||
]
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user