|
|
|
@ -13,6 +13,7 @@ use crate::{
|
|
|
|
|
use anyhow::{bail, Result};
|
|
|
|
|
use data_encoding::BASE64;
|
|
|
|
|
use log::{debug, error, trace};
|
|
|
|
|
use reqwest::Client;
|
|
|
|
|
use ring::digest::{Algorithm, Context as DigestContext, SHA256, SHA512};
|
|
|
|
|
use serde::Deserialize;
|
|
|
|
|
use std::{
|
|
|
|
@ -31,6 +32,7 @@ use trust_dns_resolver::{
|
|
|
|
|
|
|
|
|
|
lazy_static::lazy_static! {
|
|
|
|
|
static ref RESOLVER: TokioAsyncResolver = make_resolver();
|
|
|
|
|
static ref HTTPS_CLIENT: Client = make_https_client();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn make_resolver() -> TokioAsyncResolver {
|
|
|
|
@ -39,6 +41,15 @@ fn make_resolver() -> TokioAsyncResolver {
|
|
|
|
|
TokioAsyncResolver::tokio(config, options).unwrap()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn make_https_client() -> Client {
|
|
|
|
|
// todo: configure our root certs here
|
|
|
|
|
Client::builder().https_only(true).build().expect("failed to make https client?")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async fn https_get<T: reqwest::IntoUrl>(url: T) -> reqwest::Result<reqwest::Response> {
|
|
|
|
|
HTTPS_CLIENT.get(url).send().await
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
|
|
|
enum XmppConnectionType {
|
|
|
|
|
#[cfg(feature = "tls")]
|
|
|
|
@ -706,11 +717,6 @@ async fn collect_host_meta_xml(ret: &mut Vec<XmppConnection>, domain: &str, is_c
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async fn https_get<T: reqwest::IntoUrl>(url: T) -> reqwest::Result<reqwest::Response> {
|
|
|
|
|
// todo: resolve URL with our resolver
|
|
|
|
|
reqwest::Client::builder().https_only(true).build()?.get(url).send().await
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// https://datatracker.ietf.org/doc/html/rfc7711
|
|
|
|
|
// https://www.iana.org/assignments/posh-service-names/posh-service-names.xhtml
|
|
|
|
|
async fn collect_posh(domain: &str) -> Result<Posh> {
|
|
|
|
|