Update hyper / tokio
(and raise the minimum version for other dependencies)
This commit is contained in:
parent
2686a3ecc0
commit
4ffec95b01
@ -64,9 +64,12 @@ tasks:
|
||||
cargo check --no-default-features --quiet
|
||||
client_1_exit=$?
|
||||
|
||||
cargo check --no-default-features --features tls-rustls --quiet
|
||||
cargo check --no-default-features --features http1,http2,tls-rustls-native-roots --quiet
|
||||
client_2_exit=$?
|
||||
|
||||
cargo check --no-default-features --features http1,http2,tls-rustls-webpki-roots --quiet
|
||||
client_3_exit=$?
|
||||
|
||||
popd
|
||||
|
||||
exit $(( \
|
||||
@ -77,4 +80,5 @@ tasks:
|
||||
|| $client_api_build_exit \
|
||||
|| $client_1_exit \
|
||||
|| $client_2_exit \
|
||||
|| $client_3_exit \
|
||||
))
|
||||
|
@ -45,9 +45,12 @@ tasks:
|
||||
cargo check --no-default-features --quiet
|
||||
client_1_exit=$?
|
||||
|
||||
cargo check --no-default-features --features tls-rustls --quiet
|
||||
cargo check --no-default-features --features http1,http2,tls-rustls-native-roots --quiet
|
||||
client_2_exit=$?
|
||||
|
||||
cargo check --no-default-features --features http1,http2,tls-rustls-webpki-roots --quiet
|
||||
client_3_exit=$?
|
||||
|
||||
popd
|
||||
|
||||
exit $(( \
|
||||
@ -57,6 +60,7 @@ tasks:
|
||||
|| $client_api_exit \
|
||||
|| $client_1_exit \
|
||||
|| $client_2_exit \
|
||||
|| $client_3_exit \
|
||||
))
|
||||
# TODO: Add audit task once cargo-audit binary releases are available.
|
||||
# See https://github.com/RustSec/cargo-audit/issues/66
|
||||
|
@ -16,13 +16,13 @@ repository = "https://github.com/ruma/ruma"
|
||||
version = "0.4.0"
|
||||
|
||||
[dependencies]
|
||||
assign = "1.1.0"
|
||||
assign = "1.1.1"
|
||||
futures-core = "0.3.8"
|
||||
futures-util = "0.3.8"
|
||||
http = "0.2.2"
|
||||
hyper = "0.13.9"
|
||||
hyper-tls = { version = "0.4.3", optional = true }
|
||||
hyper-rustls = { version = "0.21.0", optional = true }
|
||||
hyper = { version = "0.14.2", features = ["client", "tcp"] }
|
||||
hyper-tls = { version = "0.5.0", optional = true }
|
||||
hyper-rustls = { version = "0.22.1", optional = true, default-features = false }
|
||||
ruma-api = { version = "=0.17.0-alpha.1", path = "../ruma-api" }
|
||||
ruma-client-api = { version = "0.10.0-alpha.1", path = "../ruma-client-api" }
|
||||
ruma-common = { version = "0.2.0", path = "../ruma-common" }
|
||||
@ -30,15 +30,24 @@ ruma-events = { version = "=0.22.0-alpha.1", path = "../ruma-events" }
|
||||
ruma-identifiers = { version = "0.17.4", path = "../ruma-identifiers" }
|
||||
ruma-serde = { version = "0.2.3", path = "../ruma-serde" }
|
||||
serde = { version = "1.0.118", features = ["derive"] }
|
||||
serde_json = "1.0.60"
|
||||
serde_json = "1.0.61"
|
||||
|
||||
[dev-dependencies]
|
||||
anyhow = "1.0.36"
|
||||
ruma = { version = "0.0.1", path = "../ruma", features = ["client-api"] }
|
||||
tokio = { version = "0.2.24", features = ["macros"] }
|
||||
tokio = { version = "1.0.1", features = ["macros", "rt"] }
|
||||
|
||||
[features]
|
||||
default = ["tls-native"]
|
||||
tls-native = ["hyper-tls"]
|
||||
tls-rustls = ["hyper-rustls"]
|
||||
default = ["http1", "http2", "tls-native"]
|
||||
|
||||
http1 = ["hyper/http1"]
|
||||
http2 = ["hyper/http2"]
|
||||
tls-native = ["hyper-tls", "_tls"]
|
||||
tls-rustls-native-roots = ["hyper-rustls", "hyper-rustls/native-tokio", "_tls-rustls"]
|
||||
tls-rustls-webpki-roots = ["hyper-rustls", "hyper-rustls/webpki-tokio", "_tls-rustls"]
|
||||
|
||||
unstable-synapse-quirks = ["ruma-events/unstable-synapse-quirks"]
|
||||
|
||||
# Internal, not meant to be used directly
|
||||
_tls = []
|
||||
_tls-rustls = ["_tls"]
|
||||
|
@ -1,13 +1,19 @@
|
||||
use std::{env, process};
|
||||
|
||||
fn main() {
|
||||
let tls_native_active = env::var_os("CARGO_FEATURE_TLS_NATIVE").is_some();
|
||||
let tls_rustls_active = env::var_os("CARGO_FEATURE_TLS_RUSTLS").is_some();
|
||||
let tls_features = [
|
||||
("tls-native", env::var_os("CARGO_FEATURE_TLS_NATIVE").is_some()),
|
||||
("tls-rustls-native-roots", env::var_os("CARGO_FEATURE_TLS_RUSTLS_NATIVE_ROOTS").is_some()),
|
||||
("tls-rustls-webpki-roots", env::var_os("CARGO_FEATURE_TLS_RUSTLS_WEBPKI_ROOTS").is_some()),
|
||||
];
|
||||
|
||||
if tls_features.iter().filter(|(_, a)| *a).count() > 1 {
|
||||
eprintln!("error: Only one tls features can be enabled.");
|
||||
|
||||
for (f, a) in &tls_features {
|
||||
eprintln!(" {}: {}", f, if *a { "enabled" } else { "disabled" });
|
||||
}
|
||||
|
||||
if tls_native_active && tls_rustls_active {
|
||||
eprintln!(
|
||||
"error: The tls-native and tls-rustls features can't be activated at the same time."
|
||||
);
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ async fn hello_world(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
let (homeserver_url, username, password, room) =
|
||||
match (env::args().nth(1), env::args().nth(2), env::args().nth(3), env::args().nth(4)) {
|
||||
|
@ -57,7 +57,7 @@ async fn log_messages(homeserver_url: Uri, username: &str, password: &str) -> an
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
let (homeserver_url, username, password) =
|
||||
match (env::args().nth(1), env::args().nth(2), env::args().nth(3)) {
|
||||
|
@ -128,15 +128,31 @@ pub use self::{
|
||||
session::{Identification, Session},
|
||||
};
|
||||
|
||||
#[cfg(not(any(feature = "tls-native", feature = "tls-rustls")))]
|
||||
#[cfg(not(feature = "_tls"))]
|
||||
type Connector = HttpConnector;
|
||||
|
||||
#[cfg(feature = "tls-native")]
|
||||
type Connector = hyper_tls::HttpsConnector<HttpConnector>;
|
||||
|
||||
#[cfg(feature = "tls-rustls")]
|
||||
#[cfg(feature = "_tls-rustls")]
|
||||
type Connector = hyper_rustls::HttpsConnector<HttpConnector>;
|
||||
|
||||
fn create_connector() -> Connector {
|
||||
#[cfg(not(feature = "_tls"))]
|
||||
let connector = HttpConnector;
|
||||
|
||||
#[cfg(feature = "tls-native")]
|
||||
let connector = hyper_tls::HttpsConnector::new();
|
||||
|
||||
#[cfg(feature = "tls-rustls-native-roots")]
|
||||
let connector = hyper_rustls::HttpsConnector::with_native_roots();
|
||||
|
||||
#[cfg(feature = "tls-rustls-webpki-roots")]
|
||||
let connector = hyper_rustls::HttpsConnector::with_webpki_roots();
|
||||
|
||||
connector
|
||||
}
|
||||
|
||||
/// A client for the Matrix client-server API.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Client(Arc<ClientData>);
|
||||
@ -159,7 +175,7 @@ impl Client {
|
||||
pub fn new(homeserver_url: Uri, session: Option<Session>) -> Self {
|
||||
Self(Arc::new(ClientData {
|
||||
homeserver_url,
|
||||
hyper: HyperClient::builder().build(Connector::new()),
|
||||
hyper: HyperClient::builder().build(create_connector()),
|
||||
session: Mutex::new(session),
|
||||
}))
|
||||
}
|
||||
@ -174,7 +190,7 @@ impl Client {
|
||||
) -> Self {
|
||||
Self(Arc::new(ClientData {
|
||||
homeserver_url,
|
||||
hyper: client_builder.build(Connector::new()),
|
||||
hyper: client_builder.build(create_connector()),
|
||||
session: Mutex::new(session),
|
||||
}))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user