summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2022-06-14 12:33:58 +0200
committerDavid Lönnhager <david.l@mullvad.net>2022-06-14 12:33:58 +0200
commita38dce1ce10893f8e1a077c95ca4afe085bcaeea (patch)
tree50f2bcb8cd3c01a2d3e04f45cb3b173d26532591 /gui/src
parent0e74ce4143661138a76d313df43546dc4174ba1a (diff)
parent0e0f1d6b8c8d24eb9d5f565322c126f9d6a9e096 (diff)
downloadmullvadvpn-a38dce1ce10893f8e1a077c95ca4afe085bcaeea.tar.xz
mullvadvpn-a38dce1ce10893f8e1a077c95ca4afe085bcaeea.zip
Merge branch 'win-simplify-dns'
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/renderer/components/CustomDnsSettings.tsx66
1 files changed, 49 insertions, 17 deletions
diff --git a/gui/src/renderer/components/CustomDnsSettings.tsx b/gui/src/renderer/components/CustomDnsSettings.tsx
index 9c976062c1..0e9dccc79e 100644
--- a/gui/src/renderer/components/CustomDnsSettings.tsx
+++ b/gui/src/renderer/components/CustomDnsSettings.tsx
@@ -43,6 +43,8 @@ export default function CustomDnsSettings() {
const [savingAdd, setSavingAdd] = useState(false);
const [savingEdit, setSavingEdit] = useState(false);
const willShowConfirmationDialog = useRef(false);
+ const addingLocalIp = useRef(false);
+ const manualLocal = window.env.platform === 'win32' || window.env.platform === 'linux';
const featureAvailable = useMemo(
() =>
@@ -121,8 +123,17 @@ export default function CustomDnsSettings() {
try {
const ipAddress = IpAddress.fromString(address);
- if (ipAddress.isLocal()) {
- await add();
+ addingLocalIp.current = ipAddress.isLocal();
+ if (addingLocalIp.current) {
+ if (manualLocal) {
+ willShowConfirmationDialog.current = true;
+ setConfirmAction(() => async () => {
+ willShowConfirmationDialog.current = false;
+ await add();
+ });
+ } else {
+ await add();
+ }
} else {
willShowConfirmationDialog.current = true;
setConfirmAction(() => async () => {
@@ -160,8 +171,18 @@ export default function CustomDnsSettings() {
const ipAddress = IpAddress.fromString(newAddress);
return new Promise<void>((resolve) => {
- if (ipAddress.isLocal()) {
- void edit().then(resolve);
+ addingLocalIp.current = ipAddress.isLocal();
+ if (addingLocalIp.current) {
+ if (manualLocal) {
+ willShowConfirmationDialog.current = true;
+ setConfirmAction(() => async () => {
+ willShowConfirmationDialog.current = false;
+ await edit();
+ resolve();
+ });
+ } else {
+ void edit().then(resolve);
+ }
} else {
willShowConfirmationDialog.current = true;
setConfirmAction(() => async () => {
@@ -275,6 +296,7 @@ export default function CustomDnsSettings() {
<ConfirmationDialog
isOpen={confirmAction !== undefined}
+ isLocal={addingLocalIp}
confirm={confirm}
abort={abortConfirmation}
/>
@@ -386,11 +408,33 @@ function CellListItem(props: ICellListItemProps) {
interface IConfirmationDialogProps {
isOpen: boolean;
+ isLocal: React.RefObject<boolean>;
confirm: () => void;
abort: () => void;
}
function ConfirmationDialog(props: IConfirmationDialogProps) {
+ let message;
+ if (props.isLocal.current) {
+ message = messages.pgettext(
+ 'advanced-settings-view',
+ 'The DNS server you want to add is a private IP. You must ensure that your network interfaces are configured to use it.',
+ );
+ } else {
+ message = sprintf(
+ // TRANSLATORS: Available placeholders:
+ // TRANSLATORS: %(tunnelProtocol)s - the name of the tunnel protocol setting
+ // TRANSLATORS: %(wireguard)s - will be replaced with "WireGuard"
+ messages.pgettext(
+ 'advanced-settings-view',
+ 'The DNS server you want to add is public and will only work with %(wireguard)s. To ensure that it always works, set the "%(tunnelProtocol)s" (in Advanced settings) to %(wireguard)s.',
+ ),
+ {
+ wireguard: strings.wireguard,
+ tunnelProtocol: messages.pgettext('advanced-settings-view', 'Tunnel protocol'),
+ },
+ );
+ }
return (
<ModalAlert
isOpen={props.isOpen}
@@ -404,18 +448,6 @@ function ConfirmationDialog(props: IConfirmationDialogProps) {
</AppButton.BlueButton>,
]}
close={props.abort}
- message={sprintf(
- // TRANSLATORS: Available placeholders:
- // TRANSLATORS: %(tunnelProtocol)s - the name of the tunnel protocol setting
- // TRANSLATORS: %(wireguard)s - will be replaced with "WireGuard"
- messages.pgettext(
- 'advanced-settings-view',
- 'The DNS server you want to add is public and will only work with %(wireguard)s. To ensure that it always works, set the "%(tunnelProtocol)s" (in Advanced settings) to %(wireguard)s.',
- ),
- {
- wireguard: strings.wireguard,
- tunnelProtocol: messages.pgettext('advanced-settings-view', 'Tunnel protocol'),
- },
- )}></ModalAlert>
+ message={message}></ModalAlert>
);
}