summaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2017-11-21 12:34:20 +0100
committerAndrej Mihajlov <and@mullvad.net>2017-11-23 12:41:13 +0100
commit0d5771aa9b7a8f50cb514b2e7527ff748cdde7f0 (patch)
treeded53c8123e63824acf8367cecb90f63f15752ff /app
parenta1a7a920e787689eed8525f4c2ffd521c9d538ff (diff)
downloadmullvadvpn-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')
-rw-r--r--app/components/AdvancedSettings.js11
-rw-r--r--app/containers/AdvancedSettingsPage.js47
2 files changed, 27 insertions, 31 deletions
diff --git a/app/components/AdvancedSettings.js b/app/components/AdvancedSettings.js
index 227499a1a8..1821309369 100644
--- a/app/components/AdvancedSettings.js
+++ b/app/components/AdvancedSettings.js
@@ -7,14 +7,16 @@ import CustomScrollbars from './CustomScrollbars';
export class AdvancedSettings extends React.Component {
props: {
- onClose: () => void,
+ host: string,
protocol: string,
port: string|number,
- updateConstraints: (string, string|number) => void,
+ onUpdateConstraints: (host: string, protocol: string, port: string|number) => void,
+ onClose: () => void,
};
render() {
let portSelector = null;
+ const host = this.props.host;
let protocol = this.props.protocol.toUpperCase();
if (protocol === 'AUTOMATIC') {
@@ -30,7 +32,7 @@ export class AdvancedSettings extends React.Component {
values={ ['Automatic', 'UDP', 'TCP'] }
value={ protocol }
onSelect={ protocol => {
- this.props.updateConstraints(protocol, 'Automatic');
+ this.props.onUpdateConstraints(host, protocol, 'Automatic');
}}/>
<div className="settings__cell-spacer"></div>
@@ -41,6 +43,7 @@ export class AdvancedSettings extends React.Component {
}
_createPortSelector() {
+ const host = this.props.host;
const protocol = this.props.protocol.toUpperCase();
const ports = protocol === 'TCP'
? ['Automatic', 80, 443]
@@ -51,7 +54,7 @@ export class AdvancedSettings extends React.Component {
values={ ports }
value={ this.props.port }
onSelect={ port => {
- this.props.updateConstraints(protocol, port);
+ this.props.onUpdateConstraints(host, protocol, port);
}} />;
}
}
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));
},