From 9cd217fc5d8199c1d19f9c8ea3d95bfa39028e67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Fri, 22 Jan 2021 10:01:21 +0100 Subject: [PATCH] matrix-sdk: Remove the proxy usage from the exmaples for now While it's generally useful to watch what the sdk is sending out during development using mitmproxy, users of the sdk might wonder why the example doesn't connect. Remove the proxy usage until we add a cli parser which can enable proxy support with a command line switch. --- matrix_sdk/examples/command_bot.rs | 5 +---- matrix_sdk/examples/cross_signing_bootstrap.rs | 9 ++------- matrix_sdk/examples/emoji_verification.rs | 8 ++------ matrix_sdk/examples/get_profiles.rs | 9 ++------- matrix_sdk/examples/image_bot.rs | 8 ++------ matrix_sdk/examples/login.rs | 7 ++----- 6 files changed, 11 insertions(+), 35 deletions(-) diff --git a/matrix_sdk/examples/command_bot.rs b/matrix_sdk/examples/command_bot.rs index a3f12d36..0afca9b9 100644 --- a/matrix_sdk/examples/command_bot.rs +++ b/matrix_sdk/examples/command_bot.rs @@ -69,10 +69,7 @@ async fn login_and_sync( let mut home = dirs::home_dir().expect("no home directory found"); home.push("party_bot"); - let client_config = ClientConfig::new() - .proxy("http://localhost:8080")? - .disable_ssl_verification() - .store_path(home); + let client_config = ClientConfig::new().store_path(home); let homeserver_url = Url::parse(&homeserver_url).expect("Couldn't parse the homeserver URL"); // create a new Client with the given homeserver url and config diff --git a/matrix_sdk/examples/cross_signing_bootstrap.rs b/matrix_sdk/examples/cross_signing_bootstrap.rs index 5f910bf4..710ddc1f 100644 --- a/matrix_sdk/examples/cross_signing_bootstrap.rs +++ b/matrix_sdk/examples/cross_signing_bootstrap.rs @@ -9,8 +9,7 @@ use serde_json::json; use url::Url; use matrix_sdk::{ - self, api::r0::uiaa::AuthData, identifiers::UserId, Client, ClientConfig, LoopCtrl, - SyncSettings, + self, api::r0::uiaa::AuthData, identifiers::UserId, Client, LoopCtrl, SyncSettings, }; fn auth_data<'a>(user: &UserId, password: &str, session: Option<&'a str>) -> AuthData<'a> { @@ -64,12 +63,8 @@ async fn login( username: &str, password: &str, ) -> Result<(), matrix_sdk::Error> { - let client_config = ClientConfig::new() - .disable_ssl_verification() - .proxy("http://localhost:8080") - .unwrap(); let homeserver_url = Url::parse(&homeserver_url).expect("Couldn't parse the homeserver URL"); - let client = Client::new_with_config(homeserver_url, client_config).unwrap(); + let client = Client::new(homeserver_url).unwrap(); let response = client .login(username, password, None, Some("rust-sdk")) diff --git a/matrix_sdk/examples/emoji_verification.rs b/matrix_sdk/examples/emoji_verification.rs index 2dfc1a1e..18ce6b17 100644 --- a/matrix_sdk/examples/emoji_verification.rs +++ b/matrix_sdk/examples/emoji_verification.rs @@ -14,7 +14,7 @@ use matrix_sdk::{ room::message::MessageEventContent, AnySyncMessageEvent, AnySyncRoomEvent, AnyToDeviceEvent, }, identifiers::UserId, - Client, ClientConfig, LoopCtrl, Sas, SyncSettings, + Client, LoopCtrl, Sas, SyncSettings, }; async fn wait_for_confirmation(client: Client, sas: Sas) { @@ -67,12 +67,8 @@ async fn login( username: &str, password: &str, ) -> Result<(), matrix_sdk::Error> { - let client_config = ClientConfig::new() - .disable_ssl_verification() - .proxy("http://localhost:8080") - .unwrap(); let homeserver_url = Url::parse(&homeserver_url).expect("Couldn't parse the homeserver URL"); - let client = Client::new_with_config(homeserver_url, client_config).unwrap(); + let client = Client::new(homeserver_url).unwrap(); client .login(username, password, None, Some("rust-sdk")) diff --git a/matrix_sdk/examples/get_profiles.rs b/matrix_sdk/examples/get_profiles.rs index 8aea2206..c75d25b4 100644 --- a/matrix_sdk/examples/get_profiles.rs +++ b/matrix_sdk/examples/get_profiles.rs @@ -2,9 +2,7 @@ use std::{convert::TryFrom, env, process::exit}; use url::Url; -use matrix_sdk::{ - self, api::r0::profile, identifiers::UserId, Client, ClientConfig, Result as MatrixResult, -}; +use matrix_sdk::{self, api::r0::profile, identifiers::UserId, Client, Result as MatrixResult}; #[derive(Debug)] struct UserProfile { @@ -38,11 +36,8 @@ async fn login( username: &str, password: &str, ) -> Result { - let client_config = ClientConfig::new() - .proxy("http://localhost:8080")? - .disable_ssl_verification(); let homeserver_url = Url::parse(&homeserver_url).expect("Couldn't parse the homeserver URL"); - let client = Client::new_with_config(homeserver_url, client_config).unwrap(); + let client = Client::new(homeserver_url).unwrap(); client .login(username, password, None, Some("rust-sdk")) diff --git a/matrix_sdk/examples/image_bot.rs b/matrix_sdk/examples/image_bot.rs index b23840c1..344495df 100644 --- a/matrix_sdk/examples/image_bot.rs +++ b/matrix_sdk/examples/image_bot.rs @@ -14,7 +14,7 @@ use matrix_sdk::{ room::message::{MessageEventContent, TextMessageEventContent}, SyncMessageEvent, }, - Client, ClientConfig, EventEmitter, RoomState, SyncSettings, + Client, EventEmitter, RoomState, SyncSettings, }; use url::Url; @@ -77,12 +77,8 @@ async fn login_and_sync( password: String, image: File, ) -> Result<(), matrix_sdk::Error> { - let client_config = ClientConfig::new() - .proxy("http://localhost:8080")? - .disable_ssl_verification(); - let homeserver_url = Url::parse(&homeserver_url).expect("Couldn't parse the homeserver URL"); - let client = Client::new_with_config(homeserver_url, client_config).unwrap(); + let client = Client::new(homeserver_url).unwrap(); client .login(&username, &password, None, Some("command bot")) diff --git a/matrix_sdk/examples/login.rs b/matrix_sdk/examples/login.rs index abe02890..37440ac2 100644 --- a/matrix_sdk/examples/login.rs +++ b/matrix_sdk/examples/login.rs @@ -7,7 +7,7 @@ use matrix_sdk::{ room::message::{MessageEventContent, TextMessageEventContent}, SyncMessageEvent, }, - Client, ClientConfig, EventEmitter, RoomState, SyncSettings, + Client, EventEmitter, RoomState, SyncSettings, }; struct EventCallback; @@ -41,11 +41,8 @@ async fn login( username: &str, password: &str, ) -> Result<(), matrix_sdk::Error> { - let client_config = ClientConfig::new() - .proxy("http://localhost:8080")? - .disable_ssl_verification(); let homeserver_url = Url::parse(&homeserver_url).expect("Couldn't parse the homeserver URL"); - let client = Client::new_with_config(homeserver_url, client_config).unwrap(); + let client = Client::new(homeserver_url).unwrap(); client.add_event_emitter(Box::new(EventCallback)).await;