summaryrefslogtreecommitdiffhomepage
path: root/app/lib
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@codeispoetry.ru>2017-02-24 15:20:52 +0000
committerAndrej Mihajlov <and@codeispoetry.ru>2017-02-24 15:20:52 +0000
commite2c417059216d983c3e7d9560cfad02d82297aba (patch)
treee6683b6616db131e3a4f1823cf9403f82c1909c1 /app/lib
parent040c1ef18fec5ab1aac5bfef4fc596f0c4591e9f (diff)
downloadmullvadvpn-e2c417059216d983c3e7d9560cfad02d82297aba.tar.xz
mullvadvpn-e2c417059216d983c3e7d9560cfad02d82297aba.zip
- Move serverInfo configuration to backend
- Update settings - Reconnect when switching location
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/backend.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/app/lib/backend.js b/app/lib/backend.js
index 0add43f24f..abc6e56aba 100644
--- a/app/lib/backend.js
+++ b/app/lib/backend.js
@@ -1,5 +1,6 @@
import Enum from './enum';
import { EventEmitter } from 'events';
+import { servers } from '../constants';
const EventType = Enum('connect', 'connecting', 'disconnect', 'login', 'logging', 'logout', 'updatedIp');
@@ -31,6 +32,34 @@ export default class Backend extends EventEmitter {
// Public methods
+ serverInfo(key) {
+ switch(key) {
+ case 'fastest': return this.fastestServer();
+ case 'nearest': return this.nearestServer();
+ default: return servers[key] || {};
+ }
+ }
+
+ fastestServer() {
+ return {
+ address: 'uk.mullvad.net',
+ name: 'Fastest',
+ city: 'London',
+ country: 'United Kingdom',
+ location: [51.5073509, -0.1277583]
+ };
+ }
+
+ nearestServer() {
+ return {
+ address: 'es.mullvad.net',
+ name: 'Nearest',
+ city: 'Madrid',
+ country: 'Spain',
+ location: [40.4167754, -3.7037902]
+ };
+ }
+
login(account) {
this._account = account;
@@ -58,6 +87,8 @@ export default class Backend extends EventEmitter {
}
connect(addr) {
+ this.disconnect();
+
this._serverAddress = addr;
// emit: connecting