From 7ce592542622747c7e3e3e273f8c50c09a6ac945 Mon Sep 17 00:00:00 2001 From: gauthier-th Date: Tue, 18 Jun 2024 19:29:56 +0200 Subject: [PATCH] feat: add custom DNS servers --- server/index.ts | 10 ++++++ server/lib/settings/index.ts | 1 + .../Settings/SettingsMain/index.tsx | 36 +++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/server/index.ts b/server/index.ts index a9a746562..08bdf87bf 100644 --- a/server/index.ts +++ b/server/index.ts @@ -84,6 +84,16 @@ app const settings = getSettings().load(); restartFlag.initializeSettings(settings.main); + // Overwrite DNS servers + if (settings.main.overwriteDnsServers) { + cacheable.servers = settings.main.overwriteDnsServers + .split(',') + .map((server) => server.trim()); + logger.info('Using custom DNS servers', { + label: 'Settings', + }); + } + // Migrate library types if ( settings.plex.libraries.length > 1 && diff --git a/server/lib/settings/index.ts b/server/lib/settings/index.ts index ad613cc30..8eada00b1 100644 --- a/server/lib/settings/index.ts +++ b/server/lib/settings/index.ts @@ -118,6 +118,7 @@ export interface MainSettings { mediaServerType: number; partialRequestsEnabled: boolean; locale: string; + overwriteDnsServers?: string; } interface PublicSettings { diff --git a/src/components/Settings/SettingsMain/index.tsx b/src/components/Settings/SettingsMain/index.tsx index b9f285ce7..d6a5fff53 100644 --- a/src/components/Settings/SettingsMain/index.tsx +++ b/src/components/Settings/SettingsMain/index.tsx @@ -55,6 +55,9 @@ const messages = defineMessages({ validationApplicationUrlTrailingSlash: 'URL must not end in a trailing slash', partialRequestsEnabled: 'Allow Partial Series Requests', locale: 'Display Language', + overwriteDnsServers: 'Overwrite Default DNS Servers', + overwriteDnsServersTip: + 'A comma-separated list of DNS server to use instead of the default ones', }); const SettingsMain = () => { @@ -134,6 +137,7 @@ const SettingsMain = () => { partialRequestsEnabled: data?.partialRequestsEnabled, trustProxy: data?.trustProxy, cacheImages: data?.cacheImages, + overwriteDnsServers: data?.overwriteDnsServers, }} enableReinitialize validationSchema={MainSettingsSchema} @@ -150,6 +154,7 @@ const SettingsMain = () => { partialRequestsEnabled: values.partialRequestsEnabled, trustProxy: values.trustProxy, cacheImages: values.cacheImages, + overwriteDnsServers: values.overwriteDnsServers, }); mutate('/api/v1/settings/public'); mutate('/api/v1/status'); @@ -427,6 +432,37 @@ const SettingsMain = () => { /> +
+ +
+
+ +
+ {errors.overwriteDnsServers && + touched.overwriteDnsServers && + typeof errors.overwriteDnsServers === 'string' && ( +
+ {errors.overwriteDnsServers} +
+ )} +
+