summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOdd Stranne <odd@mullvad.net>2022-03-30 20:04:13 +0200
committerOskar Nyberg <oskar@mullvad.net>2022-04-25 14:29:35 +0200
commit5f25b79b631ffb0a4d99ef004ab177b2cbbb0606 (patch)
tree447d9a5eda1524af86391deb4928be2239059032
parent92ccdc17551ef40c3d76448e41886d910462d775 (diff)
downloadmullvadvpn-5f25b79b631ffb0a4d99ef004ab177b2cbbb0606.tar.xz
mullvadvpn-5f25b79b631ffb0a4d99ef004ab177b2cbbb0606.zip
Extend DNS blocking in GUI
-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
6 files changed, 73 insertions, 16 deletions
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;
};
}