Add anyhow and configurable TcpListener
- add anyhow to Cargo.toml - make the connection parameter (for the TcpListener) configurable
This commit is contained in:
Generated
+1
@@ -164,6 +164,7 @@ checksum = "135b12329e5e3ce057a9f972339ea52bc954fe1e9358ef27f95e89716fbc5424"
|
|||||||
name = "husk"
|
name = "husk"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
"bytes",
|
"bytes",
|
||||||
"indymilter",
|
"indymilter",
|
||||||
"log",
|
"log",
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ categories = ["cryptography", "email"]
|
|||||||
rust-version = "1.79"
|
rust-version = "1.79"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
anyhow = "1.0.100"
|
||||||
bytes = "1.10.1"
|
bytes = "1.10.1"
|
||||||
indymilter = "0.3.0"
|
indymilter = "0.3.0"
|
||||||
log = "0.4.27"
|
log = "0.4.27"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#
|
#
|
||||||
# Husk config file
|
# Husk config file
|
||||||
#
|
#
|
||||||
|
connection = "localhost:3000"
|
||||||
|
|
||||||
logfile_config = "./config/log4rs.yml"
|
logfile_config = "./config/log4rs.yml"
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use serde_derive::Deserialize;
|
|||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub struct HuskConfig {
|
pub struct HuskConfig {
|
||||||
|
pub connection: String,
|
||||||
logfile_config: Option<String>,
|
logfile_config: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -4,6 +4,7 @@
|
|||||||
// the actual daemon
|
// the actual daemon
|
||||||
//
|
//
|
||||||
|
|
||||||
|
use anyhow;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use tokio::signal;
|
use tokio::signal;
|
||||||
@@ -24,14 +25,15 @@ use indymilter::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::types::husk_context::HuskContext;
|
use crate::types::husk_context::HuskContext;
|
||||||
|
use crate::config::HuskConfig;
|
||||||
|
|
||||||
pub struct Daemon { }
|
pub struct Daemon { }
|
||||||
|
|
||||||
impl 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
|
.await
|
||||||
.expect(" opening milter socket");
|
.expect(" opening milter socket");
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@ async fn main() {
|
|||||||
|
|
||||||
log::info!("starting...");
|
log::info!("starting...");
|
||||||
|
|
||||||
match Daemon::run().await {
|
match Daemon::run(&husk_config).await {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
println!("exiting...");
|
println!("exiting...");
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user