diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2017-11-21 12:34:20 +0100 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2017-11-23 12:41:13 +0100 |
| commit | 0d5771aa9b7a8f50cb514b2e7527ff748cdde7f0 (patch) | |
| tree | ded53c8123e63824acf8367cecb90f63f15752ff /app/containers | |
| parent | a1a7a920e787689eed8525f4c2ffd521c9d538ff (diff) | |
| download | mullvadvpn-0d5771aa9b7a8f50cb514b2e7527ff748cdde7f0.tar.xz mullvadvpn-0d5771aa9b7a8f50cb514b2e7527ff748cdde7f0.zip | |
Temporary hardcode automatic constraints selection since we cannot use
any constraint with custom tunnel endpoint
Diffstat (limited to 'app/containers')
| -rw-r--r-- | app/containers/AdvancedSettingsPage.js | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/app/containers/AdvancedSettingsPage.js b/app/containers/AdvancedSettingsPage.js index 632ce089be..fd83406c25 100644 --- a/app/containers/AdvancedSettingsPage.js +++ b/app/containers/AdvancedSettingsPage.js @@ -5,47 +5,40 @@ import settingsActions from '../redux/settings/actions'; import log from 'electron-log'; const mapStateToProps = (state) => { - const contraints = state.settings.relaySettings; + const constraints = state.settings.relaySettings; + const { host, protocol, port } = constraints; return { - protocol: anyToAuto(contraints.protocol), - port: anyToAuto(contraints.port), + host: host, + protocol: protocol === 'any' ? 'Automatic' : protocol, + port: port === 'any' ? 'Automatic' : port, }; }; -function anyToAuto(constraint) { - if (constraint === 'any') { - return 'Automatic'; - } else { - return constraint; - } -} - const mapDispatchToProps = (dispatch, props) => { const { backend } = props; return { onClose: () => dispatch(push('/settings')), - updateConstraints: (protocol, port) => { - - const protConstraint = protocol === 'Automatic' - ? 'any' - : { only: protocol.toLowerCase() }; - - const portConstraint = port === 'Automatic' - ? 'any' - : { only: port }; - + onUpdateConstraints: (host, protocol, port) => { + // TODO: udp and 1300 are automatic because we cannot pass `any` when using custom tunnel + const protocolConstraint = protocol === 'Automatic' ? 'udp' : protocol.toLowerCase(); + const portConstraint = port === 'Automatic' ? (protocolConstraint === 'tcp' ? 443 : 1300) : port; const update = { - tunnel: { openvpn: { - protocol: protConstraint, - port: portConstraint, - }}, + custom_tunnel_endpoint: { + host: host, + tunnel: { + openvpn: { + protocol: protocolConstraint, + port: portConstraint, + } + } + }, }; backend.updateRelaySettings(update) .then( () => dispatch(settingsActions.updateRelay({ - port: typeof(portConstraint) === 'object' ? portConstraint.only : portConstraint, - protocol: typeof(protConstraint) === 'object' ? protConstraint.only : protConstraint, + protocol: protocolConstraint, + port: portConstraint, }))) .catch( e => log.error('Failed updating relay constraints', e.message)); }, |
