Skip to content

Commit e125f6a

Browse files
Merge branch 'remove-automatic-tunnel-option-from-gui-des-1787'
2 parents 44f98be + c4d84fc commit e125f6a

18 files changed

+92
-141
lines changed

desktop/packages/mullvad-vpn/locales/messages.pot

+3-3
Original file line numberDiff line numberDiff line change
@@ -1312,8 +1312,8 @@ msgstr ""
13121312
#. available.
13131313
#. Available placeholders:
13141314
#. %(transportProtocol)s - the name of the transport protocol setting
1315-
#. %(automat)s - the translation of "Automatic"
1316-
#. %(openvpn)s - will be replaced with OpenVPN
1315+
#. %(automatic)s - the translation of "Automatic"
1316+
#. %(tcp)s - the translation of "TCP"
13171317
msgctxt "openvpn-settings-view"
13181318
msgid "To activate Bridge mode, change <b>%(transportProtocol)s</b> to <b>%(automatic)s</b> or <b>%(tcp)s</b>."
13191319
msgstr ""
@@ -2217,7 +2217,7 @@ msgid "Shadowsocks"
22172217
msgstr ""
22182218

22192219
msgctxt "wireguard-settings-view"
2220-
msgid "Switch to “%(wireguard)s” or “%(automatic)s” in Settings > %(tunnelProtocol)s to make %(setting)s available."
2220+
msgid "Switch to “%(wireguard)s” in Settings > %(tunnelProtocol)s to make %(setting)s available."
22212221
msgstr ""
22222222

22232223
msgctxt "wireguard-settings-view"

desktop/packages/mullvad-vpn/src/main/default-settings.ts

+26-16
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
11
import {
22
ApiAccessMethodSettings,
3+
IOpenVpnConstraints,
4+
IRelaySettingsNormal,
35
ISettings,
6+
IWireguardConstraints,
47
ObfuscationType,
58
Ownership,
69
} from '../shared/daemon-rpc-types';
710

