mirror of
https://github.com/aljazceru/pkdns.git
synced 2025-12-17 05:54:21 +01:00
formating
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use std::sync::{Arc, Mutex};
|
||||
use anyhow::anyhow;
|
||||
|
||||
use crate::{packet_lookup::resolve_query, pkarr_cache::PkarrPacketTtlCache};
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user