summaryrefslogtreecommitdiffhomepage
path: root/gui/src/renderer
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2024-02-14 15:07:47 +0100
committerOskar Nyberg <oskar@mullvad.net>2024-02-15 16:04:29 +0100
commit8ab10682e57bf4f42f4a789ee8566af69e5b161f (patch)
treee4f4f0bc9468c7333eb7ea8a5b3248e96502579b /gui/src/renderer
parentd0650acef1db8ed2f2f2e1423f7567efcdc09802 (diff)
downloadmullvadvpn-8ab10682e57bf4f42f4a789ee8566af69e5b161f.tar.xz
mullvadvpn-8ab10682e57bf4f42f4a789ee8566af69e5b161f.zip
Add rpc and ipc calls for IP override along with redux additions
Diffstat (limited to 'gui/src/renderer')
-rw-r--r--gui/src/renderer/app.tsx4
-rw-r--r--gui/src/renderer/redux/settings-import/actions.ts40
-rw-r--r--gui/src/renderer/redux/settings-import/reducers.ts41
-rw-r--r--gui/src/renderer/redux/settings/actions.ts17
-rw-r--r--gui/src/renderer/redux/settings/reducers.ts9
-rw-r--r--gui/src/renderer/redux/store.ts7
6 files changed, 116 insertions, 2 deletions
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx
index d4aef54f31..5e2c574d79 100644
--- a/gui/src/renderer/app.tsx
+++ b/gui/src/renderer/app.tsx
@@ -366,6 +366,9 @@ export default class AppRenderer {
IpcRendererEventChannel.settings.testApiAccessMethodById(id);
public testCustomApiAccessMethod = (method: CustomProxy) =>
IpcRendererEventChannel.settings.testCustomApiAccessMethod(method);
+ public importSettingsFile = (path: string) => IpcRendererEventChannel.settings.importFile(path);
+ public importSettingsText = (text: string) => IpcRendererEventChannel.settings.importText(text);
+ public clearAllRelayOverrides = () => IpcRendererEventChannel.settings.clearAllRelayOverrides();
public getMapData = () => IpcRendererEventChannel.map.getData();
public setAnimateMap = (displayMap: boolean): void =>
IpcRendererEventChannel.guiSettings.setAnimateMap(displayMap);
@@ -813,6 +816,7 @@ export default class AppRenderer {
reduxSettings.updateObfuscationSettings(newSettings.obfuscationSettings);
reduxSettings.updateCustomLists(newSettings.customLists);
reduxSettings.updateApiAccessMethods(newSettings.apiAccessMethods);
+ reduxSettings.updateRelayOverrides(newSettings.relayOverrides);
this.setReduxRelaySettings(newSettings.relaySettings);
this.setBridgeSettings(newSettings.bridgeSettings);
diff --git a/gui/src/renderer/redux/settings-import/actions.ts b/gui/src/renderer/redux/settings-import/actions.ts
new file mode 100644
index 0000000000..f31af1c1c6
--- /dev/null
+++ b/gui/src/renderer/redux/settings-import/actions.ts
@@ -0,0 +1,40 @@
+export interface SaveSettingsImportFormAction {
+ type: 'SAVE_SETTINGS_IMPORT_FORM';
+ value: string;
+ submit: boolean;
+}
+
+export interface ClearSettingsImportFormAction {
+ type: 'CLEAR_SETTINGS_IMPORT_FORM';
+}
+
+export interface UnsetSubmitSettingsImportFormAction {
+ type: 'UNSET_SUBMIT_SETTINGS_IMPORT_FORM';
+}
+
+export type SettingsImportAction =
+ | SaveSettingsImportFormAction
+ | ClearSettingsImportFormAction
+ | UnsetSubmitSettingsImportFormAction;
+
+function saveSettingsImportForm(value: string, submit: boolean): SaveSettingsImportFormAction {
+ return {
+ type: 'SAVE_SETTINGS_IMPORT_FORM',
+ value,
+ submit,
+ };
+}
+
+function clearSettingsImportForm(): ClearSettingsImportFormAction {
+ return {
+ type: 'CLEAR_SETTINGS_IMPORT_FORM',
+ };
+}
+
+function unsetSubmitSettingsImportForm(): UnsetSubmitSettingsImportFormAction {
+ return {
+ type: 'UNSET_SUBMIT_SETTINGS_IMPORT_FORM',
+ };
+}
+
+export default { saveSettingsImportForm, clearSettingsImportForm, unsetSubmitSettingsImportForm };
diff --git a/gui/src/renderer/redux/settings-import/reducers.ts b/gui/src/renderer/redux/settings-import/reducers.ts
new file mode 100644
index 0000000000..76908bc67a
--- /dev/null
+++ b/gui/src/renderer/redux/settings-import/reducers.ts
@@ -0,0 +1,41 @@
+import { ReduxAction } from '../store';
+
+export interface SettingsImportReduxState {
+ value: string;
+ submit: boolean;
+}
+
+const initialState: SettingsImportReduxState = {
+ value: '',
+ submit: false,
+};
+
+export default function (
+ state: SettingsImportReduxState = initialState,
+ action: ReduxAction,
+): SettingsImportReduxState {
+ switch (action.type) {
+ case 'SAVE_SETTINGS_IMPORT_FORM':
+ return {
+ ...state,
+ value: action.value,
+ submit: action.submit,
+ };
+
+ case 'CLEAR_SETTINGS_IMPORT_FORM':
+ return {
+ ...state,
+ value: '',
+ submit: false,
+ };
+
+ case 'UNSET_SUBMIT_SETTINGS_IMPORT_FORM':
+ return {
+ ...state,
+ submit: false,
+ };
+
+ default:
+ return state;
+ }
+}
diff --git a/gui/src/renderer/redux/settings/actions.ts b/gui/src/renderer/redux/settings/actions.ts
index 969f8b0a41..aa4e460e6f 100644
--- a/gui/src/renderer/redux/settings/actions.ts
+++ b/gui/src/renderer/redux/settings/actions.ts
@@ -7,6 +7,7 @@ import {
IDnsOptions,
IWireguardEndpointData,
ObfuscationSettings,
+ RelayOverride,
} from '../../../shared/daemon-rpc-types';
import { IGuiSettingsState } from '../../../shared/gui-settings-state';
import { BridgeSettingsRedux, IRelayLocationCountryRedux, RelaySettingsRedux } from './reducers';
@@ -116,6 +117,11 @@ export interface ISetCurrentApiAccessMethod {
accessMethod: AccessMethodSetting;
}
+export interface ISetRelayOverrides {
+ type: 'SET_RELAY_OVERRIDES';
+ relayOverrides: Array<RelayOverride>;
+}
+
export type SettingsAction =
| IUpdateGuiSettingsAction
| IUpdateRelayAction
@@ -137,7 +143,8 @@ export type SettingsAction =
| ISetObfuscationSettings
| ISetCustomLists
| ISetApiAccessMethods
- | ISetCurrentApiAccessMethod;
+ | ISetCurrentApiAccessMethod
+ | ISetRelayOverrides;
function updateGuiSettings(guiSettings: IGuiSettingsState): IUpdateGuiSettingsAction {
return {
@@ -298,6 +305,13 @@ function updateCurrentApiAccessMethod(setting: AccessMethodSetting): ISetCurrent
};
}
+function updateRelayOverrides(relayOverrides: Array<RelayOverride>): ISetRelayOverrides {
+ return {
+ type: 'SET_RELAY_OVERRIDES',
+ relayOverrides,
+ };
+}
+
export default {
updateGuiSettings,
updateRelay,
@@ -320,4 +334,5 @@ export default {
updateCustomLists,
updateApiAccessMethods,
updateCurrentApiAccessMethod,
+ updateRelayOverrides,
};
diff --git a/gui/src/renderer/redux/settings/reducers.ts b/gui/src/renderer/redux/settings/reducers.ts
index bb971f896a..07502ab280 100644
--- a/gui/src/renderer/redux/settings/reducers.ts
+++ b/gui/src/renderer/redux/settings/reducers.ts
@@ -16,6 +16,7 @@ import {
ProxySettings,
RelayEndpointType,
RelayLocation,
+ RelayOverride,
RelayProtocol,
TunnelProtocol,
} from '../../../shared/daemon-rpc-types';
@@ -112,6 +113,7 @@ export interface ISettingsReduxState {
customLists: CustomLists;
apiAccessMethods: ApiAccessMethodSettings;
currentApiAccessMethod?: AccessMethodSetting;
+ relayOverrides: Array<RelayOverride>;
}
const initialState: ISettingsReduxState = {
@@ -181,6 +183,7 @@ const initialState: ISettingsReduxState = {
customLists: [],
apiAccessMethods: getDefaultApiAccessMethods(),
currentApiAccessMethod: undefined,
+ relayOverrides: [],
};
export default function (
@@ -323,6 +326,12 @@ export default function (
currentApiAccessMethod: action.accessMethod,
};
+ case 'SET_RELAY_OVERRIDES':
+ return {
+ ...state,
+ relayOverrides: action.relayOverrides,
+ };
+
default:
return state;
}
diff --git a/gui/src/renderer/redux/store.ts b/gui/src/renderer/redux/store.ts
index 9634774038..1617acce3d 100644
--- a/gui/src/renderer/redux/store.ts
+++ b/gui/src/renderer/redux/store.ts
@@ -9,6 +9,8 @@ import connectionActions, { ConnectionAction } from './connection/actions';
import connectionReducer, { IConnectionReduxState } from './connection/reducers';
import settingsActions, { SettingsAction } from './settings/actions';
import settingsReducer, { ISettingsReduxState } from './settings/reducers';
+import { SettingsImportAction } from './settings-import/actions';
+import settingsImportReducer, { SettingsImportReduxState } from './settings-import/reducers';
import supportActions, { SupportAction } from './support/actions';
import supportReducer, { ISupportReduxState } from './support/reducers';
import userInterfaceActions, { UserInterfaceAction } from './userinterface/actions';
@@ -23,6 +25,7 @@ export interface IReduxState {
support: ISupportReduxState;
version: IVersionReduxState;
userInterface: IUserInterfaceReduxState;
+ settingsImport: SettingsImportReduxState;
}
export type ReduxAction =
@@ -31,7 +34,8 @@ export type ReduxAction =
| SettingsAction
| SupportAction
| VersionAction
- | UserInterfaceAction;
+ | UserInterfaceAction
+ | SettingsImportAction;
export type ReduxStore = ReturnType<typeof configureStore>;
export type ReduxDispatch = Dispatch<ReduxAction>;
@@ -43,6 +47,7 @@ export default function configureStore() {
support: supportReducer,
version: versionReducer,
userInterface: userInterfaceReducer,
+ settingsImport: settingsImportReducer,
};
const rootReducer = combineReducers(reducers);