Skip to content

Commit 368ecf8

Browse files
authored
fix(dnscaching): display stats for DNS caching (#1858)
* fix(dnscaching): display stats for DNS caching * fix: add missing translation
1 parent d3fd502 commit 368ecf8

7 files changed

Lines changed: 20 additions & 50 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"cronstrue": "2.23.0",
5858
"date-fns": "2.29.3",
5959
"dayjs": "1.11.7",
60-
"dns-caching": "^0.2.4",
60+
"dns-caching": "^0.2.5",
6161
"email-templates": "12.0.1",
6262
"email-validator": "2.0.4",
6363
"express": "4.21.2",

pnpm-lock.yaml

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/interfaces/api/settingsInterfaces.ts

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { DnsEntries, DnsStats } from 'dns-caching';
12
import type { PaginatedResponse } from './common';
23

34
export type LogMessage = {
@@ -61,38 +62,12 @@ export interface CacheItem {
6162
};
6263
}
6364

64-
export interface DNSAddresses {
65-
ipv4: number;
66-
ipv6: number;
67-
}
68-
69-
export interface DNSRecord {
70-
addresses: DNSAddresses;
71-
activeAddress: string;
72-
family: number;
73-
age: number;
74-
ttl: number;
75-
networkErrors: number;
76-
hits: number;
77-
misses: number;
78-
}
79-
80-
export interface DNSStats {
81-
size: number;
82-
maxSize: number;
83-
hits: number;
84-
misses: number;
85-
failures: number;
86-
ipv4Fallbacks: number;
87-
hitRate: number;
88-
}
89-
9065
export interface CacheResponse {
9166
apiCaches: CacheItem[];
9267
imageCache: Record<'tmdb' | 'avatar', { size: number; imageCount: number }>;
9368
dnsCache: {
94-
entries: Record<string, DNSRecord>;
95-
stats: DNSStats;
69+
stats: DnsStats | undefined;
70+
entries: DnsEntries | undefined;
9671
};
9772
}
9873

server/routes/settings/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ import discoverSettingRoutes from '@server/routes/settings/discover';
2828
import { ApiError } from '@server/types/error';
2929
import { appDataPath } from '@server/utils/appDataVolume';
3030
import { getAppVersion } from '@server/utils/appVersion';
31-
import dnsCache from '@server/utils/dnsCache';
31+
import { dnsCache } from '@server/utils/dnsCache';
3232
import { getHostname } from '@server/utils/getHostname';
33+
import type { DnsEntries, DnsStats } from 'dns-caching';
3334
import { Router } from 'express';
3435
import rateLimit from 'express-rate-limit';
3536
import fs from 'fs';
@@ -756,8 +757,8 @@ settingsRoutes.get('/cache', async (_req, res) => {
756757
const tmdbImageCache = await ImageProxy.getImageStats('tmdb');
757758
const avatarImageCache = await ImageProxy.getImageStats('avatar');
758759

759-
const stats = dnsCache?.getStats();
760-
const entries = dnsCache?.getCacheEntries();
760+
const stats: DnsStats | undefined = dnsCache?.getStats();
761+
const entries: DnsEntries | undefined = dnsCache?.getCacheEntries();
761762

762763
return res.status(200).json({
763764
apiCaches,

server/utils/dnsCache.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logger from '@server/logger';
22
import { DnsCacheManager } from 'dns-caching';
33

4-
let dnsCache: DnsCacheManager | undefined;
4+
export let dnsCache: DnsCacheManager | undefined;
55

66
export function initializeDnsCache({
77
forceMinTtl,
@@ -24,5 +24,3 @@ export function initializeDnsCache({
2424
});
2525
dnsCache.initialize();
2626
}
27-
28-
export default dnsCache;

src/components/Settings/SettingsJobsCache/index.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ const messages: { [messageName: string]: MessageDescriptor } = defineMessages(
6565
dnscachehits: 'Hits',
6666
dnscachemisses: 'Misses',
6767
dnscacheage: 'Age',
68-
dnscachenetworkerrors: 'Network Errors',
6968
flushdnscache: 'Flush DNS Cache',
7069
dnsCacheGlobalStats: 'Global DNS Cache Stats',
7170
dnsCacheGlobalStatsDescription:
@@ -629,9 +628,6 @@ const SettingsJobs = () => {
629628
<Table.TH>{intl.formatMessage(messages.dnscachehits)}</Table.TH>
630629
<Table.TH>{intl.formatMessage(messages.dnscachemisses)}</Table.TH>
631630
<Table.TH>{intl.formatMessage(messages.dnscacheage)}</Table.TH>
632-
<Table.TH>
633-
{intl.formatMessage(messages.dnscachenetworkerrors)}
634-
</Table.TH>
635631
<Table.TH></Table.TH>
636632
</tr>
637633
</thead>
@@ -644,7 +640,6 @@ const SettingsJobs = () => {
644640
<Table.TD>{intl.formatNumber(data.hits)}</Table.TD>
645641
<Table.TD>{intl.formatNumber(data.misses)}</Table.TD>
646642
<Table.TD>{formatAge(data.age)}</Table.TD>
647-
<Table.TD>{intl.formatNumber(data.networkErrors)}</Table.TD>
648643
<Table.TD alignText="right">
649644
<Button
650645
buttonType="danger"

src/i18n/locale/en.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@
104104
"components.Discover.StudioSlider.studios": "Studios",
105105
"components.Discover.TvGenreList.seriesgenres": "Series Genres",
106106
"components.Discover.TvGenreSlider.tvgenres": "Series Genres",
107-
"components.DiscoverTvUpcoming.upcomingtv": "Upcoming Series",
108107
"components.Discover.createnewslider": "Create New Slider",
109108
"components.Discover.customizediscover": "Customize Discover",
110109
"components.Discover.discover": "Discover",
@@ -138,6 +137,7 @@
138137
"components.Discover.upcomingtv": "Upcoming Series",
139138
"components.Discover.updatefailed": "Something went wrong updating the discover customization settings.",
140139
"components.Discover.updatesuccess": "Updated discover customization settings.",
140+
"components.DiscoverTvUpcoming.upcomingtv": "Upcoming Series",
141141
"components.DownloadBlock.estimatedtime": "Estimated {time}",
142142
"components.DownloadBlock.formattedTitle": "{title}: Season {seasonNumber} Episode {episodeNumber}",
143143
"components.IssueDetails.IssueComment.areyousuredelete": "Are you sure you want to delete this comment?",
@@ -883,7 +883,6 @@
883883
"components.Settings.SettingsJobsCache.dnscachehits": "Hits",
884884
"components.Settings.SettingsJobsCache.dnscachemisses": "Misses",
885885
"components.Settings.SettingsJobsCache.dnscachename": "Hostname",
886-
"components.Settings.SettingsJobsCache.dnscachenetworkerrors": "Network Errors",
887886
"components.Settings.SettingsJobsCache.download-sync": "Download Sync",
888887
"components.Settings.SettingsJobsCache.download-sync-reset": "Download Sync Reset",
889888
"components.Settings.SettingsJobsCache.editJobSchedule": "Modify Job",
@@ -988,6 +987,8 @@
988987
"components.Settings.SettingsNetwork.csrfProtectionHoverTip": "Do NOT enable this setting unless you understand what you are doing!",
989988
"components.Settings.SettingsNetwork.csrfProtectionTip": "Set external API access to read-only (requires HTTPS)",
990989
"components.Settings.SettingsNetwork.dnsCache": "DNS Cache",
990+
"components.Settings.SettingsNetwork.dnsCacheForceMaxTtl": "DNS Cache Maximum TTL",
991+
"components.Settings.SettingsNetwork.dnsCacheForceMinTtl": "DNS Cache Minimum TTL",
991992
"components.Settings.SettingsNetwork.dnsCacheHoverTip": "Do NOT enable this if you are experiencing issues with DNS lookups",
992993
"components.Settings.SettingsNetwork.dnsCacheTip": "Enable caching of DNS lookups to optimize performance and avoid making unnecessary API calls",
993994
"components.Settings.SettingsNetwork.docs": "documentation",
@@ -1224,7 +1225,7 @@
12241225
"components.Setup.librarieserror": "Validation failed. Please toggle the libraries again to continue.",
12251226
"components.Setup.servertype": "Choose Server Type",
12261227
"components.Setup.setup": "Setup",
1227-
"components.Setup.signin": "Sign In",
1228+
"components.Setup.signin": "Sign in to your account",
12281229
"components.Setup.signinMessage": "Get started by signing in",
12291230
"components.Setup.signinWithEmby": "Enter your Emby details",
12301231
"components.Setup.signinWithJellyfin": "Enter your Jellyfin details",

0 commit comments

Comments
 (0)