client: Add support for rustls as the TLS backend
This commit is contained in:
parent
1129520290
commit
8ea4cf4862
@ -58,4 +58,23 @@ tasks:
|
||||
|
||||
popd
|
||||
|
||||
exit $(( $ruma_build_exit || $client_build_exit || $id_build_1_exit || $id_build_2_exit || $client_api_build_exit ))
|
||||
# Test non-default configurations of ruma-client
|
||||
pushd ruma-client
|
||||
|
||||
cargo check --no-default-features --quiet
|
||||
client_1_exit=$?
|
||||
|
||||
cargo check --no-default-features --features tls-rustls --quiet
|
||||
client_2_exit=$?
|
||||
|
||||
popd
|
||||
|
||||
exit $(( \
|
||||
$ruma_build_exit \
|
||||
|| $client_build_exit \
|
||||
|| $id_build_1_exit \
|
||||
|| $id_build_2_exit \
|
||||
|| $client_api_build_exit \
|
||||
|| $client_1_exit \
|
||||
|| $client_2_exit \
|
||||
))
|
||||
|
@ -39,6 +39,24 @@ tasks:
|
||||
|
||||
popd
|
||||
|
||||
exit $(( $test_exit || $id_test_1_exit || $id_test_2_exit || $client_api_exit ))
|
||||
# Test non-default configurations of ruma-client
|
||||
pushd ruma-client
|
||||
|
||||
cargo check --no-default-features --quiet
|
||||
client_1_exit=$?
|
||||
|
||||
cargo check --no-default-features --features tls-rustls --quiet
|
||||
client_2_exit=$?
|
||||
|
||||
popd
|
||||
|
||||
exit $(( \
|
||||
$test_exit \
|
||||
|| $id_test_1_exit \
|
||||
|| $id_test_2_exit \
|
||||
|| $client_api_exit \
|
||||
|| $client_1_exit \
|
||||
|| $client_2_exit \
|
||||
))
|
||||
# TODO: Add audit task once cargo-audit binary releases are available.
|
||||
# See https://github.com/RustSec/cargo-audit/issues/66
|
||||
|
@ -22,6 +22,7 @@ futures-util = "0.3.5"
|
||||
http = "0.2.1"
|
||||
hyper = "0.13.7"
|
||||
hyper-tls = { version = "0.4.3", optional = true }
|
||||
hyper-rustls = { version = "0.21.0", optional = true }
|
||||
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" }
|
||||
@ -39,4 +40,5 @@ tokio = { version = "0.2.22", features = ["macros"] }
|
||||
[features]
|
||||
default = ["tls-native"]
|
||||
tls-native = ["hyper-tls"]
|
||||
tls-rustls = ["hyper-rustls"]
|
||||
unstable-synapse-quirks = ["ruma-events/unstable-synapse-quirks"]
|
||||
|
13
ruma-client/build.rs
Normal file
13
ruma-client/build.rs
Normal file
@ -0,0 +1,13 @@
|
||||
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();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
@ -127,12 +127,15 @@ pub use self::{
|
||||
session::{Identification, Session},
|
||||
};
|
||||
|
||||
#[cfg(not(feature = "tls-native"))]
|
||||
#[cfg(not(any(feature = "tls-native", feature = "tls-rustls")))]
|
||||
type Connector = HttpConnector;
|
||||
|
||||
#[cfg(feature = "tls-native")]
|
||||
type Connector = hyper_tls::HttpsConnector<HttpConnector>;
|
||||
|
||||
#[cfg(feature = "tls-rustls")]
|
||||
type Connector = hyper_rustls::HttpsConnector<HttpConnector>;
|
||||
|
||||
/// A client for the Matrix client-server API.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Client(Arc<ClientData>);
|
||||
|
Loading…
x
Reference in New Issue
Block a user