diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-05-04 15:29:04 -0300 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-05-07 08:55:03 -0300 |
| commit | 02f76355d339166d259c60420358e35553753c35 (patch) | |
| tree | dce3e3e96d778d0bf3a2b63efe8429cc07220380 | |
| parent | 083fa2b11bb3ac32e62ecabe4a66ab4c1a94d68c (diff) | |
| download | mullvadvpn-02f76355d339166d259c60420358e35553753c35.tar.xz mullvadvpn-02f76355d339166d259c60420358e35553753c35.zip | |
Borrow server ID instead of moving it
| -rw-r--r-- | mullvad-ipc-client/src/lib.rs | 2 | ||||
| -rw-r--r-- | talpid-ipc/src/client.rs | 4 | ||||
| -rw-r--r-- | talpid-ipc/tests/ipc-client-server.rs | 8 | ||||
| -rw-r--r-- | talpid-openvpn-plugin/src/lib.rs | 2 | ||||
| -rw-r--r-- | talpid-openvpn-plugin/src/processing.rs | 2 |
5 files changed, 9 insertions, 9 deletions
diff --git a/mullvad-ipc-client/src/lib.rs b/mullvad-ipc-client/src/lib.rs index 90c14de5d6..0e8cffdcd8 100644 --- a/mullvad-ipc-client/src/lib.rs +++ b/mullvad-ipc-client/src/lib.rs @@ -168,7 +168,7 @@ impl DaemonRpcClient { A: Serialize, O: for<'de> Deserialize<'de>, { - let mut rpc_client = WsIpcClient::connect(self.address.clone()) + let mut rpc_client = WsIpcClient::connect(&self.address) .chain_err(|| ErrorKind::StartRpcClient(self.address.clone()))?; rpc_client diff --git a/talpid-ipc/src/client.rs b/talpid-ipc/src/client.rs index 19f981d379..9e76bfe443 100644 --- a/talpid-ipc/src/client.rs +++ b/talpid-ipc/src/client.rs @@ -180,8 +180,8 @@ pub struct WsIpcClient { } impl WsIpcClient { - pub fn connect(server_id: ::IpcServerId) -> Result<Self> { - let url = url::Url::parse(&server_id).chain_err(|| "Unable to parse server_id as url")?; + pub fn connect(server_id: &::IpcServerId) -> Result<Self> { + let url = url::Url::parse(server_id).chain_err(|| "Unable to parse server_id as url")?; let active_request = Arc::new(Mutex::new(None)); let sender = Self::open_websocket(url, active_request.clone())?; diff --git a/talpid-ipc/tests/ipc-client-server.rs b/talpid-ipc/tests/ipc-client-server.rs index 150c950b96..34b44beb68 100644 --- a/talpid-ipc/tests/ipc-client-server.rs +++ b/talpid-ipc/tests/ipc-client-server.rs @@ -36,7 +36,7 @@ fn can_call_rpcs_on_server() { let (server, rx) = create_server(); let server_id = server.address().to_owned(); - let mut client = create_client(server_id); + let mut client = create_client(&server_id); let _result: () = client.call("foo", &[97]).unwrap(); assert_eq!(Ok(97), rx.recv_timeout(Duration::from_millis(500))); @@ -51,12 +51,12 @@ fn can_call_rpcs_on_server() { #[test] #[should_panic] fn ipc_client_invalid_url() { - create_client("INVALID ID".to_owned()); + create_client(&"INVALID ID".to_owned()); } #[test] fn ipc_client_bad_connection() { - let mut client = create_client("ws://127.0.0.1:9876".to_owned()); + let mut client = create_client(&"ws://127.0.0.1:9876".to_owned()); let result: Result<(), _> = client.call("invalid_method", &[0]); assert_matches!(result, Err(_)); } @@ -71,6 +71,6 @@ fn create_server() -> (talpid_ipc::IpcServer, mpsc::Receiver<i64>) { (server, rx) } -fn create_client(id: talpid_ipc::IpcServerId) -> talpid_ipc::WsIpcClient { +fn create_client(id: &talpid_ipc::IpcServerId) -> talpid_ipc::WsIpcClient { talpid_ipc::WsIpcClient::connect(id).unwrap() } diff --git a/talpid-openvpn-plugin/src/lib.rs b/talpid-openvpn-plugin/src/lib.rs index f1c210b4d1..71c332a212 100644 --- a/talpid-openvpn-plugin/src/lib.rs +++ b/talpid-openvpn-plugin/src/lib.rs @@ -66,7 +66,7 @@ fn openvpn_open( let core_server_id = parse_args(&args)?; info!("Connecting back to talpid core at {}", core_server_id); - let processor = EventProcessor::new(core_server_id).chain_err(|| ErrorKind::InitHandleFailed)?; + let processor = EventProcessor::new(&core_server_id).chain_err(|| ErrorKind::InitHandleFailed)?; Ok((INTERESTING_EVENTS.to_vec(), processor)) } diff --git a/talpid-openvpn-plugin/src/processing.rs b/talpid-openvpn-plugin/src/processing.rs index 5fc2a1312e..a376665888 100644 --- a/talpid-openvpn-plugin/src/processing.rs +++ b/talpid-openvpn-plugin/src/processing.rs @@ -18,7 +18,7 @@ pub struct EventProcessor { } impl EventProcessor { - pub fn new(server_id: IpcServerId) -> Result<EventProcessor> { + pub fn new(server_id: &IpcServerId) -> Result<EventProcessor> { trace!("Creating EventProcessor"); let ipc_client = WsIpcClient::connect(server_id).chain_err(|| "Unable to create IPC client")?; |
