use async_trait::async_trait;
use hickory_resolver::TokioAsyncResolver;
use std::sync::Arc;
use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender};
use crate::{Config, Finding, Target};
pub struct ScanInput {
pub seed: String,
pub target_rx: tokio::sync::Mutex<UnboundedReceiver<Target>>,
pub live_tx: UnboundedSender<Finding>,
pub target_tx: UnboundedSender<Target>,
pub resolver: Arc<TokioAsyncResolver>,
}
impl ScanInput {
pub fn emit(&self, f: Finding) {
let _ = self.live_tx.send(f);
}
pub fn emit_target(&self, t: Target) {
let _ = self.target_tx.send(t);
}
}
#[async_trait]
pub trait Scanner: Send + Sync {
fn name(&self) -> &'static str;
fn tags(&self) -> &[&'static str];
fn accepts(&self, target: &Target) -> bool;
async fn run(&self, input: ScanInput, config: &Config) -> anyhow::Result<()>;
}