summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2021-11-03 00:19:05 +0100
committerOskar Nyberg <oskar@mullvad.net>2022-03-14 13:58:44 +0100
commitb43833503ba221d775e2f6196ad6e0dec0929756 (patch)
treede0c68c2b049a0ea3f659aa73f10869ebd7e8230 /gui/src
parent6459ae7beefcc5f13eb54254dfe402dd807c62fe (diff)
downloadmullvadvpn-b43833503ba221d775e2f6196ad6e0dec0929756.tar.xz
mullvadvpn-b43833503ba221d775e2f6196ad6e0dec0929756.zip
Remove everything related to WireGuard key handling
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/main/daemon-rpc.ts47
-rw-r--r--gui/src/main/index.ts83
-rw-r--r--gui/src/renderer/app.tsx43
-rw-r--r--gui/src/renderer/components/AdvancedSettings.tsx67
-rw-r--r--gui/src/renderer/components/AdvancedSettingsStyles.tsx11
-rw-r--r--gui/src/renderer/components/AppRouter.tsx2
-rw-r--r--gui/src/renderer/components/NotificationArea.tsx8
-rw-r--r--gui/src/renderer/components/WireguardKeys.tsx345
-rw-r--r--gui/src/renderer/components/WireguardKeysStyles.tsx59
-rw-r--r--gui/src/renderer/components/WireguardSettings.tsx10
-rw-r--r--gui/src/renderer/containers/AdvancedSettingsPage.tsx1
-rw-r--r--gui/src/renderer/containers/WireguardKeysPage.tsx27
-rw-r--r--gui/src/renderer/containers/WireguardSettingsPage.tsx3
-rw-r--r--gui/src/renderer/lib/routes.ts1
-rw-r--r--gui/src/renderer/redux/settings/actions.ts99
-rw-r--r--gui/src/renderer/redux/settings/reducers.ts163
-rw-r--r--gui/src/shared/daemon-rpc-types.ts13
-rw-r--r--gui/src/shared/ipc-schema.ts9
-rw-r--r--gui/src/shared/localization-contexts.ts2
-rw-r--r--gui/src/shared/notifications/no-valid-key.ts38
-rw-r--r--gui/src/shared/notifications/notification.ts1
21 files changed, 24 insertions, 1008 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts
index 6638799e2f..6f11a36100 100644
--- a/gui/src/main/daemon-rpc.ts
+++ b/gui/src/main/daemon-rpc.ts
@@ -36,8 +36,6 @@ import {
TunnelType,
IProxyEndpoint,
ProxyType,
- KeygenEvent,
- IWireguardPublicKey,
ISettings,
ConnectionConfig,
DaemonEvent,
@@ -438,19 +436,6 @@ export class DaemonRpc {
return response.getValue();
}
- public async generateWireguardKey(): Promise<KeygenEvent> {
- const response = await this.callEmpty<grpcTypes.KeygenEvent>(this.client.generateWireguardKey);
- return convertFromKeygenEvent(response);
- }
-
- public async getWireguardKey(): Promise<IWireguardPublicKey> {
- const response = await this.callEmpty<grpcTypes.PublicKey>(this.client.getWireguardKey);
- return {
- created: response.getCreated()!.toDate().toISOString(),
- key: convertFromWireguardKey(response.getKey()),
- };
- }
-
public async setDnsOptions(dns: IDnsOptions): Promise<void> {
const dnsOptions = new grpcTypes.DnsOptions();
@@ -473,11 +458,6 @@ export class DaemonRpc {
await this.call<grpcTypes.DnsOptions, Empty>(this.client.setDnsOptions, dnsOptions);
}
- public async verifyWireguardKey(): Promise<boolean> {
- const response = await this.callEmpty<BoolValue>(this.client.verifyWireguardKey);
- return response.getValue();
- }
-
public async getVersionInfo(): Promise<IAppVersionInfo> {
const response = await this.callEmpty<grpcTypes.AppVersionInfo>(this.client.getVersionInfo);
return response.toObject();
@@ -1123,38 +1103,11 @@ function convertFromDaemonEvent(data: grpcTypes.DaemonEvent): DaemonEvent {
};
}
- const keygenEvent = data.getKeyEvent();
- if (keygenEvent !== undefined) {
- return {
- wireguardKey: convertFromKeygenEvent(keygenEvent),
- };
- }
-
return {
appVersionInfo: data.getVersionInfo()!.toObject(),
};
}
-function convertFromKeygenEvent(data: grpcTypes.KeygenEvent): KeygenEvent {
- switch (data.getEvent()) {
- case grpcTypes.KeygenEvent.KeygenEvent.TOO_MANY_KEYS:
- return 'too_many_keys';
- case grpcTypes.KeygenEvent.KeygenEvent.NEW_KEY: {
- const newKey = data.getNewKey();
- return newKey
- ? {
- newKey: {
- created: newKey.getCreated()!.toDate().toISOString(),
- key: convertFromWireguardKey(newKey.getKey()),
- },
- }
- : 'generation_failure';
- }
- case grpcTypes.KeygenEvent.KeygenEvent.GENERATION_FAILURE:
- return 'generation_failure';
- }
-}
-
function convertFromOpenVpnConstraints(
constraints: grpcTypes.OpenvpnConstraints,
): IOpenVpnConstraints {
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts
index 8cebf9511b..782e6d3982 100644
--- a/gui/src/main/index.ts
+++ b/gui/src/main/index.ts
@@ -30,8 +30,6 @@ import {
IDnsOptions,
IRelayList,
ISettings,
- IWireguardPublicKey,
- KeygenEvent,
liftConstraint,
RelaySettings,
RelaySettingsUpdate,
@@ -88,8 +86,6 @@ const windowsSplitTunneling = process.platform === 'win32' && require('./windows
const DAEMON_RPC_PATH =
process.platform === 'win32' ? 'unix:////./pipe/Mullvad VPN' : 'unix:///var/run/mullvad-vpn';
-const AUTO_CONNECT_FALLBACK_DELAY = 6000;
-
const GUI_VERSION = app.getVersion().replace('.0', '');
/// Mirrors the beta check regex in the daemon. Matches only well formed beta versions
const IS_BETA = /^(\d{4})\.(\d+)-beta(\d+)$/;
@@ -221,8 +217,6 @@ class ApplicationMain {
// The UI locale which is set once from onReady handler
private locale = 'en';
- private wireguardPublicKey?: IWireguardPublicKey;
-
private accountExpiryNotificationScheduler = new Scheduler();
private accountDataCache = new AccountDataCache(
@@ -240,9 +234,6 @@ class ApplicationMain {
},
);
- private autoConnectOnWireguardKeyEvent = false;
- private autoConnectFallbackScheduler = new Scheduler();
-
private blurNavigationResetScheduler = new Scheduler();
private backgroundThrottleScheduler = new Scheduler();
@@ -722,7 +713,6 @@ class ApplicationMain {
this.daemonEventListener = undefined;
this.tunnelStateFallback = undefined;
- this.autoConnectFallbackScheduler.cancel();
if (wasConnected) {
this.connectedToDaemon = false;
@@ -775,8 +765,6 @@ class ApplicationMain {
this.settings.relaySettings,
this.settings.bridgeState,
);
- } else if ('wireguardKey' in daemonEvent) {
- this.handleWireguardKeygenEvent(daemonEvent.wireguardKey);
} else if ('appVersionInfo' in daemonEvent) {
this.setLatestVersion(daemonEvent.appVersionInfo);
}
@@ -825,37 +813,6 @@ class ApplicationMain {
}
}
- private setWireguardKey(wireguardKey?: IWireguardPublicKey) {
- this.wireguardPublicKey = wireguardKey;
- if (this.windowController) {
- IpcMainEventChannel.wireguardKeys.notifyPublicKey(
- this.windowController.webContents,
- wireguardKey,
- );
- }
-
- if (wireguardKey) {
- this.wireguardKeygenEventAutoConnect();
- }
- }
-
- private handleWireguardKeygenEvent(event: KeygenEvent) {
- switch (event) {
- case 'too_many_keys':
- case 'generation_failure':
- this.wireguardPublicKey = undefined;
- break;
- default:
- this.wireguardPublicKey = event.newKey;
- }
-
- if (this.windowController) {
- IpcMainEventChannel.wireguardKeys.notifyKeygenEvent(this.windowController.webContents, event);
- }
-
- this.wireguardKeygenEventAutoConnect();
- }
-
// This function sets a new tunnel state as an assumed next state and saves the current state as
// fallback. The fallback is used if the assumed next state isn't reached.
private setOptimisticTunnelState(state: 'connecting' | 'disconnecting') {
@@ -929,7 +886,6 @@ class ApplicationMain {
if (oldSettings.accountToken !== newSettings.accountToken) {
void this.updateAccountHistory();
- void this.fetchWireguardKey();
}
if (oldSettings.showBetaReleases !== newSettings.showBetaReleases) {
@@ -1223,7 +1179,6 @@ class ApplicationMain {
currentVersion: this.currentVersion,
upgradeVersion: this.upgradeVersion,
guiSettings: this.guiSettings.state,
- wireguardPublicKey: this.wireguardPublicKey,
translations: this.translations,
windowsSplitTunnelingApplications: this.windowsSplitTunnelingApplications,
macOsScrollbarVisibility: this.macOsScrollbarVisibility,
@@ -1322,15 +1277,6 @@ class ApplicationMain {
void this.updateAccountHistory();
});
- IpcMainEventChannel.wireguardKeys.handleGenerateKey(async () => {
- try {
- return await this.daemonRpc.generateWireguardKey();
- } catch {
- return 'generation_failure';
- }
- });
- IpcMainEventChannel.wireguardKeys.handleVerifyKey(() => this.daemonRpc.verifyWireguardKey());
-
IpcMainEventChannel.linuxSplitTunneling.handleGetApplications(() => {
if (linuxSplitTunneling) {
return linuxSplitTunneling.getApplications(this.locale);
@@ -1490,22 +1436,11 @@ class ApplicationMain {
log.warn(`Failed to get account data, logging in anyway: ${verification.error.message}`);
}
- this.autoConnectOnWireguardKeyEvent = this.guiSettings.autoConnect;
await this.daemonRpc.setAccount(accountToken);
-
- // Fallback if daemon doesn't send event.
- if (this.autoConnectOnWireguardKeyEvent) {
- this.autoConnectFallbackScheduler.schedule(
- () => this.wireguardKeygenEventAutoConnect(),
- AUTO_CONNECT_FALLBACK_DELAY,
- );
- }
} catch (e) {
const error = e as Error;
log.error(`Failed to login: ${error.message}`);
- this.autoConnectOnWireguardKeyEvent = false;
-
if (error instanceof InvalidAccountError) {
throw Error(messages.gettext('Invalid account number'));
} else {
@@ -1514,14 +1449,6 @@ class ApplicationMain {
}
}
- private wireguardKeygenEventAutoConnect() {
- if (this.autoConnectOnWireguardKeyEvent) {
- this.autoConnectOnWireguardKeyEvent = false;
- this.autoConnectFallbackScheduler.cancel();
- void this.autoConnect();
- }
- }
-
private async autoConnect() {
if (process.env.NODE_ENV === 'development') {
log.info('Skip autoconnect in development');
@@ -1550,7 +1477,6 @@ class ApplicationMain {
try {
await this.daemonRpc.setAccount();
- this.autoConnectFallbackScheduler.cancel();
this.accountExpiryNotificationScheduler.cancel();
} catch (e) {
const error = e as Error;
@@ -1641,15 +1567,6 @@ class ApplicationMain {
}
}
- private async fetchWireguardKey(): Promise<void> {
- try {
- this.setWireguardKey(await this.daemonRpc.getWireguardKey());
- } catch (e) {
- const error = e as Error;
- log.error(`Failed to fetch wireguard key: ${error.message}`);
- }
- }
-
private updateDaemonsAutoConnect() {
const daemonAutoConnect = this.guiSettings.autoConnect && getOpenAtLogin();
if (daemonAutoConnect !== this.settings.autoConnect) {
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx
index 28f73ac9e0..8abb47af79 100644
--- a/gui/src/renderer/app.tsx
+++ b/gui/src/renderer/app.tsx
@@ -11,7 +11,6 @@ import { AppContext } from './context';
import accountActions from './redux/account/actions';
import connectionActions from './redux/connection/actions';
import settingsActions from './redux/settings/actions';
-import { IWgKey } from './redux/settings/reducers';
import configureStore from './redux/store';
import userInterfaceActions from './redux/userinterface/actions';
import versionActions from './redux/version/actions';
@@ -35,8 +34,6 @@ import {
IDnsOptions,
ILocation,
ISettings,
- IWireguardPublicKey,
- KeygenEvent,
liftConstraint,
RelaySettings,
RelaySettingsUpdate,
@@ -160,14 +157,6 @@ export default class AppRenderer {
this.storeAutoStart(autoStart);
});
- IpcRendererEventChannel.wireguardKeys.listenPublicKey((publicKey?: IWireguardPublicKey) => {
- this.setWireguardPublicKey(publicKey);
- });
-
- IpcRendererEventChannel.wireguardKeys.listenKeygenEvent((event: KeygenEvent) => {
- this.reduxActions.settings.setWireguardKeygenEvent(event);
- });
-
IpcRendererEventChannel.windowsSplitTunneling.listen((applications: IApplication[]) => {
this.reduxActions.settings.setSplitTunnelingApplications(applications);
});
@@ -211,7 +200,6 @@ export default class AppRenderer {
this.setUpgradeVersion(initialState.upgradeVersion);
this.setGuiSettings(initialState.guiSettings);
this.storeAutoStart(initialState.autoStart);
- this.setWireguardPublicKey(initialState.wireguardPublicKey);
this.setChangelog(initialState.changelog);
if (initialState.macOsScrollbarVisibility !== undefined) {
@@ -425,33 +413,6 @@ export default class AppRenderer {
IpcRendererEventChannel.guiSettings.setUnpinnedWindow(unpinnedWindow);
}
- public async verifyWireguardKey(publicKey: IWgKey) {
- const actions = this.reduxActions;
- actions.settings.verifyWireguardKey(publicKey);
- try {
- const valid = await IpcRendererEventChannel.wireguardKeys.verifyKey();
- actions.settings.completeWireguardKeyVerification(valid);
- } catch (e) {
- const error = e as Error;
- log.error(`Failed to verify WireGuard key - ${error.message}`);
- actions.settings.completeWireguardKeyVerification(undefined);
- }
- }
-
- public async generateWireguardKey() {
- const actions = this.reduxActions;
- actions.settings.generateWireguardKey();
- const keygenEvent = await IpcRendererEventChannel.wireguardKeys.generateKey();
- actions.settings.setWireguardKeygenEvent(keygenEvent);
- }
-
- public async replaceWireguardKey(oldKey: IWgKey) {
- const actions = this.reduxActions;
- actions.settings.replaceWireguardKey(oldKey);
- const keygenEvent = await IpcRendererEventChannel.wireguardKeys.generateKey();
- actions.settings.setWireguardKeygenEvent(keygenEvent);
- }
-
public getLinuxSplitTunnelingApplications() {
return IpcRendererEventChannel.linuxSplitTunneling.getApplications();
}
@@ -839,10 +800,6 @@ export default class AppRenderer {
this.reduxActions.settings.updateAutoStart(autoStart);
}
- private setWireguardPublicKey(publicKey?: IWireguardPublicKey) {
- this.reduxActions.settings.setWireguardKey(publicKey);
- }
-
private setChangelog(changelog: IChangelog) {
this.reduxActions.userInterface.setChangelog(changelog);
}
diff --git a/gui/src/renderer/components/AdvancedSettings.tsx b/gui/src/renderer/components/AdvancedSettings.tsx
index 8ecf6c0052..596a638f51 100644
--- a/gui/src/renderer/components/AdvancedSettings.tsx
+++ b/gui/src/renderer/components/AdvancedSettings.tsx
@@ -1,12 +1,8 @@
import * as React from 'react';
-import { sprintf } from 'sprintf-js';
import { TunnelProtocol } from '../../shared/daemon-rpc-types';
import { messages } from '../../shared/gettext';
-import { WgKeyState } from '../redux/settings/reducers';
import {
StyledNavigationScrollbars,
- StyledNoWireguardKeyError,
- StyledNoWireguardKeyErrorContainer,
StyledSelectorForFooter,
StyledTunnelProtocolContainer,
} from './AdvancedSettingsStyles';
@@ -28,7 +24,6 @@ interface IProps {
enableIpv6: boolean;
blockWhenDisconnected: boolean;
tunnelProtocol?: TunnelProtocol;
- wireguardKeyState: WgKeyState;
setEnableIpv6: (value: boolean) => void;
setBlockWhenDisconnected: (value: boolean) => void;
setTunnelProtocol: (value: OptionalTunnelProtocol) => void;
@@ -49,9 +44,28 @@ export default class AdvancedSettings extends React.Component<IProps, IState> {
private blockWhenDisconnectedRef = React.createRef<Switch>();
- public render() {
- const hasWireguardKey = this.props.wireguardKeyState.type === 'key-set';
+ private tunnelProtocolItems: Array<ISelectorItem<OptionalTunnelProtocol>>;
+
+ public constructor(props: IProps) {
+ super(props);
+
+ this.tunnelProtocolItems = [
+ {
+ label: messages.gettext('Automatic'),
+ value: undefined,
+ },
+ {
+ label: messages.pgettext('advanced-settings-view', 'WireGuard'),
+ value: 'wireguard',
+ },
+ {
+ label: messages.pgettext('advanced-settings-view', 'OpenVPN'),
+ value: 'openvpn',
+ },
+ ];
+ }
+ public render() {
return (
<BackAction action={this.props.onClose}>
<Layout>
@@ -141,22 +155,10 @@ export default class AdvancedSettings extends React.Component<IProps, IState> {
<StyledTunnelProtocolContainer>
<StyledSelectorForFooter
title={messages.pgettext('advanced-settings-view', 'Tunnel protocol')}
- values={this.tunnelProtocolItems(hasWireguardKey)}
+ values={this.tunnelProtocolItems}
value={this.props.tunnelProtocol}
onSelect={this.onSelectTunnelProtocol}
/>
- {!hasWireguardKey && (
- <StyledNoWireguardKeyErrorContainer>
- <AriaDescription>
- <StyledNoWireguardKeyError>
- {messages.pgettext(
- 'advanced-settings-view',
- 'To enable WireGuard, generate a key under the "WireGuard key" setting below.',
- )}
- </StyledNoWireguardKeyError>
- </AriaDescription>
- </StyledNoWireguardKeyErrorContainer>
- )}
</StyledTunnelProtocolContainer>
</AriaInputGroup>
@@ -191,31 +193,6 @@ export default class AdvancedSettings extends React.Component<IProps, IState> {
);
}
- private tunnelProtocolItems = (
- hasWireguardKey: boolean,
- ): Array<ISelectorItem<OptionalTunnelProtocol>> => {
- return [
- {
- label: messages.gettext('Automatic'),
- value: undefined,
- },
- {
- label: hasWireguardKey
- ? messages.pgettext('advanced-settings-view', 'WireGuard')
- : sprintf('%(label)s (%(error)s)', {
- label: messages.pgettext('advanced-settings-view', 'WireGuard'),
- error: messages.pgettext('advanced-settings-view', 'missing key'),
- }),
- value: 'wireguard',
- disabled: !hasWireguardKey,
- },
- {
- label: messages.pgettext('advanced-settings-view', 'OpenVPN'),
- value: 'openvpn',
- },
- ];
- };
-
private renderConfirmBlockWhenDisconnectedAlert = () => {
return (
<ModalAlert
diff --git a/gui/src/renderer/components/AdvancedSettingsStyles.tsx b/gui/src/renderer/components/AdvancedSettingsStyles.tsx
index bdc84701c6..f7a87b5311 100644
--- a/gui/src/renderer/components/AdvancedSettingsStyles.tsx
+++ b/gui/src/renderer/components/AdvancedSettingsStyles.tsx
@@ -1,6 +1,4 @@
import styled from 'styled-components';
-import { colors } from '../../config.json';
-import * as Cell from './cell';
import { NavigationScrollbars } from './NavigationBar';
import Selector from './cell/Selector';
@@ -19,12 +17,3 @@ export const StyledTunnelProtocolContainer = styled(StyledSelectorContainer)({
export const StyledNavigationScrollbars = styled(NavigationScrollbars)({
flex: 1,
});
-
-export const StyledNoWireguardKeyErrorContainer = styled(Cell.Footer)({
- paddingBottom: 0,
-});
-
-export const StyledNoWireguardKeyError = styled(Cell.FooterText)({
- fontWeight: 700,
- color: colors.red,
-});
diff --git a/gui/src/renderer/components/AppRouter.tsx b/gui/src/renderer/components/AppRouter.tsx
index f72de697e3..998877bf97 100644
--- a/gui/src/renderer/components/AppRouter.tsx
+++ b/gui/src/renderer/components/AppRouter.tsx
@@ -16,7 +16,6 @@ import SelectLanguagePage from '../containers/SelectLanguagePage';
import SelectLocationPage from '../containers/SelectLocationPage';
import SettingsPage from '../containers/SettingsPage';
import SupportPage from '../containers/SupportPage';
-import WireguardKeysPage from '../containers/WireguardKeysPage';
import WireguardSettingsPage from '../containers/WireguardSettingsPage';
import { IHistoryProps, ITransitionSpecification, transitions, withHistory } from '../lib/history';
import {
@@ -92,7 +91,6 @@ class AppRouter extends React.Component<IHistoryProps, IAppRoutesState> {
<Route exact path={RoutePath.preferences} component={PreferencesPage} />
<Route exact path={RoutePath.advancedSettings} component={AdvancedSettingsPage} />
<Route exact path={RoutePath.wireguardSettings} component={WireguardSettingsPage} />
- <Route exact path={RoutePath.wireguardKeys} component={WireguardKeysPage} />
<Route exact path={RoutePath.openVpnSettings} component={OpenVPNSettingsPage} />
<Route exact path={RoutePath.splitTunneling} component={SplitTunnelingSettings} />
<Route exact path={RoutePath.support} component={SupportPage} />
diff --git a/gui/src/renderer/components/NotificationArea.tsx b/gui/src/renderer/components/NotificationArea.tsx
index 1f79d8b90d..de8b547087 100644
--- a/gui/src/renderer/components/NotificationArea.tsx
+++ b/gui/src/renderer/components/NotificationArea.tsx
@@ -9,7 +9,6 @@ import {
InAppNotificationProvider,
InconsistentVersionNotificationProvider,
NotificationAction,
- NoValidKeyNotificationProvider,
ReconnectingNotificationProvider,
UnsupportedVersionNotificationProvider,
UpdateAvailableNotificationProvider,
@@ -38,12 +37,6 @@ export default function NotificationArea(props: IProps) {
const blockWhenDisconnected = useSelector(
(state: IReduxState) => state.settings.blockWhenDisconnected,
);
- const tunnelProtocol = useSelector((state: IReduxState) =>
- 'normal' in state.settings.relaySettings
- ? state.settings.relaySettings.normal.tunnelProtocol
- : undefined,
- );
- const wireGuardKey = useSelector((state: IReduxState) => state.settings.wireguardKeyState);
const hasExcludedApps = useSelector(
(state: IReduxState) =>
state.settings.splitTunneling && state.settings.splitTunnelingApplications.length > 0,
@@ -58,7 +51,6 @@ export default function NotificationArea(props: IProps) {
hasExcludedApps,
}),
new ErrorNotificationProvider({ tunnelState, accountExpiry, hasExcludedApps }),
- new NoValidKeyNotificationProvider({ tunnelProtocol, wireGuardKey }),
new InconsistentVersionNotificationProvider({ consistent: version.consistent }),
new UnsupportedVersionNotificationProvider(version),
];
diff --git a/gui/src/renderer/components/WireguardKeys.tsx b/gui/src/renderer/components/WireguardKeys.tsx
deleted file mode 100644
index 1a4dab38a6..0000000000
--- a/gui/src/renderer/components/WireguardKeys.tsx
+++ /dev/null
@@ -1,345 +0,0 @@
-import * as React from 'react';
-import { sprintf } from 'sprintf-js';
-import { TunnelState } from '../../shared/daemon-rpc-types';
-import { formatRelativeDate } from '../../shared/date-helper';
-import { messages } from '../../shared/gettext';
-import log from '../../shared/logging';
-import { IWgKey, WgKeyState } from '../redux/settings/reducers';
-import * as AppButton from './AppButton';
-import { AriaDescribed, AriaDescription, AriaDescriptionGroup } from './AriaGroup';
-import ClipboardLabel from './ClipboardLabel';
-import ImageView from './ImageView';
-import { BackAction } from './KeyboardNavigation';
-import { Layout } from './Layout';
-import { NavigationBar, NavigationContainer, NavigationItems, TitleBarItem } from './NavigationBar';
-import SettingsHeader, { HeaderTitle } from './SettingsHeader';
-import {
- StyledButtonRow,
- StyledContainer,
- StyledContent,
- StyledLastButtonRow,
- StyledMessage,
- StyledMessages,
- StyledNavigationScrollbars,
- StyledRow,
- StyledRowLabel,
- StyledRowLabelSpacer,
- StyledRowValue,
-} from './WireguardKeysStyles';
-
-export interface IProps {
- keyState: WgKeyState;
- isOffline: boolean;
- tunnelState: TunnelState;
- windowFocused: boolean;
-
- onClose: () => void;
- onGenerateKey: () => void;
- onReplaceKey: (old: IWgKey) => void;
- onVerifyKey: (publicKey: IWgKey) => void;
- onVisitWebsiteKey: () => Promise<void>;
-}
-
-export interface IState {
- recentlyGeneratedKey: boolean;
- userHasInitiatedVerification: boolean;
- ageOfKeyString: string;
-}
-
-export default class WireguardKeys extends React.Component<IProps, IState> {
- public state = {
- recentlyGeneratedKey: false,
- userHasInitiatedVerification: false,
- ageOfKeyString: WireguardKeys.ageOfKeyString(this.props.keyState),
- };
-
- private keyAgeUpdateInterval?: number;
-
- public static getDerivedStateFromProps(props: IProps) {
- return {
- ageOfKeyString: WireguardKeys.ageOfKeyString(props.keyState),
- };
- }
-
- public componentDidMount() {
- this.verifyKey();
- this.keyAgeUpdateInterval = window.setInterval(this.setAgeOfKeyStringState, 60 * 1000);
- }
-
- public componentWillUnmount() {
- clearInterval(this.keyAgeUpdateInterval);
- }
-
- public componentDidUpdate(prevProps: IProps) {
- const prevKey =
- prevProps.keyState.type === 'key-set' ? prevProps.keyState.key.publicKey : undefined;
- const key =
- this.props.keyState.type === 'key-set' ? this.props.keyState.key.publicKey : undefined;
- if (this.props.tunnelState.state === 'connected' && key !== undefined && key != prevKey) {
- this.setState({ recentlyGeneratedKey: true });
- }
-
- if (
- this.state.recentlyGeneratedKey &&
- prevProps.tunnelState.state !== 'connected' &&
- this.props.tunnelState.state === 'connected'
- ) {
- this.setState({ recentlyGeneratedKey: false });
- }
- }
-
- public render() {
- return (
- <BackAction action={this.props.onClose}>
- <Layout>
- <StyledContainer>
- <NavigationContainer>
- <NavigationBar>
- <NavigationItems>
- <TitleBarItem>
- {
- // TRANSLATORS: Title label in navigation bar
- messages.pgettext('wireguard-keys-nav', 'WireGuard key')
- }
- </TitleBarItem>
- </NavigationItems>
- </NavigationBar>
-
- <StyledNavigationScrollbars fillContainer>
- <StyledContent>
- <SettingsHeader>
- <HeaderTitle>
- {messages.pgettext('wireguard-keys-nav', 'WireGuard key')}
- </HeaderTitle>
- </SettingsHeader>
-
- <StyledRow>
- <StyledRowLabel>
- <span>{messages.pgettext('wireguard-key-view', 'Public key')}</span>
- <StyledRowLabelSpacer />
- <span>{this.keyValidityLabel()}</span>
- </StyledRowLabel>
-
- <StyledRowValue>{this.getKeyText()}</StyledRowValue>
- </StyledRow>
- <StyledRow>
- <StyledRowLabel>
- {messages.pgettext('wireguard-key-view', 'Key generated')}
- </StyledRowLabel>
- <StyledRowValue>{this.state.ageOfKeyString}</StyledRowValue>
- </StyledRow>
-
- <StyledMessages>{this.getStatusMessage()}</StyledMessages>
-
- <StyledButtonRow>{this.getGenerateButton()}</StyledButtonRow>
- <StyledButtonRow>
- <AppButton.BlueButton
- disabled={this.isVerifyButtonDisabled()}
- onClick={this.handleVerifyKeyPress}>
- <AppButton.Label>
- {messages.pgettext('wireguard-key-view', 'Verify key')}
- </AppButton.Label>
- </AppButton.BlueButton>
- </StyledButtonRow>
- <StyledLastButtonRow>
- <AppButton.BlockingButton
- disabled={this.props.isOffline}
- onClick={this.props.onVisitWebsiteKey}>
- <AriaDescriptionGroup>
- <AriaDescribed>
- <AppButton.BlueButton>
- <AppButton.Label>
- {messages.pgettext('wireguard-key-view', 'Manage keys')}
- </AppButton.Label>
- <AriaDescription>
- <AppButton.Icon
- source="icon-extLink"
- height={16}
- width={16}
- aria-label={messages.pgettext('accessibility', 'Opens externally')}
- />
- </AriaDescription>
- </AppButton.BlueButton>
- </AriaDescribed>
- </AriaDescriptionGroup>
- </AppButton.BlockingButton>
- </StyledLastButtonRow>
- </StyledContent>
- </StyledNavigationScrollbars>
- </NavigationContainer>
- </StyledContainer>
- </Layout>
- </BackAction>
- );
- }
-
- private isVerifyButtonDisabled(): boolean {
- return this.props.keyState.type !== 'key-set';
- }
-
- private handleVerifyKeyPress = () => {
- this.setState({ userHasInitiatedVerification: true });
- this.verifyKey();
- };
-
- private verifyKey() {
- switch (this.props.keyState.type) {
- case 'key-set': {
- const key = this.props.keyState.key;
- this.props.onVerifyKey(key);
- break;
- }
- default:
- log.error(`onVerifyKey called from invalid state - ${this.props.keyState.type}`);
- }
- }
-
- /// Action button can either generate or verify a key
- private getGenerateButton() {
- let buttonText = messages.pgettext('wireguard-key-view', 'Generate key');
- const regenerateText = messages.pgettext('wireguard-key-view', 'Regenerate key');
-
- let disabled = false;
- let generateKey = this.props.onGenerateKey;
- switch (this.props.keyState.type) {
- case 'key-set': {
- buttonText = regenerateText;
- const key = this.props.keyState.key;
- generateKey = () => this.props.onReplaceKey(key);
- break;
- }
- case 'being-verified':
- disabled = true;
- buttonText = regenerateText;
- break;
- case 'being-replaced':
- case 'being-generated':
- disabled = true;
- buttonText = messages.pgettext('wireguard-key-view', 'Generating key');
- }
-
- return (
- <AppButton.GreenButton disabled={disabled} onClick={generateKey}>
- <AppButton.Label>{buttonText}</AppButton.Label>
- </AppButton.GreenButton>
- );
- }
-
- private getKeyText() {
- switch (this.props.keyState.type) {
- case 'being-verified':
- case 'key-set': {
- // mimicking the truncating of the key from website
- const publicKey = this.props.keyState.key.publicKey;
- return (
- <StyledRowValue title={this.props.keyState.key.publicKey}>
- <ClipboardLabel
- value={publicKey}
- displayValue={publicKey.substring(0, 20) + '...'}
- obscureValue={false}
- />
- </StyledRowValue>
- );
- }
- case 'being-replaced':
- case 'being-generated':
- return <ImageView source="icon-spinner" height={19} width={19} />;
- default:
- return (
- <StyledRowValue>{messages.pgettext('wireguard-key-view', 'No key set')}</StyledRowValue>
- );
- }
- }
-
- private keyValidityLabel() {
- const keyStateType = this.props.keyState.type;
- if (keyStateType === 'being-verified' && this.state.userHasInitiatedVerification) {
- return <ImageView source="icon-spinner" height={20} width={20} />;
- } else if (this.props.keyState.type === 'key-set') {
- const valid = this.props.keyState.key.valid;
- const show = this.state.userHasInitiatedVerification || valid === false;
- return show && valid !== undefined ? (
- <StyledMessage success={valid}>
- {valid
- ? messages.pgettext('wireguard-key-view', 'Key is valid')
- : messages.pgettext('wireguard-key-view', 'Key is invalid')}
- </StyledMessage>
- ) : null;
- } else {
- return null;
- }
- }
-
- private static ageOfKeyString(keyState: WgKeyState): string {
- switch (keyState.type) {
- case 'key-set':
- case 'being-verified': {
- const createdDate = Math.min(Date.parse(keyState.key.created), Date.now());
- return formatRelativeDate(new Date(), createdDate, true);
- }
- default:
- return '-';
- }
- }
-
- private setAgeOfKeyStringState = () => {
- this.setState({
- ageOfKeyString: WireguardKeys.ageOfKeyString(this.props.keyState),
- });
- };
-
- private getStatusMessage() {
- if (this.props.isOffline && this.state.recentlyGeneratedKey) {
- return (
- <StyledMessage success={this.state.recentlyGeneratedKey}>
- {messages.pgettext('wireguard-key-view', 'Reconnecting with new WireGuard key...')}
- </StyledMessage>
- );
- } else {
- let message = '';
- switch (this.props.keyState.type) {
- case 'key-set': {
- const key = this.props.keyState.key;
- if (key.replacementFailure) {
- switch (key.replacementFailure) {
- case 'too_many_keys':
- message = this.formatKeygenFailure('too-many-keys');
- break;
- case 'generation_failure':
- message = this.formatKeygenFailure('generation-failure');
- break;
- }
- } else if (key.verificationFailed) {
- message = messages.pgettext('wireguard-key-view', 'Key verification failed');
- }
-
- break;
- }
- case 'too-many-keys':
- case 'generation-failure':
- message = this.formatKeygenFailure(this.props.keyState.type);
- break;
- }
-
- return <StyledMessage success={false}>{message}</StyledMessage>;
- }
- }
-
- private formatKeygenFailure(failure: 'too-many-keys' | 'generation-failure'): string {
- switch (failure) {
- case 'too-many-keys':
- // TRANSLATORS: "%(manage)" is replaced with the text in the "Manage keys" button.
- return sprintf(
- messages.pgettext(
- 'wireguard-key-view',
- 'Unable to regenerate key: you already have the maximum number of keys. To generate a new key, you first need to revoke one under “Manage keys.”',
- ),
- { manage: messages.pgettext('wireguard-key-view', 'Manage keys') },
- );
- case 'generation-failure':
- return messages.pgettext('wireguard-key-view', 'Failed to generate a key');
- default:
- return failure;
- }
- }
-}
diff --git a/gui/src/renderer/components/WireguardKeysStyles.tsx b/gui/src/renderer/components/WireguardKeysStyles.tsx
deleted file mode 100644
index cf443b2fa5..0000000000
--- a/gui/src/renderer/components/WireguardKeysStyles.tsx
+++ /dev/null
@@ -1,59 +0,0 @@
-import styled from 'styled-components';
-import { colors } from '../../config.json';
-import { normalText, smallText, tinyText } from './common-styles';
-import { Container } from './Layout';
-import { NavigationScrollbars } from './NavigationBar';
-
-export const StyledNavigationScrollbars = styled(NavigationScrollbars)({
- flex: 1,
-});
-
-export const StyledContainer = styled(Container)({
- backgroundColor: colors.darkBlue,
-});
-
-export const StyledContent = styled.div({
- display: 'flex',
- flexDirection: 'column',
- flex: 1,
-});
-
-export const StyledMessages = styled.div({
- padding: '0 22px 20px',
- flex: 1,
-});
-
-export const StyledMessage = styled.span(smallText, (props: { success: boolean }) => ({
- fontWeight: props.success ? 600 : 700,
- color: props.success ? colors.green : colors.red,
-}));
-
-export const StyledRow = styled.div({
- display: 'flex',
- flexDirection: 'column',
- padding: '0 22px',
- marginBottom: '20px',
-});
-
-export const StyledButtonRow = styled(StyledRow)({
- marginBottom: '18px',
-});
-
-export const StyledLastButtonRow = styled(StyledButtonRow)({
- marginBottom: '22px',
-});
-
-export const StyledRowLabel = styled.span(tinyText, {
- color: colors.white60,
- lineHeight: '20px',
- marginBottom: '5px',
-});
-
-export const StyledRowLabelSpacer = styled.div({
- flex: 1,
-});
-
-export const StyledRowValue = styled.span(normalText, {
- fontWeight: 600,
- color: colors.white,
-});
diff --git a/gui/src/renderer/components/WireguardSettings.tsx b/gui/src/renderer/components/WireguardSettings.tsx
index f799cff335..8bec012986 100644
--- a/gui/src/renderer/components/WireguardSettings.tsx
+++ b/gui/src/renderer/components/WireguardSettings.tsx
@@ -51,7 +51,6 @@ interface IProps {
setWireguardMultihop: (value: boolean) => void;
setWireguardPort: (port?: number) => void;
setWireguardIpVersion: (ipVersion?: IpVersion) => void;
- onViewWireguardKeys: () => void;
onClose: () => void;
}
@@ -202,15 +201,6 @@ export default class WireguardSettings extends React.Component<IProps, IState> {
</Cell.Footer>
</AriaInputGroup>
- <Cell.CellButtonGroup>
- <Cell.CellButton onClick={this.props.onViewWireguardKeys}>
- <Cell.Label>
- {messages.pgettext('wireguard-settings-view', 'WireGuard key')}
- </Cell.Label>
- <Cell.Icon height={12} width={7} source="icon-chevron" />
- </Cell.CellButton>
- </Cell.CellButtonGroup>
-
<AriaInputGroup>
<Cell.Container>
<AriaLabel>
diff --git a/gui/src/renderer/containers/AdvancedSettingsPage.tsx b/gui/src/renderer/containers/AdvancedSettingsPage.tsx
index 51ba310aad..0bc00ee204 100644
--- a/gui/src/renderer/containers/AdvancedSettingsPage.tsx
+++ b/gui/src/renderer/containers/AdvancedSettingsPage.tsx
@@ -16,7 +16,6 @@ const mapStateToProps = (state: IReduxState) => {
return {
enableIpv6: state.settings.enableIpv6,
blockWhenDisconnected: state.settings.blockWhenDisconnected,
- wireguardKeyState: state.settings.wireguardKeyState,
tunnelProtocol,
};
};
diff --git a/gui/src/renderer/containers/WireguardKeysPage.tsx b/gui/src/renderer/containers/WireguardKeysPage.tsx
deleted file mode 100644
index b0c25e06a9..0000000000
--- a/gui/src/renderer/containers/WireguardKeysPage.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import { connect } from 'react-redux';
-import { links } from '../../config.json';
-import WireguardKeys from '../components/WireguardKeys';
-import withAppContext, { IAppContext } from '../context';
-import { IHistoryProps, withHistory } from '../lib/history';
-import { IWgKey } from '../redux/settings/reducers';
-import { IReduxState, ReduxDispatch } from '../redux/store';
-
-const mapStateToProps = (state: IReduxState) => ({
- keyState: state.settings.wireguardKeyState,
- isOffline: state.connection.isBlocked,
- tunnelState: state.connection.status,
- windowFocused: state.userInterface.windowFocused,
-});
-const mapDispatchToProps = (_dispatch: ReduxDispatch, props: IHistoryProps & IAppContext) => {
- return {
- onClose: () => props.history.pop(),
- onGenerateKey: () => props.app.generateWireguardKey(),
- onReplaceKey: (oldKey: IWgKey) => props.app.replaceWireguardKey(oldKey),
- onVerifyKey: (publicKey: IWgKey) => props.app.verifyWireguardKey(publicKey),
- onVisitWebsiteKey: () => props.app.openLinkWithAuth(links.manageKeys),
- };
-};
-
-export default withAppContext(
- withHistory(connect(mapStateToProps, mapDispatchToProps)(WireguardKeys)),
-);
diff --git a/gui/src/renderer/containers/WireguardSettingsPage.tsx b/gui/src/renderer/containers/WireguardSettingsPage.tsx
index 4b0af37510..d9ac31756d 100644
--- a/gui/src/renderer/containers/WireguardSettingsPage.tsx
+++ b/gui/src/renderer/containers/WireguardSettingsPage.tsx
@@ -6,7 +6,6 @@ import WireguardSettings from '../components/WireguardSettings';
import withAppContext, { IAppContext } from '../context';
import { createWireguardRelayUpdater } from '../lib/constraint-updater';
import { IHistoryProps, withHistory } from '../lib/history';
-import { RoutePath } from '../lib/routes';
import { RelaySettingsRedux } from '../redux/settings/reducers';
import { IReduxState, ReduxDispatch } from '../redux/store';
@@ -108,8 +107,6 @@ const mapDispatchToProps = (_dispatch: ReduxDispatch, props: IHistoryProps & IAp
log.error('Failed to update mtu value', error.message);
}
},
-
- onViewWireguardKeys: () => props.history.push(RoutePath.wireguardKeys),
};
};
diff --git a/gui/src/renderer/lib/routes.ts b/gui/src/renderer/lib/routes.ts
index 8a63cd6de0..ef06e14023 100644
--- a/gui/src/renderer/lib/routes.ts
+++ b/gui/src/renderer/lib/routes.ts
@@ -16,7 +16,6 @@ export enum RoutePath {
preferences = '/settings/preferences',
advancedSettings = '/settings/advanced',
wireguardSettings = '/settings/advanced/wireguard',
- wireguardKeys = '/settings/advanced/wireguard/keys',
openVpnSettings = '/settings/advanced/openvpn',
splitTunneling = '/settings/advanced/split-tunneling',
support = '/settings/support',
diff --git a/gui/src/renderer/redux/settings/actions.ts b/gui/src/renderer/redux/settings/actions.ts
index 1b1e48265c..32cd157157 100644
--- a/gui/src/renderer/redux/settings/actions.ts
+++ b/gui/src/renderer/redux/settings/actions.ts
@@ -1,12 +1,7 @@
-import {
- BridgeState,
- IDnsOptions,
- IWireguardPublicKey,
- KeygenEvent,
-} from '../../../shared/daemon-rpc-types';
+import { BridgeState, IDnsOptions } from '../../../shared/daemon-rpc-types';
import { IGuiSettingsState } from '../../../shared/gui-settings-state';
import { IApplication } from '../../../shared/application-types';
-import { BridgeSettingsRedux, IRelayLocationRedux, IWgKey, RelaySettingsRedux } from './reducers';
+import { BridgeSettingsRedux, IRelayLocationRedux, RelaySettingsRedux } from './reducers';
export interface IUpdateGuiSettingsAction {
type: 'UPDATE_GUI_SETTINGS';
@@ -73,36 +68,6 @@ export interface IUpdateAutoStartAction {
autoStart: boolean;
}
-// Used to set wireguard key when accounts are changed.
-export interface IWireguardSetKey {
- type: 'SET_WIREGUARD_KEY';
- key?: IWgKey;
-}
-
-export interface IWireguardGenerateKey {
- type: 'GENERATE_WIREGUARD_KEY';
-}
-
-export interface IWireguardReplaceKey {
- type: 'REPLACE_WIREGUARD_KEY';
- oldKey: IWgKey;
-}
-
-export interface IWireguardVerifyKey {
- type: 'VERIFY_WIREGUARD_KEY';
- key: IWgKey;
-}
-
-export interface IWireguardKeygenEvent {
- type: 'WIREGUARD_KEYGEN_EVENT';
- event: KeygenEvent;
-}
-
-export interface IWireguardKeyVerifiedAction {
- type: 'WIREGUARD_KEY_VERIFICATION_COMPLETE';
- verified?: boolean;
-}
-
export interface IUpdateDnsOptionsAction {
type: 'UPDATE_DNS_OPTIONS';
dns: IDnsOptions;
@@ -132,12 +97,6 @@ export type SettingsAction =
| IUpdateOpenVpnMssfixAction
| IUpdateWireguardMtuAction
| IUpdateAutoStartAction
- | IWireguardSetKey
- | IWireguardVerifyKey
- | IWireguardGenerateKey
- | IWireguardReplaceKey
- | IWireguardKeygenEvent
- | IWireguardKeyVerifiedAction
| IUpdateDnsOptionsAction
| IUpdateSplitTunnelingStateAction
| ISetSplitTunnelingApplicationsAction;
@@ -237,54 +196,6 @@ function updateAutoStart(autoStart: boolean): IUpdateAutoStartAction {
};
}
-function setWireguardKey(publicKey?: IWireguardPublicKey): IWireguardSetKey {
- const key = publicKey
- ? {
- publicKey: publicKey.key,
- created: publicKey.created,
- valid: undefined,
- }
- : undefined;
- return {
- type: 'SET_WIREGUARD_KEY',
- key,
- };
-}
-
-function setWireguardKeygenEvent(event: KeygenEvent): IWireguardKeygenEvent {
- return {
- type: 'WIREGUARD_KEYGEN_EVENT',
- event,
- };
-}
-
-function generateWireguardKey(): IWireguardGenerateKey {
- return {
- type: 'GENERATE_WIREGUARD_KEY',
- };
-}
-
-function replaceWireguardKey(oldKey: IWgKey): IWireguardReplaceKey {
- return {
- type: 'REPLACE_WIREGUARD_KEY',
- oldKey,
- };
-}
-
-function verifyWireguardKey(key: IWgKey): IWireguardVerifyKey {
- return {
- type: 'VERIFY_WIREGUARD_KEY',
- key,
- };
-}
-
-function completeWireguardKeyVerification(verified?: boolean): IWireguardKeyVerifiedAction {
- return {
- type: 'WIREGUARD_KEY_VERIFICATION_COMPLETE',
- verified,
- };
-}
-
function updateDnsOptions(dns: IDnsOptions): IUpdateDnsOptionsAction {
return {
type: 'UPDATE_DNS_OPTIONS',
@@ -322,12 +233,6 @@ export default {
updateOpenVpnMssfix,
updateWireguardMtu,
updateAutoStart,
- setWireguardKey,
- setWireguardKeygenEvent,
- generateWireguardKey,
- replaceWireguardKey,
- verifyWireguardKey,
- completeWireguardKeyVerification,
updateDnsOptions,
updateSplitTunnelingState,
setSplitTunnelingApplications,
diff --git a/gui/src/renderer/redux/settings/reducers.ts b/gui/src/renderer/redux/settings/reducers.ts
index 449ff2b563..9b55160a5e 100644
--- a/gui/src/renderer/redux/settings/reducers.ts
+++ b/gui/src/renderer/redux/settings/reducers.ts
@@ -1,7 +1,6 @@
import { IApplication } from '../../../shared/application-types';
import {
BridgeState,
- KeygenEvent,
LiftedConstraint,
ProxySettings,
RelayLocation,
@@ -11,7 +10,6 @@ import {
IpVersion,
} from '../../../shared/daemon-rpc-types';
import { IGuiSettingsState } from '../../../shared/gui-settings-state';
-import log from '../../../shared/logging';
import { ReduxAction } from '../store';
export type RelaySettingsRedux =
@@ -73,54 +71,6 @@ export interface IRelayLocationRedux {
cities: IRelayLocationCityRedux[];
}
-export interface IWgKey {
- publicKey: string;
- created: string;
- valid?: boolean;
- replacementFailure?: KeygenEvent;
- verificationFailed?: boolean;
-}
-
-interface IWgKeySet {
- type: 'key-set';
- key: IWgKey;
-}
-
-interface IWgKeyNotSet {
- type: 'key-not-set';
-}
-
-interface IWgTooManyKeys {
- type: 'too-many-keys';
-}
-
-interface IWgKeyGenerationFailure {
- type: 'generation-failure';
-}
-
-interface IWgKeyBeingGenerated {
- type: 'being-generated';
-}
-
-interface IWgKeyBeingReplaced {
- type: 'being-replaced';
- oldKey: IWgKey;
-}
-
-interface IWgKeyBeingVerified {
- type: 'being-verified';
- key: IWgKey;
-}
-
-export type WgKeyState =
- | IWgKeySet
- | IWgKeyNotSet
- | IWgKeyGenerationFailure
- | IWgTooManyKeys
- | IWgKeyBeingVerified
- | IWgKeyBeingReplaced
- | IWgKeyBeingGenerated;
-
export interface ISettingsReduxState {
autoStart: boolean;
guiSettings: IGuiSettingsState;
@@ -140,7 +90,6 @@ export interface ISettingsReduxState {
mtu?: number;
};
dns: IDnsOptions;
- wireguardKeyState: WgKeyState;
splitTunneling: boolean;
splitTunnelingApplications: IApplication[];
}
@@ -183,9 +132,6 @@ const initialState: ISettingsReduxState = {
showBetaReleases: false,
openVpn: {},
wireguard: {},
- wireguardKeyState: {
- type: 'key-not-set',
- },
dns: {
state: 'default',
defaultOptions: {
@@ -290,42 +236,6 @@ export default function (
bridgeState: action.bridgeState,
};
- case 'SET_WIREGUARD_KEY':
- return {
- ...state,
- wireguardKeyState: setWireguardKey(action.key),
- };
- case 'WIREGUARD_KEYGEN_EVENT':
- return {
- ...state,
- wireguardKeyState: setWireguardKeygenEvent(state, action.event),
- };
- case 'WIREGUARD_KEY_VERIFICATION_COMPLETE':
- return {
- ...state,
- wireguardKeyState: applyKeyVerification(state.wireguardKeyState, action.verified),
- };
- case 'VERIFY_WIREGUARD_KEY':
- return {
- ...state,
- wireguardKeyState: { type: 'being-verified', key: resetWireguardKeyErrors(action.key) },
- };
-
- case 'GENERATE_WIREGUARD_KEY':
- return {
- ...state,
- wireguardKeyState: { type: 'being-generated' },
- };
-
- case 'REPLACE_WIREGUARD_KEY':
- return {
- ...state,
- wireguardKeyState: {
- type: 'being-replaced',
- oldKey: resetWireguardKeyErrors(action.oldKey),
- },
- };
-
case 'UPDATE_DNS_OPTIONS':
return {
...state,
@@ -348,76 +258,3 @@ export default function (
return state;
}
}
-
-function setWireguardKey(key?: IWgKey): WgKeyState {
- if (key) {
- return {
- type: 'key-set',
- key,
- };
- } else {
- return {
- type: 'key-not-set',
- };
- }
-}
-
-function resetWireguardKeyErrors(key: IWgKey): IWgKey {
- return {
- publicKey: key.publicKey,
- created: key.created,
- };
-}
-
-function setWireguardKeygenEvent(state: ISettingsReduxState, keygenEvent: KeygenEvent): WgKeyState {
- const oldKeyState = state.wireguardKeyState;
- if (oldKeyState.type === 'being-replaced') {
- switch (keygenEvent) {
- case 'too_many_keys':
- case 'generation_failure':
- return {
- type: 'key-set',
- key: {
- ...oldKeyState.oldKey,
- replacementFailure: keygenEvent,
- },
- };
- default:
- break;
- }
- }
- switch (keygenEvent) {
- case 'too_many_keys':
- return { type: 'too-many-keys' };
- case 'generation_failure':
- return { type: 'generation-failure' };
- default:
- return {
- type: 'key-set',
- key: {
- publicKey: keygenEvent.newKey.key,
- created: keygenEvent.newKey.created,
- valid: undefined,
- },
- };
- }
-}
-
-function applyKeyVerification(state: WgKeyState, verified?: boolean): WgKeyState {
- const verificationFailed = verified === undefined ? true : undefined;
- switch (state.type) {
- case 'being-verified':
- return {
- type: 'key-set',
- key: {
- ...state.key,
- valid: verified,
- verificationFailed,
- },
- };
- // drop the verification event if the key wasn't being verified.
- default:
- log.error("Received key verification event when key wasn't being verified");
- return state;
- }
-}
diff --git a/gui/src/shared/daemon-rpc-types.ts b/gui/src/shared/daemon-rpc-types.ts
index eec1e1f2a4..a45bdada4d 100644
--- a/gui/src/shared/daemon-rpc-types.ts
+++ b/gui/src/shared/daemon-rpc-types.ts
@@ -104,7 +104,6 @@ export type DaemonEvent =
| { tunnelState: TunnelState }
| { settings: ISettings }
| { relayList: IRelayList }
- | { wireguardKey: KeygenEvent }
| { appVersionInfo: IAppVersionInfo };
export interface ITunnelStateRelayInfo {
@@ -334,18 +333,6 @@ export interface ISettings {
splitTunnel: SplitTunnelSettings;
}
-export type KeygenEvent = INewWireguardKey | KeygenFailure;
-export type KeygenFailure = 'too_many_keys' | 'generation_failure';
-
-export interface INewWireguardKey {
- newKey: IWireguardPublicKey;
-}
-
-export interface IWireguardPublicKey {
- key: string;
- created: string;
-}
-
export type BridgeState = 'auto' | 'on' | 'off';
export type SplitTunnelSettings = {
diff --git a/gui/src/shared/ipc-schema.ts b/gui/src/shared/ipc-schema.ts
index 0ed0985bf1..a6d41298ce 100644
--- a/gui/src/shared/ipc-schema.ts
+++ b/gui/src/shared/ipc-schema.ts
@@ -10,8 +10,6 @@ import {
ILocation,
IRelayList,
ISettings,
- IWireguardPublicKey,
- KeygenEvent,
RelaySettingsUpdate,
TunnelState,
VoucherResponse,
@@ -56,7 +54,6 @@ export interface IAppStateSnapshot {
currentVersion: ICurrentAppVersionInfo;
upgradeVersion: IAppVersionInfo;
guiSettings: IGuiSettingsState;
- wireguardPublicKey?: IWireguardPublicKey;
translations: ITranslations;
windowsSplitTunnelingApplications?: IApplication[];
macOsScrollbarVisibility?: MacOsScrollbarVisibility;
@@ -181,12 +178,6 @@ export const ipcSchema = {
'': notifyRenderer<boolean>(),
set: invoke<boolean, void>(),
},
- wireguardKeys: {
- publicKey: notifyRenderer<IWireguardPublicKey | undefined>(),
- keygenEvent: notifyRenderer<KeygenEvent>(),
- generateKey: invoke<void, KeygenEvent>(),
- verifyKey: invoke<void, boolean>(),
- },
problemReport: {
collectLogs: invoke<string | undefined, string>(),
sendReport: invoke<{ email: string; message: string; savedReportId: string }, void>(),
diff --git a/gui/src/shared/localization-contexts.ts b/gui/src/shared/localization-contexts.ts
index b402278571..5523951d9c 100644
--- a/gui/src/shared/localization-contexts.ts
+++ b/gui/src/shared/localization-contexts.ts
@@ -29,8 +29,6 @@ export type LocalizationContexts =
| 'wireguard-settings-nav'
| 'openvpn-settings-view'
| 'openvpn-settings-nav'
- | 'wireguard-key-view'
- | 'wireguard-keys-nav'
| 'split-tunneling-view'
| 'split-tunneling-nav'
| 'support-view'
diff --git a/gui/src/shared/notifications/no-valid-key.ts b/gui/src/shared/notifications/no-valid-key.ts
deleted file mode 100644
index 6de28ab8df..0000000000
--- a/gui/src/shared/notifications/no-valid-key.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-import { WgKeyState } from '../../renderer/redux/settings/reducers';
-import { messages } from '../../shared/gettext';
-import { LiftedConstraint, TunnelProtocol } from '../daemon-rpc-types';
-import { InAppNotification, InAppNotificationProvider } from './notification';
-
-interface NoValidKeyNotificationContext {
- tunnelProtocol?: LiftedConstraint<TunnelProtocol>;
- wireGuardKey: WgKeyState;
-}
-
-export class NoValidKeyNotificationProvider implements InAppNotificationProvider {
- public constructor(private context: NoValidKeyNotificationContext) {}
-
- public mayDisplay() {
- const usingWireGuard =
- this.context.tunnelProtocol === 'wireguard' ||
- (this.context.tunnelProtocol === 'any' &&
- (process.platform ?? window.env.platform) !== 'win32');
- const keyInvalid =
- this.context.wireGuardKey.type === 'key-not-set' ||
- this.context.wireGuardKey.type === 'too-many-keys' ||
- this.context.wireGuardKey.type === 'generation-failure' ||
- (this.context.wireGuardKey.type === 'key-set' &&
- this.context.wireGuardKey.key.valid === false) ||
- (this.context.wireGuardKey.type === 'key-set' &&
- this.context.wireGuardKey.key.replacementFailure === 'too_many_keys');
-
- return usingWireGuard && keyInvalid;
- }
-
- public getInAppNotification(): InAppNotification {
- return {
- indicator: 'warning',
- title: messages.pgettext('in-app-notifications', 'VALID WIREGUARD KEY IS MISSING'),
- subtitle: messages.pgettext('in-app-notifications', 'Manage keys under Advanced settings.'),
- };
- }
-}
diff --git a/gui/src/shared/notifications/notification.ts b/gui/src/shared/notifications/notification.ts
index 570bf2f12b..2152da0e79 100644
--- a/gui/src/shared/notifications/notification.ts
+++ b/gui/src/shared/notifications/notification.ts
@@ -41,7 +41,6 @@ export * from './connected';
export * from './connecting';
export * from './disconnected';
export * from './error';
-export * from './no-valid-key';
export * from './inconsistent-version';
export * from './reconnecting';
export * from './unsupported-version';