11+
export function getDefaultRelaySettingsNormal(): IRelaySettingsNormal<
12+
IOpenVpnConstraints,
13+
IWireguardConstraints
14+
> {
15+
return {
16+
location: 'any',
17+
tunnelProtocol: 'wireguard',
18+
providers: [],
19+
ownership: Ownership.any,
20+
openvpnConstraints: {
21+
port: 'any',
22+
protocol: 'any',
23+
},
24+
wireguardConstraints: {
25+
port: 'any',
26+
ipVersion: 'any',
27+
useMultihop: false,
28+
entryLocation: 'any',
29+
},
30+
};
31+
}
32+
833
export function getDefaultSettings(): ISettings {
934
return {
1035
allowLan: false,
@@ -16,22 +41,7 @@ export function getDefaultSettings(): ISettings {
1641
appsList: [],
1742
},
1843
relaySettings: {
19-
normal: {
20-
location: 'any',
21-
tunnelProtocol: 'any',
22-
providers: [],
23-
ownership: Ownership.any,
24-
openvpnConstraints: {
25-
port: 'any',
26-
protocol: 'any',
27-
},
28-
wireguardConstraints: {
29-
port: 'any',
30-
ipVersion: 'any',
31-
useMultihop: false,
32-
entryLocation: 'any',
33-
},
34-
},
44+
normal: getDefaultRelaySettingsNormal(),
3545
},
3646
bridgeSettings: {
3747
type: 'normal',

desktop/packages/mullvad-vpn/src/main/grpc-type-convertions.ts

+2-23
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,7 @@ function convertFromRelaySettings(
498498
const normal = relaySettings.getNormal()!;
499499
const locationConstraint = convertFromLocationConstraint(normal.getLocation());
500500
const location = wrapConstraint(locationConstraint);
501-
// `getTunnelType()` is not falsy if type is 'any'
502-
const tunnelProtocol = convertFromTunnelTypeConstraint(
503-
normal.hasTunnelType() ? normal.getTunnelType() : undefined,
504-
);
501+
const tunnelProtocol = convertFromTunnelType(normal.getTunnelType());
505502
const providers = normal.getProvidersList();
506503
const ownership = convertFromOwnership(normal.getOwnership());
507504
const openvpnConstraints = convertFromOpenVpnConstraints(normal.getOpenvpnConstraints()!);
@@ -824,22 +821,6 @@ function convertFromWireguardConstraints(
824821
return result;
825822
}
826823

827-
function convertFromTunnelTypeConstraint(
828-
constraint: grpcTypes.TunnelType | undefined,
829-
): Constraint<TunnelProtocol> {
830-
switch (constraint) {
831-
case grpcTypes.TunnelType.WIREGUARD: {
832-
return { only: 'wireguard' };
833-
}
834-
case grpcTypes.TunnelType.OPENVPN: {
835-
return { only: 'openvpn' };
836-
}
837-
default: {
838-
return 'any';
839-
}
840-
}
841-
}
842-
843824
function convertFromConstraint<T>(value: T | undefined): Constraint<T> {
844825
if (value) {
845826
return { only: value };
@@ -853,9 +834,7 @@ export function convertToRelayConstraints(
853834
): grpcTypes.NormalRelaySettings {
854835
const relayConstraints = new grpcTypes.NormalRelaySettings();
855836

856-
if (constraints.tunnelProtocol !== 'any') {
857-
relayConstraints.setTunnelType(convertToTunnelType(constraints.tunnelProtocol.only));
858-
}
837+
relayConstraints.setTunnelType(convertToTunnelType(constraints.tunnelProtocol));
859838
relayConstraints.setLocation(convertToLocation(unwrapConstraint(constraints.location)));
860839
relayConstraints.setWireguardConstraints(
861840
convertToWireguardConstraints(constraints.wireguardConstraints),

desktop/packages/mullvad-vpn/src/renderer/app.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ export default class AppRenderer {
650650
useMultihop: wireguardConstraints.useMultihop,
651651
entryLocation: liftConstraint(wireguardConstraints.entryLocation),
652652
},
653-
tunnelProtocol: liftConstraint(tunnelProtocol),
653+
tunnelProtocol,
654654
},
655655
});
656656
} else if ('customTunnelEndpoint' in relaySettings) {

desktop/packages/mullvad-vpn/src/renderer/components/DaitaSettings.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,19 @@ function DirectOnlyModalMessage() {
273273
}
274274

275275
function featureUnavailableMessage() {
276-
const automatic = messages.gettext('Automatic');
277276
const tunnelProtocol = messages.pgettext('vpn-settings-view', 'Tunnel protocol');
278277

279278
return sprintf(
280279
messages.pgettext(
280+
// TRANSLATORS: Informs the user that the the feature is only available when WireGuard
281+
// TRANSLATORS: is selected.
282+
// TRANSLATORS: Available placeholders:
283+
// TRANSLATORS: %(wireguard)s - will be replaced with WireGuard
284+
// TRANSLATORS: %(tunnelProtocol)s - the name of the tunnel protocol setting
285+
// TRANSLATORS: %(setting)s - the name of the setting
281286
'wireguard-settings-view',
282-
'Switch to “%(wireguard)s” or “%(automatic)s” in Settings > %(tunnelProtocol)s to make %(setting)s available.',
287+
'Switch to “%(wireguard)s” in Settings > %(tunnelProtocol)s to make %(setting)s available.',
283288
),
284-
{ wireguard: strings.wireguard, automatic, tunnelProtocol, setting: strings.daita },
289+
{ wireguard: strings.wireguard, tunnelProtocol, setting: strings.daita },
285290
);
286291
}

desktop/packages/mullvad-vpn/src/renderer/components/Filter.tsx

+3-12
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ export default function Filter() {
114114

115115
// Returns only the ownership options that are compatible with the other filters
116116
function useFilteredOwnershipOptions(providers: string[], ownership: Ownership): Ownership[] {
117-
const relaySettings = useNormalRelaySettings();
118117
const tunnelProtocol = useTunnelProtocol();
119118
const bridgeState = useSelector((state) => state.settings.bridgeState);
120119
const locations = useSelector((state) => state.settings.relayLocations);
@@ -126,7 +125,6 @@ function useFilteredOwnershipOptions(providers: string[], ownership: Ownership):
126125
locations,
127126
endpointType,
128127
tunnelProtocol,
129-
relaySettings,
130128
);
131129
const relaylistForFilters = filterLocations(relayListForEndpointType, ownership, providers);
132130

@@ -143,14 +141,13 @@ function useFilteredOwnershipOptions(providers: string[], ownership: Ownership):
143141
}
144142

145143
return ownershipOptions;
146-
}, [locations, endpointType, tunnelProtocol, relaySettings, ownership, providers]);
144+
}, [locations, endpointType, tunnelProtocol, ownership, providers]);
147145

148146
return availableOwnershipOptions;
149147
}
150148

151149
// Returns only the providers that are compatible with the other filters
152150
export function useFilteredProviders(providers: string[], ownership: Ownership): string[] {
153-
const relaySettings = useNormalRelaySettings();
154151
const tunnelProtocol = useTunnelProtocol();
155152
const bridgeState = useSelector((state) => state.settings.bridgeState);
156153
const locations = useSelector((state) => state.settings.relayLocations);
@@ -162,11 +159,10 @@ export function useFilteredProviders(providers: string[], ownership: Ownership):
162159
locations,
163160
endpointType,
164161
tunnelProtocol,
165-
relaySettings,
166162
);
167163
const relaylistForFilters = filterLocations(relayListForEndpointType, ownership, providers);
168164
return providersFromRelays(relaylistForFilters);
169-
}, [endpointType, locations, ownership, providers, relaySettings, tunnelProtocol]);
165+
}, [endpointType, locations, ownership, providers, tunnelProtocol]);
170166

