refactor error types

This commit is contained in:
Ferdinand Schober
2024-06-30 19:35:34 +02:00
parent 9cbe1ed8d8
commit 2ac193a5b2
7 changed files with 71 additions and 59 deletions

View File

@@ -8,7 +8,7 @@ use tokio::signal;
use crate::{
client::{ClientConfig, ClientHandle, ClientManager, ClientState},
config::{CaptureBackend, Config},
config::{CaptureBackend, Config, EmulationBackend},
dns,
frontend::{FrontendListener, FrontendRequest},
server::capture_task::CaptureEvent,
@@ -77,7 +77,11 @@ impl Server {
}
}
pub async fn run(&self, backend: Option<CaptureBackend>) -> anyhow::Result<()> {
pub async fn run(
&self,
capture_backend: Option<CaptureBackend>,
emulation_backend: Option<EmulationBackend>,
) -> anyhow::Result<()> {
// create frontend communication adapter
let frontend = match FrontendListener::new().await {
Some(f) => f?,
@@ -97,7 +101,7 @@ impl Server {
// input capture
let (mut capture_task, capture_channel) = capture_task::new(
backend,
capture_backend,
self.clone(),
sender_tx.clone(),
timer_tx.clone(),
@@ -106,12 +110,13 @@ impl Server {
// input emulation
let (mut emulation_task, emulate_channel) = emulation_task::new(
emulation_backend,
self.clone(),
receiver_rx,
sender_tx.clone(),
capture_channel.clone(),
timer_tx,
);
)?;
// create dns resolver
let resolver = dns::DnsResolver::new().await?;