tokio-xmpp: simplify examples by requiring specific TLS features
This commit is contained in:
parent
fc8b581593
commit
e3a4aae42d
6 changed files with 4 additions and 74 deletions
|
|
@ -44,15 +44,15 @@ tokio-xmpp = { path = ".", default-features = false, features = ["rustls-native-
|
|||
|
||||
[[example]]
|
||||
name = "contact_addr"
|
||||
required-features = ["starttls"]
|
||||
required-features = ["starttls", "aws_lc_rs"]
|
||||
|
||||
[[example]]
|
||||
name = "download_avatars"
|
||||
required-features = ["starttls"]
|
||||
required-features = ["starttls", "aws_lc_rs"]
|
||||
|
||||
[[example]]
|
||||
name = "echo_bot"
|
||||
required-features = ["starttls"]
|
||||
required-features = ["starttls", "aws_lc_rs"]
|
||||
|
||||
[[example]]
|
||||
name = "echo_component"
|
||||
|
|
@ -60,7 +60,7 @@ required-features = ["starttls", "insecure-tcp"]
|
|||
|
||||
[[example]]
|
||||
name = "echo_server"
|
||||
required-features = ["starttls"]
|
||||
required-features = ["starttls", "aws_lc_rs"]
|
||||
|
||||
[[example]]
|
||||
name = "keep_connection"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ use futures::stream::StreamExt;
|
|||
use std::env::args;
|
||||
use std::process::exit;
|
||||
use std::str::FromStr;
|
||||
#[cfg(feature = "rustls-any-backend")]
|
||||
use tokio_xmpp::rustls;
|
||||
use tokio_xmpp::{Client, IqRequest, IqResponse};
|
||||
use xmpp_parsers::{
|
||||
|
|
@ -12,26 +11,14 @@ use xmpp_parsers::{
|
|||
server_info::ServerInfo,
|
||||
};
|
||||
|
||||
#[cfg(all(
|
||||
feature = "rustls-any-backend",
|
||||
not(any(feature = "aws_lc_rs", feature = "ring"))
|
||||
))]
|
||||
compile_error!("using rustls (e.g. via the ktls feature) needs an enabled rustls backend feature (either aws_lc_rs or ring).");
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
env_logger::init();
|
||||
|
||||
#[cfg(all(feature = "aws_lc_rs", not(feature = "ring")))]
|
||||
rustls::crypto::aws_lc_rs::default_provider()
|
||||
.install_default()
|
||||
.expect("failed to install rustls crypto provider");
|
||||
|
||||
#[cfg(all(feature = "ring"))]
|
||||
rustls::crypto::ring::default_provider()
|
||||
.install_default()
|
||||
.expect("failed to install rustls crypto provider");
|
||||
|
||||
let args: Vec<String> = args().collect();
|
||||
if args.len() != 4 {
|
||||
println!("Usage: {} <jid> <password> <target>", args[0]);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ use std::fs::{create_dir_all, File};
|
|||
use std::io::{self, Write};
|
||||
use std::process::exit;
|
||||
use std::str::FromStr;
|
||||
#[cfg(feature = "rustls-any-backend")]
|
||||
use tokio_xmpp::rustls;
|
||||
use tokio_xmpp::{Client, Stanza};
|
||||
use xmpp_parsers::{
|
||||
|
|
@ -24,26 +23,14 @@ use xmpp_parsers::{
|
|||
stanza_error::{DefinedCondition, ErrorType, StanzaError},
|
||||
};
|
||||
|
||||
#[cfg(all(
|
||||
feature = "rustls-any-backend",
|
||||
not(any(feature = "aws_lc_rs", feature = "ring"))
|
||||
))]
|
||||
compile_error!("using rustls (e.g. via the ktls feature) needs an enabled rustls backend feature (either aws_lc_rs or ring).");
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
env_logger::init();
|
||||
|
||||
#[cfg(all(feature = "aws_lc_rs", not(feature = "ring")))]
|
||||
rustls::crypto::aws_lc_rs::default_provider()
|
||||
.install_default()
|
||||
.expect("failed to install rustls crypto provider");
|
||||
|
||||
#[cfg(all(feature = "ring"))]
|
||||
rustls::crypto::ring::default_provider()
|
||||
.install_default()
|
||||
.expect("failed to install rustls crypto provider");
|
||||
|
||||
let args: Vec<String> = args().collect();
|
||||
if args.len() != 3 {
|
||||
println!("Usage: {} <jid> <password>", args[0]);
|
||||
|
|
|
|||
|
|
@ -2,33 +2,20 @@ use futures::stream::StreamExt;
|
|||
use std::env::args;
|
||||
use std::process::exit;
|
||||
use std::str::FromStr;
|
||||
#[cfg(feature = "rustls-any-backend")]
|
||||
use tokio_xmpp::rustls;
|
||||
use tokio_xmpp::Client;
|
||||
use xmpp_parsers::jid::{BareJid, Jid};
|
||||
use xmpp_parsers::message::{Lang, Message, MessageType};
|
||||
use xmpp_parsers::presence::{Presence, Show as PresenceShow, Type as PresenceType};
|
||||
|
||||
#[cfg(all(
|
||||
feature = "rustls-any-backend",
|
||||
not(any(feature = "aws_lc_rs", feature = "ring"))
|
||||
))]
|
||||
compile_error!("using rustls (e.g. via the ktls feature) needs an enabled rustls backend feature (either aws_lc_rs or ring).");
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
env_logger::init();
|
||||
|
||||
#[cfg(all(feature = "aws_lc_rs", not(feature = "ring")))]
|
||||
rustls::crypto::aws_lc_rs::default_provider()
|
||||
.install_default()
|
||||
.expect("failed to install rustls crypto provider");
|
||||
|
||||
#[cfg(all(feature = "ring"))]
|
||||
rustls::crypto::ring::default_provider()
|
||||
.install_default()
|
||||
.expect("failed to install rustls crypto provider");
|
||||
|
||||
let args: Vec<String> = args().collect();
|
||||
if args.len() != 3 {
|
||||
println!("Usage: {} <jid> <password>", args[0]);
|
||||
|
|
|
|||
|
|
@ -6,30 +6,12 @@ use xmpp_parsers::jid::Jid;
|
|||
use xmpp_parsers::message::{Lang, Message, MessageType};
|
||||
use xmpp_parsers::presence::{Presence, Show as PresenceShow, Type as PresenceType};
|
||||
|
||||
#[cfg(feature = "rustls-any-backend")]
|
||||
use tokio_xmpp::rustls;
|
||||
use tokio_xmpp::{connect::DnsConfig, Component};
|
||||
|
||||
#[cfg(all(
|
||||
feature = "rustls-any-backend",
|
||||
not(any(feature = "aws_lc_rs", feature = "ring"))
|
||||
))]
|
||||
compile_error!("using rustls (e.g. via the ktls feature) needs an enabled rustls backend feature (either aws_lc_rs or ring).");
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
env_logger::init();
|
||||
|
||||
#[cfg(all(feature = "aws_lc_rs", not(feature = "ring")))]
|
||||
rustls::crypto::aws_lc_rs::default_provider()
|
||||
.install_default()
|
||||
.expect("failed to install rustls crypto provider");
|
||||
|
||||
#[cfg(all(feature = "ring"))]
|
||||
rustls::crypto::ring::default_provider()
|
||||
.install_default()
|
||||
.expect("failed to install rustls crypto provider");
|
||||
|
||||
let args: Vec<String> = args().collect();
|
||||
if args.len() < 3 || args.len() > 4 {
|
||||
println!("Usage: {} <jid> <password> [server:port]", args[0]);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use futures::{SinkExt, StreamExt};
|
||||
use tokio::{self, io, net::TcpSocket};
|
||||
|
||||
#[cfg(feature = "rustls-any-backend")]
|
||||
use tokio_xmpp::rustls;
|
||||
use tokio_xmpp::{
|
||||
minidom::Element,
|
||||
|
|
@ -9,24 +8,12 @@ use tokio_xmpp::{
|
|||
xmlstream::{accept_stream, StreamHeader, Timeouts},
|
||||
};
|
||||
|
||||
#[cfg(all(
|
||||
feature = "rustls-any-backend",
|
||||
not(any(feature = "aws_lc_rs", feature = "ring"))
|
||||
))]
|
||||
compile_error!("using rustls (e.g. via the ktls feature) needs an enabled rustls backend feature (either aws_lc_rs or ring).");
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), io::Error> {
|
||||
#[cfg(all(feature = "aws_lc_rs", not(feature = "ring")))]
|
||||
rustls::crypto::aws_lc_rs::default_provider()
|
||||
.install_default()
|
||||
.expect("failed to install rustls crypto provider");
|
||||
|
||||
#[cfg(all(feature = "ring"))]
|
||||
rustls::crypto::ring::default_provider()
|
||||
.install_default()
|
||||
.expect("failed to install rustls crypto provider");
|
||||
|
||||
// TCP socket
|
||||
let address = "127.0.0.1:5222".parse().unwrap();
|
||||
let socket = TcpSocket::new_v4()?;
|
||||
|
|
|
|||
Loading…
Reference in a new issue