171167
return availableProviders;
172168
}
@@ -188,12 +184,7 @@ function useProviders(): Record<string, boolean> {
188184

189185
const endpointType =
190186
tunnelProtocol === 'openvpn' && bridgeState === 'on' ? EndpointType.any : EndpointType.exit;
191-
const relays = filterLocationsByEndPointType(
192-
relayLocations,
193-
endpointType,
194-
tunnelProtocol,
195-
relaySettings,
196-
);
187+
const relays = filterLocationsByEndPointType(relayLocations, endpointType, tunnelProtocol);
197188
const providers = providersFromRelays(relays);
198189

199190
// Empty containt array means that all providers are selected. No selection isn't possible.

desktop/packages/mullvad-vpn/src/renderer/components/MultihopSettings.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,20 @@ function MultihopSetting() {
106106
}
107107

108108
function featureUnavailableMessage() {
109-
const automatic = messages.gettext('Automatic');
110109
const tunnelProtocol = messages.pgettext('vpn-settings-view', 'Tunnel protocol');
111110
const multihop = messages.pgettext('wireguard-settings-view', 'Multihop');
112111

113112
return sprintf(
114113
messages.pgettext(
114+
// TRANSLATORS: Informs the user that the the feature is only available when WireGuard
115+
// TRANSLATORS: is selected.
116+
// TRANSLATORS: Available placeholders:
117+
// TRANSLATORS: %(wireguard)s - will be replaced with WireGuard
118+
// TRANSLATORS: %(tunnelProtocol)s - the name of the tunnel protocol setting
119+
// TRANSLATORS: %(setting)s - the name of the setting
115120
'wireguard-settings-view',
116-
'Switch to “%(wireguard)s” or “%(automatic)s” in Settings > %(tunnelProtocol)s to make %(setting)s available.',
121+
'Switch to “%(wireguard)s” in Settings > %(tunnelProtocol)s to make %(setting)s available.',
117122
),
118-
{ wireguard: strings.wireguard, automatic, tunnelProtocol, setting: multihop },
123+
{ wireguard: strings.wireguard, tunnelProtocol, setting: multihop },
119124
);
120125
}

desktop/packages/mullvad-vpn/src/renderer/components/OpenVpnSettings.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,8 @@ function bridgeModeFooterText(
375375
// TRANSLATORS: available.
376376
// TRANSLATORS: Available placeholders:
377377
// TRANSLATORS: %(transportProtocol)s - the name of the transport protocol setting
378-
// TRANSLATORS: %(automat)s - the translation of "Automatic"
379-
// TRANSLATORS: %(openvpn)s - will be replaced with OpenVPN
378+
// TRANSLATORS: %(automatic)s - the translation of "Automatic"
379+
// TRANSLATORS: %(tcp)s - the translation of "TCP"
380380
messages.pgettext(
381381
'openvpn-settings-view',
382382
'To activate Bridge mode, change <b>%(transportProtocol)s</b> to <b>%(automatic)s</b> or <b>%(tcp)s</b>.',

desktop/packages/mullvad-vpn/src/renderer/components/VpnSettings.tsx

+7-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { sprintf } from 'sprintf-js';
33
import styled from 'styled-components';
44

55
import { strings } from '../../shared/constants';
6-
import { IDnsOptions, TunnelProtocol, wrapConstraint } from '../../shared/daemon-rpc-types';
6+
import { IDnsOptions, TunnelProtocol } from '../../shared/daemon-rpc-types';
77
import { messages } from '../../shared/gettext';
88
import log from '../../shared/logging';
99
import { useAppContext } from '../context';
@@ -664,9 +664,8 @@ function LockdownMode() {
664664
}
665665

666666
function TunnelProtocolSetting() {
667-
const tunnelProtocol = useSelector((state) =>
668-
mapRelaySettingsToProtocol(state.settings.relaySettings),
669-
);
667+
const tunnelProtocol = useTunnelProtocol();
668+
670669
const relaySettingsUpdater = useRelaySettingsUpdater();
671670

672671
const relaySettings = useSelector((state) => state.settings.relaySettings);
@@ -689,11 +688,11 @@ function TunnelProtocolSetting() {
689688
}
690689

691690
const setTunnelProtocol = useCallback(
692-
async (tunnelProtocol: TunnelProtocol | null) => {
691+
async (tunnelProtocol: TunnelProtocol) => {
693692
try {
694693
await relaySettingsUpdater((settings) => ({
695694
...settings,
696-
tunnelProtocol: wrapConstraint(tunnelProtocol),
695+
tunnelProtocol,
697696
}));
698697
} catch (e) {
699698
const error = e as Error;
@@ -723,9 +722,8 @@ function TunnelProtocolSetting() {
723722
<Selector
724723
title={messages.pgettext('vpn-settings-view', 'Tunnel protocol')}
725724
items={tunnelProtocolItems}
726-
value={tunnelProtocol ?? null}
725+
value={tunnelProtocol}
727726
onSelect={setTunnelProtocol}
728-
automaticValue={null}
729727
/>
730728
{openVpnDisabled ? (
731729
<Cell.CellFooter>
@@ -749,7 +747,7 @@ function TunnelProtocolSetting() {
749747
function mapRelaySettingsToProtocol(relaySettings: RelaySettingsRedux) {
750748
if ('normal' in relaySettings) {
751749
const { tunnelProtocol } = relaySettings.normal;
752-
return tunnelProtocol === 'any' ? undefined : tunnelProtocol;
750+
return tunnelProtocol;
753751
// since the GUI doesn't display custom settings, just display the default ones.
754752
// If the user sets any settings, then those will be applied.
755753
} else if ('customTunnelEndpoint' in relaySettings) {

desktop/packages/mullvad-vpn/src/renderer/components/select-location/RelayListContext.tsx

+4-9
Original file line numberDiff line numberDiff line change
@@ -78,29 +78,24 @@ export function RelayListContextProvider(props: RelayListContextProviderProps) {
7878
const relayListForEndpointType = useMemo(() => {
7979
const endpointType =
8080
locationType === LocationType.entry ? EndpointType.entry : EndpointType.exit;
81-
return filterLocationsByEndPointType(
82-
fullRelayList,
83-
endpointType,
84-
tunnelProtocol,
85-
relaySettings,
86-
);
87-
}, [fullRelayList, locationType, relaySettings, tunnelProtocol]);
81+
return filterLocationsByEndPointType(fullRelayList, endpointType, tunnelProtocol);
82+
}, [fullRelayList, locationType, tunnelProtocol]);
8883

8984
const relayListForDaita = useMemo(() => {
9085
return filterLocationsByDaita(
9186
relayListForEndpointType,
9287
daita,
9388
directOnly,
9489
locationType,
95-
relaySettings?.tunnelProtocol ?? 'any',
90+
tunnelProtocol,
9691
relaySettings?.wireguard.useMultihop ?? false,
9792
);
9893
}, [
9994
daita,
10095
directOnly,
10196
locationType,
10297
relayListForEndpointType,
103-
relaySettings?.tunnelProtocol,
98+
tunnelProtocol,
10499
relaySettings?.wireguard.useMultihop,
105100
]);
106101

desktop/packages/mullvad-vpn/src/renderer/components/select-location/SelectLocation.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { useRelaySettingsUpdater } from '../../lib/constraint-updater';
99
import { daitaFilterActive, filterSpecialLocations } from '../../lib/filter-locations';
1010
import { useHistory } from '../../lib/history';
1111
import { formatHtml } from '../../lib/html-formatter';
12-
import { useNormalRelaySettings } from '../../lib/relay-settings-hooks';
12+
import { useNormalRelaySettings, useTunnelProtocol } from '../../lib/relay-settings-hooks';
1313
import { RoutePath } from '../../lib/routes';
1414
import { useSelector } from '../../redux/store';
1515
import { AppNavigationHeader } from '../';
@@ -56,6 +56,7 @@ export default function SelectLocation() {
5656
const { expandSearchResults } = useRelayListContext();
5757

5858
const relaySettings = useNormalRelaySettings();
59+
const tunnelProtocol = useTunnelProtocol();
5960
const ownership = relaySettings?.ownership ?? Ownership.any;
6061
const providers = relaySettings?.providers ?? [];
6162
const filteredProviders = useFilteredProviders(providers, ownership);
@@ -65,7 +66,7 @@ export default function SelectLocation() {
6566
daita,
6667
directOnly,
6768
locationType,
68-
relaySettings?.tunnelProtocol ?? 'any',
69+
tunnelProtocol,
6970
relaySettings?.wireguard.useMultihop ?? false,
7071
);
7172

@@ -74,7 +75,6 @@ export default function SelectLocation() {
7475
const onClose = useCallback(() => history.pop(), [history]);
7576
const onViewFilter = useCallback(() => history.push(RoutePath.filter), [history]);
7677

77-
const tunnelProtocol = relaySettings?.tunnelProtocol ?? 'any';
7878
const bridgeState = useSelector((state) => state.settings.bridgeState);
7979
const allowEntrySelection =
8080
(tunnelProtocol === 'openvpn' && bridgeState === 'on') ||

0 commit comments

Comments
 (0)