Add anyhow and configurable TcpListener
- add anyhow to Cargo.toml - make the connection parameter (for the TcpListener) configurable
This commit is contained in:
@@ -7,6 +7,7 @@ use serde_derive::Deserialize;
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct HuskConfig {
|
||||
pub connection: String,
|
||||
logfile_config: Option<String>,
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -4,6 +4,7 @@
|
||||
// the actual daemon
|
||||
//
|
||||
|
||||
use anyhow;
|
||||
use bytes::Bytes;
|
||||
use std::ffi::CString;
|
||||
use tokio::signal;
|
||||
@@ -24,14 +25,15 @@ use indymilter::{
|
||||
};
|
||||
|
||||
use crate::types::husk_context::HuskContext;
|
||||
use crate::config::HuskConfig;
|
||||
|
||||
pub struct Daemon { }
|
||||
|
||||
impl Daemon {
|
||||
|
||||
pub async fn run() -> Result<(), ()> {
|
||||
pub async fn run(config: &HuskConfig) -> anyhow::Result<()> {
|
||||
|
||||
let listener = TcpListener::bind("localhost:3000")
|
||||
let listener = TcpListener::bind(&config.connection)
|
||||
.await
|
||||
.expect(" opening milter socket");
|
||||
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ async fn main() {
|
||||
|
||||
log::info!("starting...");
|
||||
|
||||
match Daemon::run().await {
|
||||
match Daemon::run(&husk_config).await {
|
||||
Ok(_) => {
|
||||
println!("exiting...");
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user