summaryrefslogtreecommitdiffhomepage
path: root/gui
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2022-04-25 15:07:03 +0200
committerOskar Nyberg <oskar@mullvad.net>2022-04-25 15:07:03 +0200
commitbc686e487e4d0eb48d7d884bb74f5d30130d60d3 (patch)
treed3f2c6af2acd9871859795b7a82c251c2d1ac9af /gui
parent3df0b46aef719777e72641c59f3dac0f5be754a3 (diff)
parent1457595ef6ab9ea7acd29c2be915b99c14c12fd1 (diff)
downloadmullvadvpn-bc686e487e4d0eb48d7d884bb74f5d30130d60d3.tar.xz
mullvadvpn-bc686e487e4d0eb48d7d884bb74f5d30130d60d3.zip
Merge branch 'extend-dns-blocking'
Diffstat (limited to 'gui')
-rw-r--r--gui/locales/messages.pot27
-rw-r--r--gui/src/main/daemon-rpc.ts4
-rw-r--r--gui/src/main/index.ts2
-rw-r--r--gui/src/renderer/components/CustomDnsSettings.tsx21
-rw-r--r--gui/src/renderer/components/Preferences.tsx58
-rw-r--r--gui/src/renderer/redux/settings/reducers.ts2
-rw-r--r--gui/src/shared/daemon-rpc-types.ts2
7 files changed, 89 insertions, 27 deletions
diff --git a/gui/locales/messages.pot b/gui/locales/messages.pot
index 7de976a7e4..e61ed3eb0a 100644
--- a/gui/locales/messages.pot
+++ b/gui/locales/messages.pot
@@ -969,23 +969,19 @@ msgid "Block ads"
msgstr ""
msgctxt "preferences-view"
-msgid "Block malware"
+msgid "Block adult content"
msgstr ""
msgctxt "preferences-view"
-msgid "Block trackers"
+msgid "Block gambling"
+msgstr ""
+
+msgctxt "preferences-view"
+msgid "Block malware"
msgstr ""
-#. This is displayed when either or both of the block ads/trackers settings are
-#. turned on which makes the custom DNS setting disabled. The text enclosed in "**"
-#. will appear bold.
-#. Available placeholders:
-#. %(blockAdsFeatureName)s - The name displayed next to the "Block ads" toggle.
-#. %(blockTrackersFeatureName)s - The name displayed next to the "Block trackers" toggle.
-#. %(blockMalwareFeatureName)s - The name displayed next to the "Block malware" toggle.
-#. %(preferencesPageName)s - The page title showed on top in the preferences page.
msgctxt "preferences-view"
-msgid "Disable **%(blockAdsFeatureName)s**, **%(blockTrackersFeatureName)s** and **%(blockMalwareFeatureName)s** (under %(preferencesPageName)s) to activate this setting."
+msgid "Block trackers"
msgstr ""
#. This is displayed when the custom DNS setting is turned on which makes the block
@@ -997,6 +993,15 @@ msgctxt "preferences-view"
msgid "Disable **%(customDnsFeatureName)s** (under Advanced settings) to activate these settings."
msgstr ""
+#. This is displayed when either or both of the block ads/trackers settings are
+#. turned on which makes the custom DNS setting disabled. The text enclosed in "**"
+#. will appear bold.
+#. Available placeholders:
+#. %(preferencesPageName)s - The page title showed on top in the preferences page.
+msgctxt "preferences-view"
+msgid "Disable all content blockers (under %(preferencesPageName)s) to activate this setting."
+msgstr ""
+
msgctxt "preferences-view"
msgid "Enable or disable system notifications. The critical notifications will always be displayed."
msgstr ""
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts
index 52c43441a6..029936093f 100644
--- a/gui/src/main/daemon-rpc.ts
+++ b/gui/src/main/daemon-rpc.ts
@@ -463,6 +463,8 @@ export class DaemonRpc {
defaultOptions.setBlockAds(dns.defaultOptions.blockAds);
defaultOptions.setBlockTrackers(dns.defaultOptions.blockTrackers);
defaultOptions.setBlockMalware(dns.defaultOptions.blockMalware);
+ defaultOptions.setBlockAdultContent(dns.defaultOptions.blockAdultContent);
+ defaultOptions.setBlockGambling(dns.defaultOptions.blockGambling);
dnsOptions.setDefaultOptions(defaultOptions);
const customOptions = new grpcTypes.CustomDnsOptions();
@@ -1131,6 +1133,8 @@ function convertFromTunnelOptions(tunnelOptions: grpcTypes.TunnelOptions.AsObjec
blockAds: tunnelOptions.dnsOptions?.defaultOptions?.blockAds ?? false,
blockTrackers: tunnelOptions.dnsOptions?.defaultOptions?.blockTrackers ?? false,
blockMalware: tunnelOptions.dnsOptions?.defaultOptions?.blockMalware ?? false,
+ blockAdultContent: tunnelOptions.dnsOptions?.defaultOptions?.blockAdultContent ?? false,
+ blockGambling: tunnelOptions.dnsOptions?.defaultOptions?.blockGambling ?? false,
},
customOptions: {
addresses: tunnelOptions.dnsOptions?.customOptions?.addressesList ?? [],
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts
index 8acdac16a0..c1fb5407f7 100644
--- a/gui/src/main/index.ts
+++ b/gui/src/main/index.ts
@@ -197,6 +197,8 @@ class ApplicationMain {
blockAds: false,
blockTrackers: false,
blockMalware: false,
+ blockAdultContent: false,
+ blockGambling: false,
},
customOptions: {
addresses: [],
diff --git a/gui/src/renderer/components/CustomDnsSettings.tsx b/gui/src/renderer/components/CustomDnsSettings.tsx
index 3ab38cf3c3..9c976062c1 100644
--- a/gui/src/renderer/components/CustomDnsSettings.tsx
+++ b/gui/src/renderer/components/CustomDnsSettings.tsx
@@ -49,7 +49,9 @@ export default function CustomDnsSettings() {
dns.state === 'custom' ||
(!dns.defaultOptions.blockAds &&
!dns.defaultOptions.blockTrackers &&
- !dns.defaultOptions.blockMalware),
+ !dns.defaultOptions.blockMalware &&
+ !dns.defaultOptions.blockAdultContent &&
+ !dns.defaultOptions.blockGambling),
[dns],
);
@@ -281,32 +283,19 @@ export default function CustomDnsSettings() {
}
function DisabledMessage() {
- const blockAdsFeatureName = messages.pgettext('preferences-view', 'Block ads');
- const blockTrackersFeatureName = messages.pgettext('preferences-view', 'Block trackers');
- const blockMalwareFeatureName = messages.pgettext('preferences-view', 'Block malware');
const preferencesPageName = messages.pgettext('preferences-nav', 'Preferences');
// TRANSLATORS: This is displayed when either or both of the block ads/trackers settings are
// TRANSLATORS: turned on which makes the custom DNS setting disabled. The text enclosed in "**"
// TRANSLATORS: will appear bold.
// TRANSLATORS: Available placeholders:
- // TRANSLATORS: %(blockAdsFeatureName)s - The name displayed next to the "Block ads" toggle.
- // TRANSLATORS: %(blockTrackersFeatureName)s - The name displayed next to the "Block trackers" toggle.
- // TRANSLATORS: %(blockMalwareFeatureName)s - The name displayed next to the "Block malware" toggle.
// TRANSLATORS: %(preferencesPageName)s - The page title showed on top in the preferences page.
const customDnsDisabledMessage = messages.pgettext(
'preferences-view',
- 'Disable **%(blockAdsFeatureName)s**, **%(blockTrackersFeatureName)s** and **%(blockMalwareFeatureName)s** (under %(preferencesPageName)s) to activate this setting.',
+ 'Disable all content blockers (under %(preferencesPageName)s) to activate this setting.',
);
- return formatMarkdown(
- sprintf(customDnsDisabledMessage, {
- blockAdsFeatureName,
- blockTrackersFeatureName,
- blockMalwareFeatureName,
- preferencesPageName,
- }),
- );
+ return formatMarkdown(sprintf(customDnsDisabledMessage, { preferencesPageName }));
}
interface ICellListItemProps {
diff --git a/gui/src/renderer/components/Preferences.tsx b/gui/src/renderer/components/Preferences.tsx
index 9213c7c7e9..0d6fea3809 100644
--- a/gui/src/renderer/components/Preferences.tsx
+++ b/gui/src/renderer/components/Preferences.tsx
@@ -181,6 +181,44 @@ export default class Preferences extends React.Component<IProps, IState> {
/>
</AriaInput>
</Cell.Container>
+ </AriaInputGroup>
+ <StyledSeparator />
+ <AriaInputGroup>
+ <Cell.Container disabled={this.props.dns.state === 'custom'}>
+ <AriaLabel>
+ <Cell.InputLabel>
+ {messages.pgettext('preferences-view', 'Block adult content')}
+ </Cell.InputLabel>
+ </AriaLabel>
+ <AriaInput>
+ <Cell.Switch
+ isOn={
+ this.props.dns.state === 'default' &&
+ this.props.dns.defaultOptions.blockAdultContent
+ }
+ onChange={this.setBlockAdultContent}
+ />
+ </AriaInput>
+ </Cell.Container>
+ </AriaInputGroup>
+ <StyledSeparator />
+ <AriaInputGroup>
+ <Cell.Container disabled={this.props.dns.state === 'custom'}>
+ <AriaLabel>
+ <Cell.InputLabel>
+ {messages.pgettext('preferences-view', 'Block gambling')}
+ </Cell.InputLabel>
+ </AriaLabel>
+ <AriaInput>
+ <Cell.Switch
+ isOn={
+ this.props.dns.state === 'default' &&
+ this.props.dns.defaultOptions.blockGambling
+ }
+ onChange={this.setBlockGambling}
+ />
+ </AriaInput>
+ </Cell.Container>
{this.props.dns.state === 'custom' && <CustomDnsEnabledFooter />}
</AriaInputGroup>
@@ -404,6 +442,26 @@ export default class Preferences extends React.Component<IProps, IState> {
});
};
+ private setBlockAdultContent = async (enabled: boolean) => {
+ await this.props.setDnsOptions({
+ ...this.props.dns,
+ defaultOptions: {
+ ...this.props.dns.defaultOptions,
+ blockAdultContent: enabled,
+ },
+ });
+ };
+
+ private setBlockGambling = async (enabled: boolean) => {
+ await this.props.setDnsOptions({
+ ...this.props.dns,
+ defaultOptions: {
+ ...this.props.dns.defaultOptions,
+ blockGambling: enabled,
+ },
+ });
+ };
+
private showKillSwitchInfo = () => {
this.setState({ showKillSwitchInfo: true });
};
diff --git a/gui/src/renderer/redux/settings/reducers.ts b/gui/src/renderer/redux/settings/reducers.ts
index 3d665ba86b..1c759e1a52 100644
--- a/gui/src/renderer/redux/settings/reducers.ts
+++ b/gui/src/renderer/redux/settings/reducers.ts
@@ -138,6 +138,8 @@ const initialState: ISettingsReduxState = {
blockAds: false,
blockTrackers: false,
blockMalware: false,
+ blockAdultContent: false,
+ blockGambling: false,
},
customOptions: {
addresses: [],
diff --git a/gui/src/shared/daemon-rpc-types.ts b/gui/src/shared/daemon-rpc-types.ts
index b08f375e96..dc3088cc80 100644
--- a/gui/src/shared/daemon-rpc-types.ts
+++ b/gui/src/shared/daemon-rpc-types.ts
@@ -290,6 +290,8 @@ export interface IDnsOptions {
blockAds: boolean;
blockTrackers: boolean;
blockMalware: boolean;
+ blockAdultContent: boolean;
+ blockGambling: boolean;
};
}