mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-06-02 22:39:21 +02:00
Compare commits
4 Commits
1293e9a3eb
...
0298caf97a
Author | SHA1 | Date | |
---|---|---|---|
|
0298caf97a | ||
|
b648b4668b | ||
|
e53fa6c50c | ||
|
13be111de1 |
|
@ -41,7 +41,7 @@ variables:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- echo "Building docs to CI_DOC_TARGET=$CI_DOC_TARGET"
|
- echo "Building docs to CI_DOC_TARGET=$CI_DOC_TARGET"
|
||||||
- cargo +nightly doc --no-deps -Zrustdoc-map
|
- RUSTDOCFLAGS="--cfg docsrs" RUSTFLAGS="--cfg xmpprs_doc_build" cargo +nightly doc --no-deps -Zrustdoc-map --all-features
|
||||||
- apt install -y rsync openssh-client
|
- apt install -y rsync openssh-client
|
||||||
- mkdir -p $HOME/.ssh
|
- mkdir -p $HOME/.ssh
|
||||||
- echo -e "Host docs\n\tHostname docs.xmpp.rs\n\tPort 1312\n\tUser xmpp-rs\n\tStrictHostKeyChecking no" > $HOME/.ssh/config
|
- echo -e "Host docs\n\tHostname docs.xmpp.rs\n\tPort 1312\n\tUser xmpp-rs\n\tStrictHostKeyChecking no" > $HOME/.ssh/config
|
||||||
|
|
|
@ -26,3 +26,7 @@ sha-1 = { version = "0.10", optional = true }
|
||||||
sha2 = { version = "0.10", optional = true }
|
sha2 = { version = "0.10", optional = true }
|
||||||
hmac = { version = "0.12", optional = true }
|
hmac = { version = "0.12", optional = true }
|
||||||
pbkdf2 = { version = "0.12", default-features = false, optional = true }
|
pbkdf2 = { version = "0.12", default-features = false, optional = true }
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
all-features = true
|
||||||
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
|
@ -10,4 +10,5 @@ pub use self::anonymous::Anonymous;
|
||||||
pub use self::plain::Plain;
|
pub use self::plain::Plain;
|
||||||
|
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
pub use self::scram::Scram;
|
pub use self::scram::Scram;
|
||||||
|
|
|
@ -34,6 +34,7 @@ pub enum MechanismError {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
impl From<DeriveError> for MechanismError {
|
impl From<DeriveError> for MechanismError {
|
||||||
fn from(err: DeriveError) -> MechanismError {
|
fn from(err: DeriveError) -> MechanismError {
|
||||||
MechanismError::DeriveError(err)
|
MechanismError::DeriveError(err)
|
||||||
|
@ -41,6 +42,7 @@ impl From<DeriveError> for MechanismError {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
impl From<InvalidLength> for MechanismError {
|
impl From<InvalidLength> for MechanismError {
|
||||||
fn from(err: InvalidLength) -> MechanismError {
|
fn from(err: InvalidLength) -> MechanismError {
|
||||||
MechanismError::InvalidKeyLength(err)
|
MechanismError::InvalidKeyLength(err)
|
||||||
|
|
|
@ -2,6 +2,7 @@ use std::collections::HashMap;
|
||||||
use std::string::FromUtf8Error;
|
use std::string::FromUtf8Error;
|
||||||
|
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
pub mod scram;
|
pub mod scram;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
|
|
|
@ -5,6 +5,7 @@ use getrandom::Error as RngError;
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
/// An error while initializing the Rng.
|
/// An error while initializing the Rng.
|
||||||
RngError(RngError),
|
RngError(RngError),
|
||||||
/// An error in a SASL mechanism.
|
/// An error in a SASL mechanism.
|
||||||
|
@ -12,6 +13,7 @@ pub enum Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
impl From<RngError> for Error {
|
impl From<RngError> for Error {
|
||||||
fn from(err: RngError) -> Error {
|
fn from(err: RngError) -> Error {
|
||||||
Error::RngError(err)
|
Error::RngError(err)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
//#![deny(missing_docs)]
|
//#![deny(missing_docs)]
|
||||||
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
|
|
||||||
//! This crate provides a framework for SASL authentication and a few authentication mechanisms.
|
//! This crate provides a framework for SASL authentication and a few authentication mechanisms.
|
||||||
//!
|
//!
|
||||||
|
|
|
@ -23,6 +23,7 @@ pub struct Pbkdf2Sha1 {
|
||||||
|
|
||||||
impl Pbkdf2Sha1 {
|
impl Pbkdf2Sha1 {
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
pub fn derive(password: &str, salt: &[u8], iterations: u32) -> Result<Pbkdf2Sha1, DeriveError> {
|
pub fn derive(password: &str, salt: &[u8], iterations: u32) -> Result<Pbkdf2Sha1, DeriveError> {
|
||||||
use crate::common::scram::{ScramProvider, Sha1};
|
use crate::common::scram::{ScramProvider, Sha1};
|
||||||
use crate::common::Password;
|
use crate::common::Password;
|
||||||
|
@ -58,6 +59,7 @@ pub struct Pbkdf2Sha256 {
|
||||||
|
|
||||||
impl Pbkdf2Sha256 {
|
impl Pbkdf2Sha256 {
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
pub fn derive(
|
pub fn derive(
|
||||||
password: &str,
|
password: &str,
|
||||||
salt: &[u8],
|
salt: &[u8],
|
||||||
|
|
|
@ -5,7 +5,9 @@ mod plain;
|
||||||
mod scram;
|
mod scram;
|
||||||
|
|
||||||
#[cfg(feature = "anonymous")]
|
#[cfg(feature = "anonymous")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "anonymous")))]
|
||||||
pub use self::anonymous::Anonymous;
|
pub use self::anonymous::Anonymous;
|
||||||
pub use self::plain::Plain;
|
pub use self::plain::Plain;
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
pub use self::scram::Scram;
|
pub use self::scram::Scram;
|
||||||
|
|
|
@ -36,6 +36,7 @@ pub trait Validator<S: Secret> {
|
||||||
pub enum ProviderError {
|
pub enum ProviderError {
|
||||||
AuthenticationFailed,
|
AuthenticationFailed,
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
DeriveError(DeriveError),
|
DeriveError(DeriveError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,8 +66,10 @@ pub enum MechanismError {
|
||||||
|
|
||||||
CannotDecodeResponse,
|
CannotDecodeResponse,
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
InvalidKeyLength(hmac::digest::InvalidLength),
|
InvalidKeyLength(hmac::digest::InvalidLength),
|
||||||
#[cfg(any(feature = "scram", feature = "anonymous"))]
|
#[cfg(any(feature = "scram", feature = "anonymous"))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(any(feature = "scram", feature = "anonymous"))))]
|
||||||
RandomFailure(getrandom::Error),
|
RandomFailure(getrandom::Error),
|
||||||
NoProof,
|
NoProof,
|
||||||
CannotDecodeProof,
|
CannotDecodeProof,
|
||||||
|
@ -75,6 +78,7 @@ pub enum MechanismError {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
impl From<DeriveError> for ProviderError {
|
impl From<DeriveError> for ProviderError {
|
||||||
fn from(err: DeriveError) -> ProviderError {
|
fn from(err: DeriveError) -> ProviderError {
|
||||||
ProviderError::DeriveError(err)
|
ProviderError::DeriveError(err)
|
||||||
|
@ -100,6 +104,7 @@ impl From<ValidatorError> for MechanismError {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "scram")]
|
#[cfg(feature = "scram")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "scram")))]
|
||||||
impl From<hmac::digest::InvalidLength> for MechanismError {
|
impl From<hmac::digest::InvalidLength> for MechanismError {
|
||||||
fn from(err: hmac::digest::InvalidLength) -> MechanismError {
|
fn from(err: hmac::digest::InvalidLength) -> MechanismError {
|
||||||
MechanismError::InvalidKeyLength(err)
|
MechanismError::InvalidKeyLength(err)
|
||||||
|
@ -107,6 +112,7 @@ impl From<hmac::digest::InvalidLength> for MechanismError {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "scram", feature = "anonymous"))]
|
#[cfg(any(feature = "scram", feature = "anonymous"))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(any(feature = "scram", feature = "anonymous"))))]
|
||||||
impl From<getrandom::Error> for MechanismError {
|
impl From<getrandom::Error> for MechanismError {
|
||||||
fn from(err: getrandom::Error) -> MechanismError {
|
fn from(err: getrandom::Error) -> MechanismError {
|
||||||
MechanismError::RandomFailure(err)
|
MechanismError::RandomFailure(err)
|
||||||
|
|
|
@ -2,7 +2,12 @@
|
||||||
|
|
||||||
#![deny(unsafe_code, missing_docs, bare_trait_objects)]
|
#![deny(unsafe_code, missing_docs, bare_trait_objects)]
|
||||||
|
|
||||||
#[cfg(all(feature = "tls-native", feature = "tls-rust"))]
|
#[cfg(all(
|
||||||
|
not(xmpprs_doc_build),
|
||||||
|
not(doc),
|
||||||
|
feature = "tls-native",
|
||||||
|
feature = "tls-rust"
|
||||||
|
))]
|
||||||
compile_error!("Both tls-native and tls-rust features can't be enabled at the same time.");
|
compile_error!("Both tls-native and tls-rust features can't be enabled at the same time.");
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
|
|
|
@ -114,7 +114,7 @@ impl ServerConnector for ServerConfig {
|
||||||
async fn get_tls_stream<S: AsyncRead + AsyncWrite + Unpin>(
|
async fn get_tls_stream<S: AsyncRead + AsyncWrite + Unpin>(
|
||||||
xmpp_stream: XMPPStream<S>,
|
xmpp_stream: XMPPStream<S>,
|
||||||
) -> Result<TlsStream<S>, Error> {
|
) -> Result<TlsStream<S>, Error> {
|
||||||
let domain = xmpp_stream.jid.domain_str().to_owned();
|
let domain = xmpp_stream.jid.domain().to_owned();
|
||||||
let stream = xmpp_stream.into_inner();
|
let stream = xmpp_stream.into_inner();
|
||||||
let tls_stream = TlsConnector::from(NativeTlsConnector::builder().build().unwrap())
|
let tls_stream = TlsConnector::from(NativeTlsConnector::builder().build().unwrap())
|
||||||
.connect(&domain, stream)
|
.connect(&domain, stream)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user