diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-02-15 09:45:54 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-02-15 09:45:54 +0100 |
| commit | b6c066c8bc86deaf6b1d80296bdbd9e3fd3c5c77 (patch) | |
| tree | 00ed023257bd6d064ab425ecb320a378cf02f58b /gui/src/renderer/components | |
| parent | 85c7801a87e99af8e698a6847604510d7233cd7a (diff) | |
| parent | 31149d6acc62c52cd0bad3e1f80f7f86151d6487 (diff) | |
| download | mullvadvpn-b6c066c8bc86deaf6b1d80296bdbd9e3fd3c5c77.tar.xz mullvadvpn-b6c066c8bc86deaf6b1d80296bdbd9e3fd3c5c77.zip | |
Merge branch 'improve-ip-validation'
Diffstat (limited to 'gui/src/renderer/components')
| -rw-r--r-- | gui/src/renderer/components/AdvancedSettings.tsx | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/gui/src/renderer/components/AdvancedSettings.tsx b/gui/src/renderer/components/AdvancedSettings.tsx index 3f840f4492..b24b849b5f 100644 --- a/gui/src/renderer/components/AdvancedSettings.tsx +++ b/gui/src/renderer/components/AdvancedSettings.tsx @@ -1,4 +1,3 @@ -import ip from 'ip'; import * as React from 'react'; import { sprintf } from 'sprintf-js'; import { colors } from '../../config.json'; @@ -10,6 +9,7 @@ import { } from '../../shared/daemon-rpc-types'; import { messages } from '../../shared/gettext'; import consumePromise from '../../shared/promise'; +import { IpAddress } from '../lib/ip'; import { WgKeyState } from '../redux/settings/reducers'; import { StyledButtonCellGroup, @@ -575,21 +575,19 @@ export default class AdvancedSettings extends React.Component<IProps, IState> { }; private addDnsAddress = async (address: string, confirmed?: boolean) => { - if (ip.isV4Format(address) || ip.isV6Format(address)) { - if (ip.isPublic(address) && !confirmed) { - this.setState({ publicDnsIpToConfirm: address }); + try { + const ipAddress = IpAddress.fromString(address); + + if (ipAddress.isLocal() || confirmed) { + await this.props.setDnsOptions({ + custom: this.props.dns.custom || this.state.showAddCustomDns, + addresses: [...this.props.dns.addresses, address], + }); + this.hideAddCustomDnsRow(); } else { - try { - await this.props.setDnsOptions({ - custom: this.props.dns.custom || this.state.showAddCustomDns, - addresses: [...this.props.dns.addresses, address], - }); - this.hideAddCustomDnsRow(); - } catch (_e) { - this.setState({ invalidDnsIp: true }); - } + this.setState({ publicDnsIpToConfirm: address }); } - } else { + } catch (e) { this.setState({ invalidDnsIp: true }); } }; |
