add DnsClient arg to file_sscv init(), update main.rs example

This commit is contained in:
DarkCat09 2024-08-20 10:52:24 +04:00
parent 9806eb6a02
commit 4314df372b
Signed by: DarkCat09
GPG key ID: BD3CE9B65916CD82
2 changed files with 92 additions and 31 deletions

View file

@ -15,15 +15,21 @@ use crate::{
LibError,
};
#[cfg(feature = "hickory")]
use crate::dns::DnsClient;
pub struct FileBasedCertVerifier {
fd: Mutex<std::os::fd::OwnedFd>,
map: DashMap<String, SelfsignedCert>,
#[cfg(feature = "hickory")]
dns: Option<crate::dns::DnsClient>,
dns: Option<DnsClient>,
}
impl FileBasedCertVerifier {
pub async fn init(path: impl AsRef<Path>) -> Result<Self, LibError> {
pub async fn init(
path: impl AsRef<Path>,
#[cfg(feature = "hickory")] dns: Option<DnsClient>,
) -> Result<Self, LibError> {
let map = DashMap::new();
if tokio::fs::try_exists(&path).await? {
@ -97,7 +103,7 @@ impl FileBasedCertVerifier {
fd,
map,
#[cfg(feature = "hickory")]
dns: None,
dns,
})
}
}