From e67ded577e10355b115b78600924bba797afabc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20L=C3=B6nnhager?= Date: Fri, 29 Sep 2023 13:49:06 +0200 Subject: [PATCH] Add social media blocking server --- gui/locales/messages.pot | 5 ++++ gui/src/main/daemon-rpc.ts | 2 ++ gui/src/main/default-settings.ts | 1 + .../renderer/components/CustomDnsSettings.tsx | 3 ++- gui/src/renderer/components/VpnSettings.tsx | 26 +++++++++++++++++++ gui/src/renderer/redux/settings/reducers.ts | 1 + gui/src/shared/daemon-rpc-types.ts | 1 + 7 files changed, 38 insertions(+), 1 deletion(-) diff --git a/gui/locales/messages.pot b/gui/locales/messages.pot index b8b5552ecd92..26035a4321a8 100644 --- a/gui/locales/messages.pot +++ b/gui/locales/messages.pot @@ -1453,6 +1453,11 @@ msgctxt "vpn-settings-view" msgid "Malware" msgstr "" +#. Label for settings that enables block of social media. +msgctxt "vpn-settings-view" +msgid "Social media" +msgstr "" + msgctxt "vpn-settings-view" msgid "The app’s built-in kill switch is always on. This setting will additionally block the internet if clicking Disconnect or Quit." msgstr "" diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts index ed9fb77b486b..fbaa2fe9d9c9 100644 --- a/gui/src/main/daemon-rpc.ts +++ b/gui/src/main/daemon-rpc.ts @@ -539,6 +539,7 @@ export class DaemonRpc { defaultOptions.setBlockMalware(dns.defaultOptions.blockMalware); defaultOptions.setBlockAdultContent(dns.defaultOptions.blockAdultContent); defaultOptions.setBlockGambling(dns.defaultOptions.blockGambling); + defaultOptions.setBlockSocialMedia(dns.defaultOptions.blockSocialMedia); dnsOptions.setDefaultOptions(defaultOptions); const customOptions = new grpcTypes.CustomDnsOptions(); @@ -1272,6 +1273,7 @@ function convertFromTunnelOptions(tunnelOptions: grpcTypes.TunnelOptions.AsObjec blockMalware: tunnelOptions.dnsOptions?.defaultOptions?.blockMalware ?? false, blockAdultContent: tunnelOptions.dnsOptions?.defaultOptions?.blockAdultContent ?? false, blockGambling: tunnelOptions.dnsOptions?.defaultOptions?.blockGambling ?? false, + blockSocialMedia: tunnelOptions.dnsOptions?.defaultOptions?.blockSocialMedia ?? false, }, customOptions: { addresses: tunnelOptions.dnsOptions?.customOptions?.addressesList ?? [], diff --git a/gui/src/main/default-settings.ts b/gui/src/main/default-settings.ts index 9989575f8052..40c75042f8f1 100644 --- a/gui/src/main/default-settings.ts +++ b/gui/src/main/default-settings.ts @@ -55,6 +55,7 @@ export function getDefaultSettings(): ISettings { blockMalware: false, blockAdultContent: false, blockGambling: false, + blockSocialMedia: false, }, customOptions: { addresses: [], diff --git a/gui/src/renderer/components/CustomDnsSettings.tsx b/gui/src/renderer/components/CustomDnsSettings.tsx index fbf7d3dce01f..824e0109704d 100644 --- a/gui/src/renderer/components/CustomDnsSettings.tsx +++ b/gui/src/renderer/components/CustomDnsSettings.tsx @@ -52,7 +52,8 @@ export default function CustomDnsSettings() { !dns.defaultOptions.blockTrackers && !dns.defaultOptions.blockMalware && !dns.defaultOptions.blockAdultContent && - !dns.defaultOptions.blockGambling), + !dns.defaultOptions.blockGambling && + !dns.defaultOptions.blockSocialMedia), [dns], ); diff --git a/gui/src/renderer/components/VpnSettings.tsx b/gui/src/renderer/components/VpnSettings.tsx index 676ae4f48487..13a4503d7167 100644 --- a/gui/src/renderer/components/VpnSettings.tsx +++ b/gui/src/renderer/components/VpnSettings.tsx @@ -285,6 +285,7 @@ function DnsBlockers() { + ); } @@ -420,6 +421,31 @@ function BlockAdultContent() { /> + + ); +} + +function BlockSocialMedia() { + const [dns, setBlockSocialMedia] = useDns('blockSocialMedia'); + + return ( + + + + + { + // TRANSLATORS: Label for settings that enables block of social media. + messages.pgettext('vpn-settings-view', 'Social media') + } + + + + + + {dns.state === 'custom' && } ); diff --git a/gui/src/renderer/redux/settings/reducers.ts b/gui/src/renderer/redux/settings/reducers.ts index 576253bb4877..2030d70844fd 100644 --- a/gui/src/renderer/redux/settings/reducers.ts +++ b/gui/src/renderer/redux/settings/reducers.ts @@ -155,6 +155,7 @@ const initialState: ISettingsReduxState = { blockMalware: false, blockAdultContent: false, blockGambling: false, + blockSocialMedia: false, }, customOptions: { addresses: [], diff --git a/gui/src/shared/daemon-rpc-types.ts b/gui/src/shared/daemon-rpc-types.ts index a336d00d2794..9af927070afd 100644 --- a/gui/src/shared/daemon-rpc-types.ts +++ b/gui/src/shared/daemon-rpc-types.ts @@ -328,6 +328,7 @@ export interface IDnsOptions { blockMalware: boolean; blockAdultContent: boolean; blockGambling: boolean; + blockSocialMedia: boolean; }; }