summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2018-09-10 10:32:56 +0200
committerLinus Färnstrand <linus@mullvad.net>2018-09-10 10:32:56 +0200
commit215e0f69ee09aa35517a82ba1b697d50a4eaf1c2 (patch)
treee3824083d477f11da8ec33b60e6271de8ad82432
parentac9d0098d5fcb2d710620af476e972f8d11318ec (diff)
parent0adc869560fec05c820dde7f31cab78c282abe91 (diff)
downloadmullvadvpn-215e0f69ee09aa35517a82ba1b697d50a4eaf1c2.tar.xz
mullvadvpn-215e0f69ee09aa35517a82ba1b697d50a4eaf1c2.zip
Merge branch 'settings-update-subscription'
-rw-r--r--Cargo.lock2
-rw-r--r--mullvad-cli/src/cmds/account.rs4
-rw-r--r--mullvad-cli/src/cmds/auto_connect.rs2
-rw-r--r--mullvad-cli/src/cmds/lan.rs2
-rw-r--r--mullvad-cli/src/cmds/relay.rs2
-rw-r--r--mullvad-cli/src/cmds/tunnel.rs2
-rw-r--r--mullvad-daemon/src/main.rs120
-rw-r--r--mullvad-daemon/src/management_interface.rs75
-rw-r--r--mullvad-ipc-client/src/lib.rs6
-rw-r--r--mullvad-types/Cargo.toml2
-rw-r--r--mullvad-types/src/lib.rs2
-rw-r--r--mullvad-types/src/settings.rs (renamed from mullvad-daemon/src/settings.rs)4
12 files changed, 144 insertions, 79 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 05ff2b7f7c..3957e59b62 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1039,8 +1039,10 @@ dependencies = [
"chrono 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "mullvad-paths 0.1.0",
"serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_json 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)",
"talpid-types 0.1.0",
]
diff --git a/mullvad-cli/src/cmds/account.rs b/mullvad-cli/src/cmds/account.rs
index bab9f525f6..4d42c8c226 100644
--- a/mullvad-cli/src/cmds/account.rs
+++ b/mullvad-cli/src/cmds/account.rs
@@ -59,8 +59,8 @@ impl Account {
fn get(&self) -> Result<()> {
let mut rpc = new_rpc_client()?;
- let account_token = rpc.get_account()?;
- if let Some(account_token) = account_token {
+ let settings = rpc.get_settings()?;
+ if let Some(account_token) = settings.get_account_token() {
println!("Mullvad account: {}", account_token);
let expiry = rpc.get_account_data(account_token)?;
println!("Expires at : {}", expiry.expiry);
diff --git a/mullvad-cli/src/cmds/auto_connect.rs b/mullvad-cli/src/cmds/auto_connect.rs
index 5061f67fb8..7117c0f2aa 100644
--- a/mullvad-cli/src/cmds/auto_connect.rs
+++ b/mullvad-cli/src/cmds/auto_connect.rs
@@ -49,7 +49,7 @@ impl AutoConnect {
fn get(&self) -> Result<()> {
let mut rpc = new_rpc_client()?;
- let auto_connect = rpc.get_auto_connect()?;
+ let auto_connect = rpc.get_settings()?.get_auto_connect();
println!("Autoconnect: {}", if auto_connect { "on" } else { "off" });
Ok(())
}
diff --git a/mullvad-cli/src/cmds/lan.rs b/mullvad-cli/src/cmds/lan.rs
index 65754e3425..80a50a5047 100644
--- a/mullvad-cli/src/cmds/lan.rs
+++ b/mullvad-cli/src/cmds/lan.rs
@@ -48,7 +48,7 @@ impl Lan {
fn get(&self) -> Result<()> {
let mut rpc = new_rpc_client()?;
- let allow_lan = rpc.get_allow_lan()?;
+ let allow_lan = rpc.get_settings()?.get_allow_lan();
println!(
"Local network sharing setting: {}",
if allow_lan { "allow" } else { "block" }
diff --git a/mullvad-cli/src/cmds/relay.rs b/mullvad-cli/src/cmds/relay.rs
index 57cc934b03..70efb6362a 100644
--- a/mullvad-cli/src/cmds/relay.rs
+++ b/mullvad-cli/src/cmds/relay.rs
@@ -191,7 +191,7 @@ impl Relay {
fn get(&self) -> Result<()> {
let mut rpc = new_rpc_client()?;
- let constraints = rpc.get_relay_settings()?;
+ let constraints = rpc.get_settings()?.get_relay_settings();
println!("Current constraints: {:#?}", constraints);
Ok(())
diff --git a/mullvad-cli/src/cmds/tunnel.rs b/mullvad-cli/src/cmds/tunnel.rs
index 04afadf156..fee9188c5d 100644
--- a/mullvad-cli/src/cmds/tunnel.rs
+++ b/mullvad-cli/src/cmds/tunnel.rs
@@ -118,7 +118,7 @@ impl Tunnel {
fn get_tunnel_options() -> Result<TunnelOptions> {
let mut rpc = new_rpc_client()?;
- Ok(rpc.get_tunnel_options()?)
+ Ok(rpc.get_settings()?.get_tunnel_options().clone())
}
fn print_common_tunnel_options(options: &TunnelOptions) {
diff --git a/mullvad-daemon/src/main.rs b/mullvad-daemon/src/main.rs
index 4470a86e30..b4b1f465a8 100644
--- a/mullvad-daemon/src/main.rs
+++ b/mullvad-daemon/src/main.rs
@@ -51,7 +51,6 @@ mod logging;
mod management_interface;
mod relays;
mod rpc_uniqueness_check;
-mod settings;
mod shutdown;
mod system_service;
mod version;
@@ -68,6 +67,7 @@ use mullvad_types::account::{AccountData, AccountToken};
use mullvad_types::location::GeoIpLocation;
use mullvad_types::relay_constraints::{RelaySettings, RelaySettingsUpdate};
use mullvad_types::relay_list::{Relay, RelayList};
+use mullvad_types::settings::Settings;
use mullvad_types::states::TargetState;
use mullvad_types::version::{AppVersion, AppVersionInfo};
@@ -185,7 +185,7 @@ struct Daemon {
rx: mpsc::Receiver<DaemonEvent>,
tx: mpsc::Sender<DaemonEvent>,
management_interface_broadcaster: management_interface::EventBroadcaster,
- settings: settings::Settings,
+ settings: Settings,
accounts_proxy: AccountsProxy<HttpHandle>,
version_proxy: AppVersionProxy<HttpHandle>,
https_handle: mullvad_rpc::rest::RequestSender,
@@ -243,7 +243,7 @@ impl Daemon {
rx,
tx,
management_interface_broadcaster,
- settings: settings::Settings::load().chain_err(|| "Unable to read settings")?,
+ settings: Settings::load().chain_err(|| "Unable to read settings")?,
accounts_proxy: AccountsProxy::new(rpc_handle.clone()),
version_proxy: AppVersionProxy::new(rpc_handle),
https_handle,
@@ -314,21 +314,19 @@ impl Daemon {
fn handle_event(&mut self, event: DaemonEvent) -> Result<()> {
use DaemonEvent::*;
match event {
- TunnelStateTransition(transition) => self.handle_tunnel_state_transition(transition),
- ManagementInterfaceEvent(event) => self.handle_management_interface_event(event),
+ TunnelStateTransition(transition) => {
+ Ok(self.handle_tunnel_state_transition(transition))
+ }
+ ManagementInterfaceEvent(event) => Ok(self.handle_management_interface_event(event)),
ManagementInterfaceExited => self.handle_management_interface_exited(),
- TriggerShutdown => self.handle_trigger_shutdown_event(),
+ TriggerShutdown => Ok(self.handle_trigger_shutdown_event()),
}
}
- fn handle_tunnel_state_transition(
- &mut self,
- tunnel_state: TunnelStateTransition,
- ) -> Result<()> {
+ fn handle_tunnel_state_transition(&mut self, tunnel_state: TunnelStateTransition) {
use self::TunnelStateTransition::*;
debug!("New tunnel state: {:?}", tunnel_state);
-
match tunnel_state {
Disconnected => {
self.state.disconnected();
@@ -339,34 +337,32 @@ impl Daemon {
}
self.tunnel_state = tunnel_state;
-
self.management_interface_broadcaster
.notify_new_state(self.tunnel_state);
-
- Ok(())
}
- fn handle_management_interface_event(&mut self, event: ManagementCommand) -> Result<()> {
+ fn handle_management_interface_event(&mut self, event: ManagementCommand) {
use ManagementCommand::*;
match event {
- SetTargetState(tx, state) => Ok(self.on_set_target_state(tx, state)),
- GetState(tx) => Ok(self.on_get_state(tx)),
- GetCurrentLocation(tx) => Ok(self.on_get_current_location(tx)),
- GetAccountData(tx, account_token) => Ok(self.on_get_account_data(tx, account_token)),
- GetRelayLocations(tx) => Ok(self.on_get_relay_locations(tx)),
+ SetTargetState(tx, state) => self.on_set_target_state(tx, state),
+ GetState(tx) => self.on_get_state(tx),
+ GetCurrentLocation(tx) => self.on_get_current_location(tx),
+ GetAccountData(tx, account_token) => self.on_get_account_data(tx, account_token),
+ GetRelayLocations(tx) => self.on_get_relay_locations(tx),
SetAccount(tx, account_token) => self.on_set_account(tx, account_token),
- GetAccount(tx) => Ok(self.on_get_account(tx)),
+ GetAccount(tx) => self.on_get_account(tx),
UpdateRelaySettings(tx, update) => self.on_update_relay_settings(tx, update),
SetAllowLan(tx, allow_lan) => self.on_set_allow_lan(tx, allow_lan),
- GetAllowLan(tx) => Ok(self.on_get_allow_lan(tx)),
+ GetAllowLan(tx) => self.on_get_allow_lan(tx),
SetAutoConnect(tx, auto_connect) => self.on_set_auto_connect(tx, auto_connect),
- GetAutoConnect(tx) => Ok(self.on_get_auto_connect(tx)),
+ GetAutoConnect(tx) => self.on_get_auto_connect(tx),
SetOpenVpnMssfix(tx, mssfix_arg) => self.on_set_openvpn_mssfix(tx, mssfix_arg),
SetEnableIpv6(tx, enable_ipv6) => self.on_set_enable_ipv6(tx, enable_ipv6),
GetTunnelOptions(tx) => self.on_get_tunnel_options(tx),
- GetRelaySettings(tx) => Ok(self.on_get_relay_settings(tx)),
- GetVersionInfo(tx) => Ok(self.on_get_version_info(tx)),
- GetCurrentVersion(tx) => Ok(self.on_get_current_version(tx)),
+ GetSettings(tx) => self.on_get_settings(tx),
+ GetRelaySettings(tx) => self.on_get_relay_settings(tx),
+ GetVersionInfo(tx) => self.on_get_version_info(tx),
+ GetCurrentVersion(tx) => self.on_get_current_version(tx),
Shutdown => self.handle_trigger_shutdown_event(),
}
}
@@ -429,11 +425,7 @@ impl Daemon {
}
- fn on_set_account(
- &mut self,
- tx: OneshotSender<()>,
- account_token: Option<String>,
- ) -> Result<()> {
+ fn on_set_account(&mut self, tx: OneshotSender<()>, account_token: Option<String>) {
let account_token_cleared = account_token.is_none();
let save_result = self.settings.set_account_token(account_token);
@@ -441,6 +433,8 @@ impl Daemon {
Ok(account_changed) => {
Self::oneshot_send(tx, (), "set_account response");
if account_changed {
+ self.management_interface_broadcaster
+ .notify_settings(&self.settings);
if account_token_cleared {
info!("Disconnecting because account token was cleared");
let _ = self.set_target_state(TargetState::Unsecured);
@@ -452,7 +446,6 @@ impl Daemon {
}
Err(e) => error!("{}", e.display_chain()),
}
- Ok(())
}
fn on_get_version_info(
@@ -482,13 +475,8 @@ impl Daemon {
Self::oneshot_send(tx, self.settings.get_account_token(), "current account")
}
- fn on_update_relay_settings(
- &mut self,
- tx: OneshotSender<()>,
- update: RelaySettingsUpdate,
- ) -> Result<()> {
+ fn on_update_relay_settings(&mut self, tx: OneshotSender<()>, update: RelaySettingsUpdate) {
let save_result = self.settings.update_relay_settings(update);
-
match save_result.chain_err(|| "Unable to save settings") {
Ok(changed) => {
Self::oneshot_send(tx, (), "update_relay_settings response");
@@ -500,39 +488,43 @@ impl Daemon {
}
Err(e) => error!("{}", e.display_chain()),
}
-
- Ok(())
}
fn on_get_relay_settings(&self, tx: OneshotSender<RelaySettings>) {
Self::oneshot_send(tx, self.settings.get_relay_settings(), "relay settings")
}
- fn on_set_allow_lan(&mut self, tx: OneshotSender<()>, allow_lan: bool) -> Result<()> {
+ fn on_set_allow_lan(&mut self, tx: OneshotSender<()>, allow_lan: bool) {
let save_result = self.settings.set_allow_lan(allow_lan);
match save_result.chain_err(|| "Unable to save settings") {
Ok(settings_changed) => {
if settings_changed {
+ self.management_interface_broadcaster
+ .notify_settings(&self.settings);
self.send_tunnel_command(TunnelCommand::AllowLan(allow_lan));
}
Self::oneshot_send(tx, (), "set_allow_lan response");
}
Err(e) => error!("{}", e.display_chain()),
}
- Ok(())
}
fn on_get_allow_lan(&self, tx: OneshotSender<bool>) {
Self::oneshot_send(tx, self.settings.get_allow_lan(), "allow lan")
}
- fn on_set_auto_connect(&mut self, tx: OneshotSender<()>, auto_connect: bool) -> Result<()> {
+ fn on_set_auto_connect(&mut self, tx: OneshotSender<()>, auto_connect: bool) {
let save_result = self.settings.set_auto_connect(auto_connect);
match save_result.chain_err(|| "Unable to save settings") {
- Ok(_settings_changed) => Self::oneshot_send(tx, (), "set auto-connect response"),
+ Ok(settings_changed) => {
+ Self::oneshot_send(tx, (), "set auto-connect response");
+ if settings_changed {
+ self.management_interface_broadcaster
+ .notify_settings(&self.settings);
+ }
+ }
Err(e) => error!("{}", e.display_chain()),
}
- Ok(())
}
fn on_get_auto_connect(&self, tx: OneshotSender<bool>) {
@@ -543,41 +535,43 @@ impl Daemon {
)
}
- fn on_set_openvpn_mssfix(
- &mut self,
- tx: OneshotSender<()>,
- mssfix_arg: Option<u16>,
- ) -> Result<()> {
+ fn on_set_openvpn_mssfix(&mut self, tx: OneshotSender<()>, mssfix_arg: Option<u16>) {
let save_result = self.settings.set_openvpn_mssfix(mssfix_arg);
match save_result.chain_err(|| "Unable to save settings") {
- Ok(_) => Self::oneshot_send(tx, (), "set_openvpn_mssfix response"),
+ Ok(settings_changed) => {
+ Self::oneshot_send(tx, (), "set_openvpn_mssfix response");
+ if settings_changed {
+ self.management_interface_broadcaster
+ .notify_settings(&self.settings);
+ }
+ }
Err(e) => error!("{}", e.display_chain()),
- };
- Ok(())
+ }
}
- fn on_set_enable_ipv6(&mut self, tx: OneshotSender<()>, enable_ipv6: bool) -> Result<()> {
+ fn on_set_enable_ipv6(&mut self, tx: OneshotSender<()>, enable_ipv6: bool) {
let save_result = self.settings.set_enable_ipv6(enable_ipv6);
-
match save_result.chain_err(|| "Unable to save settings") {
Ok(settings_changed) => {
Self::oneshot_send(tx, (), "set_enable_ipv6 response");
-
if settings_changed {
+ self.management_interface_broadcaster
+ .notify_settings(&self.settings);
info!("Initiating tunnel restart because the enable IPv6 setting changed");
self.reconnect_tunnel();
}
}
Err(e) => error!("{}", e.display_chain()),
- };
-
- Ok(())
+ }
}
- fn on_get_tunnel_options(&self, tx: OneshotSender<TunnelOptions>) -> Result<()> {
+ fn on_get_tunnel_options(&self, tx: OneshotSender<TunnelOptions>) {
let tunnel_options = self.settings.get_tunnel_options().clone();
Self::oneshot_send(tx, tunnel_options, "get_tunnel_options response");
- Ok(())
+ }
+
+ fn on_get_settings(&self, tx: OneshotSender<Settings>) {
+ Self::oneshot_send(tx, self.settings.clone(), "get_settings response");
}
fn oneshot_send<T>(tx: OneshotSender<T>, t: T, msg: &'static str) {
@@ -590,11 +584,9 @@ impl Daemon {
Err(ErrorKind::ManagementInterfaceError("Server exited unexpectedly").into())
}
- fn handle_trigger_shutdown_event(&mut self) -> Result<()> {
+ fn handle_trigger_shutdown_event(&mut self) {
self.state.shutdown(self.tunnel_state);
self.disconnect_tunnel();
-
- Ok(())
}
/// Set the target state of the client. If it changed trigger the operations needed to
diff --git a/mullvad-daemon/src/management_interface.rs b/mullvad-daemon/src/management_interface.rs
index 383693bb27..2e534baf52 100644
--- a/mullvad-daemon/src/management_interface.rs
+++ b/mullvad-daemon/src/management_interface.rs
@@ -12,9 +12,12 @@ use mullvad_types::location::GeoIpLocation;
use mullvad_paths;
use mullvad_types::relay_constraints::{RelaySettings, RelaySettingsUpdate};
use mullvad_types::relay_list::RelayList;
+use mullvad_types::settings::Settings;
use mullvad_types::states::TargetState;
use mullvad_types::version;
+use serde;
+
use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::path::PathBuf;
@@ -37,7 +40,6 @@ build_rpc_trait! {
pub trait ManagementInterfaceApi {
type Metadata;
-
/// Fetches and returns metadata about an account. Returns an error on non-existing
/// accounts.
#[rpc(meta, name = "get_account_data")]
@@ -128,6 +130,10 @@ build_rpc_trait! {
#[rpc(meta, name = "get_tunnel_options")]
fn get_tunnel_options(&self, Self::Metadata) -> BoxFuture<TunnelOptions, Error>;
+ /// Returns the current daemon settings
+ #[rpc(meta, name = "get_settings")]
+ fn get_settings(&self, Self::Metadata) -> BoxFuture<Settings, Error>;
+
/// Retreive version of the app
#[rpc(meta, name = "get_current_version")]
fn get_current_version(&self, Self::Metadata) -> BoxFuture<String, Error>;
@@ -149,6 +155,17 @@ build_rpc_trait! {
#[rpc(name = "new_state_unsubscribe")]
fn new_state_unsubscribe(&self, SubscriptionId) -> BoxFuture<(), Error>;
}
+
+ #[pubsub(name = "settings")] {
+ /// Subscribes to the `settings` event notifications. Getting notified as soon as any
+ /// daemon settings change.
+ #[rpc(name = "settings_subscribe")]
+ fn settings_subscribe(&self, Self::Metadata, pubsub::Subscriber<Settings>);
+
+ /// Unsubscribes from the `settings` event notifications.
+ #[rpc(name = "settings_unsubscribe")]
+ fn settings_unsubscribe(&self, SubscriptionId) -> BoxFuture<(), Error>;
+ }
}
}
@@ -190,6 +207,8 @@ pub enum ManagementCommand {
SetEnableIpv6(OneshotSender<()>, bool),
/// Get the tunnel options
GetTunnelOptions(OneshotSender<TunnelOptions>),
+ /// Get the daemon settings
+ GetSettings(OneshotSender<Settings>),
/// Get information about the currently running and latest app versions
GetVersionInfo(OneshotSender<BoxFuture<version::AppVersionInfo, mullvad_rpc::Error>>),
/// Get current version of the app
@@ -198,9 +217,15 @@ pub enum ManagementCommand {
Shutdown,
}
+#[derive(Default)]
+struct ActiveSubscriptions {
+ new_state_subscriptions: RwLock<HashMap<SubscriptionId, pubsub::Sink<TunnelStateTransition>>>,
+ settings_subscriptions: RwLock<HashMap<SubscriptionId, pubsub::Sink<Settings>>>,
+}
+
pub struct ManagementInterfaceServer {
server: talpid_ipc::IpcServer,
- subscriptions: Arc<RwLock<HashMap<SubscriptionId, pubsub::Sink<TunnelStateTransition>>>>,
+ subscriptions: Arc<ActiveSubscriptions>,
}
impl ManagementInterfaceServer {
@@ -248,22 +273,37 @@ impl ManagementInterfaceServer {
/// A handle that allows broadcasting messages to all subscribers of the management interface.
pub struct EventBroadcaster {
- subscriptions: Arc<RwLock<HashMap<SubscriptionId, pubsub::Sink<TunnelStateTransition>>>>,
+ subscriptions: Arc<ActiveSubscriptions>,
}
impl EventBroadcaster {
/// Sends a new state update to all `new_state` subscribers of the management interface.
pub fn notify_new_state(&self, new_state: TunnelStateTransition) {
debug!("Broadcasting new state to listeners: {:?}", new_state);
- let subscriptions = self.subscriptions.read().unwrap();
+ self.notify(&self.subscriptions.new_state_subscriptions, new_state);
+ }
+
+ /// Sends settings to all `settings` subscribers of the management interface.
+ pub fn notify_settings(&self, settings: &Settings) {
+ self.notify(&self.subscriptions.settings_subscriptions, settings.clone());
+ }
+
+ fn notify<T>(
+ &self,
+ subscriptions_lock: &RwLock<HashMap<SubscriptionId, pubsub::Sink<T>>>,
+ value: T,
+ ) where
+ T: serde::Serialize + Clone,
+ {
+ let subscriptions = subscriptions_lock.read().unwrap();
for sink in subscriptions.values() {
- let _ = sink.notify(Ok(new_state.clone())).wait();
+ let _ = sink.notify(Ok(value.clone())).wait();
}
}
}
struct ManagementInterface<T: From<ManagementCommand> + 'static + Send> {
- subscriptions: Arc<RwLock<HashMap<SubscriptionId, pubsub::Sink<TunnelStateTransition>>>>,
+ subscriptions: Arc<ActiveSubscriptions>,
tx: Mutex<IntoSender<ManagementCommand, T>>,
cache_dir: PathBuf,
}
@@ -586,6 +626,15 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi
Box::new(future)
}
+ fn get_settings(&self, _: Self::Metadata) -> BoxFuture<Settings, Error> {
+ debug!("get_settings");
+ let (tx, rx) = sync::oneshot::channel();
+ let future = self
+ .send_command_to_daemon(ManagementCommand::GetSettings(tx))
+ .and_then(|_| rx.map_err(|_| Error::internal_error()));
+ Box::new(future)
+ }
+
fn get_current_version(&self, _: Self::Metadata) -> BoxFuture<String, Error> {
debug!("get_current_version");
let (tx, rx) = sync::oneshot::channel();
@@ -621,12 +670,22 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi
subscriber: pubsub::Subscriber<TunnelStateTransition>,
) {
debug!("new_state_subscribe");
- Self::subscribe(subscriber, &self.subscriptions);
+ Self::subscribe(subscriber, &self.subscriptions.new_state_subscriptions);
}
fn new_state_unsubscribe(&self, id: SubscriptionId) -> BoxFuture<(), Error> {
debug!("new_state_unsubscribe");
- Self::unsubscribe(id, &self.subscriptions)
+ Self::unsubscribe(id, &self.subscriptions.new_state_subscriptions)
+ }
+
+ fn settings_subscribe(&self, _: Self::Metadata, subscriber: pubsub::Subscriber<Settings>) {
+ debug!("settings_subscribe");
+ Self::subscribe(subscriber, &self.subscriptions.settings_subscriptions);
+ }
+
+ fn settings_unsubscribe(&self, id: SubscriptionId) -> BoxFuture<(), Error> {
+ debug!("settings_unsubscribe");
+ Self::unsubscribe(id, &self.subscriptions.settings_subscriptions)
}
}
diff --git a/mullvad-ipc-client/src/lib.rs b/mullvad-ipc-client/src/lib.rs
index 239b68d8c7..b03c741589 100644
--- a/mullvad-ipc-client/src/lib.rs
+++ b/mullvad-ipc-client/src/lib.rs
@@ -25,7 +25,9 @@ use mullvad_types::account::{AccountData, AccountToken};
use mullvad_types::location::GeoIpLocation;
use mullvad_types::relay_constraints::{RelaySettings, RelaySettingsUpdate};
use mullvad_types::relay_list::RelayList;
+use mullvad_types::settings::Settings;
use mullvad_types::version::AppVersionInfo;
+
use serde::{Deserialize, Serialize};
use talpid_types::net::TunnelOptions;
use talpid_types::tunnel::TunnelStateTransition;
@@ -182,6 +184,10 @@ impl DaemonRpcClient {
self.call("get_tunnel_options", &NO_ARGS)
}
+ pub fn get_settings(&mut self) -> Result<Settings> {
+ self.call("get_settings", &NO_ARGS)
+ }
+
pub fn get_version_info(&mut self) -> Result<AppVersionInfo> {
self.call("get_version_info", &NO_ARGS)
}
diff --git a/mullvad-types/Cargo.toml b/mullvad-types/Cargo.toml
index 1076d22b17..9b617d257a 100644
--- a/mullvad-types/Cargo.toml
+++ b/mullvad-types/Cargo.toml
@@ -9,7 +9,9 @@ license = "GPL-3.0"
chrono = { version = "0.4", features = ["serde"] }
serde_derive = "1.0"
serde = "1.0"
+serde_json = "1.0"
error-chain = "0.12"
log = "0.4"
talpid-types = { path = "../talpid-types" }
+mullvad-paths = { path = "../mullvad-paths" }
diff --git a/mullvad-types/src/lib.rs b/mullvad-types/src/lib.rs
index 6cae36372d..ff7628b9ad 100644
--- a/mullvad-types/src/lib.rs
+++ b/mullvad-types/src/lib.rs
@@ -11,6 +11,7 @@ extern crate serde;
#[macro_use]
extern crate serde_derive;
+extern crate mullvad_paths;
extern crate talpid_types;
#[macro_use]
@@ -23,6 +24,7 @@ pub mod account;
pub mod location;
pub mod relay_constraints;
pub mod relay_list;
+pub mod settings;
pub mod states;
pub mod version;
diff --git a/mullvad-daemon/src/settings.rs b/mullvad-types/src/settings.rs
index 216d18f4d8..231a1b638d 100644
--- a/mullvad-daemon/src/settings.rs
+++ b/mullvad-types/src/settings.rs
@@ -1,6 +1,6 @@
extern crate serde_json;
-use mullvad_types::relay_constraints::{
+use relay_constraints::{
Constraint, LocationConstraint, RelayConstraints, RelaySettings, RelaySettingsUpdate,
};
use talpid_types::net::TunnelOptions;
@@ -30,6 +30,8 @@ error_chain! {
static SETTINGS_FILE: &str = "settings.json";
+
+/// Mullvad daemon settings.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(default)]
pub struct Settings {