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.
master
Damir Jelić 2021-01-22 10:01:21 +01:00
parent cf07fc8e8e
commit 9cd217fc5d
6 changed files with 11 additions and 35 deletions

View File

@ -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

View File

@ -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"))

View File

@ -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"))

View File

@ -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<Client, 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("rust-sdk"))

View File

@ -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"))

View File

@ -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;