formating

This commit is contained in:
Severin Buhler
2024-02-07 19:39:01 +01:00
parent c7a6c23d48
commit 2f4299ba4d
4 changed files with 5 additions and 12 deletions

View File

@@ -23,7 +23,7 @@ impl MyHandler {
}
#[async_trait]
impl CustomHandler for MyHandler {
async fn lookup(&mut self,query: &Vec<u8>, _socket: DnsSocket) -> Result<Vec<u8>, CustomHandlerError> {
async fn lookup(&mut self, query: &Vec<u8>, _socket: DnsSocket) -> Result<Vec<u8>, CustomHandlerError> {
let result = self.pkarr.resolve(query).await;
match result {

View File

@@ -4,7 +4,6 @@ use pkarr::{dns::Packet, PublicKey};
use retainer::Cache;
use tokio::{sync::Mutex, task::JoinHandle};
/**
* Pkarr record ttl cache
*/
@@ -12,20 +11,18 @@ use tokio::{sync::Mutex, task::JoinHandle};
pub struct PkarrPacketTtlCache {
cache: Arc<Cache<String, Vec<u8>>>,
max_cache_ttl: u64,
monitor: Arc<Mutex<JoinHandle<()>>>
monitor: Arc<Mutex<JoinHandle<()>>>,
}
impl PkarrPacketTtlCache {
pub async fn new(max_cache_ttl: u64) -> Self {
let cache: Arc<Cache<String, Vec<u8>>> = Arc::new(Cache::new());
let monitor = tokio::spawn(async move {
cache.monitor(4, 0.25, Duration::from_secs(3)).await
});
let monitor = tokio::spawn(async move { cache.monitor(4, 0.25, Duration::from_secs(3)).await });
let monitor = Arc::new(Mutex::new(monitor));
PkarrPacketTtlCache {
cache: Arc::new(Cache::new()),
max_cache_ttl,
monitor
monitor,
}
}

View File

@@ -1,4 +1,3 @@
use std::sync::{Arc, Mutex};
use anyhow::anyhow;
use crate::{packet_lookup::resolve_query, pkarr_cache::PkarrPacketTtlCache};

View File

@@ -1,10 +1,7 @@
use crate::pkarr_resolver::PkarrResolver;
use anyhow::anyhow;
use pkarr::dns::{Name, Packet};
use pknames_core::resolve::resolve_standalone;
use anyhow::anyhow;
#[derive(Clone)]
pub struct PknamesResolver {