Move crypto.rs into common
- Refactor code and move crypto.rs into the common subdirectory. - Fixed comments
This commit is contained in:
@@ -104,6 +104,13 @@ pub struct IntroducerRemoveCommand {
|
||||
help = "Certificate to be removed as introducer."
|
||||
)]
|
||||
pub cert: String,
|
||||
|
||||
#[clap(
|
||||
long = "demote",
|
||||
help = "Remove introducing capabilities, but keep certificate authenticated.",
|
||||
default_value_t = false,
|
||||
)]
|
||||
pub demote: bool,
|
||||
}
|
||||
|
||||
// Local subcommands
|
||||
|
||||
@@ -3,7 +3,7 @@ use anyhow::Result;
|
||||
use crate::cli::cli_args::{IntroducerCommand, IntroducerSubcommand};
|
||||
use crate::config::HuskConfigContainer;
|
||||
use crate::types::husk_context::HuskContext;
|
||||
use crate::crypto;
|
||||
use crate::common::crypto;
|
||||
|
||||
pub mod add;
|
||||
pub mod remove;
|
||||
@@ -14,7 +14,7 @@ pub async fn dispatch(cmd: IntroducerCommand, config: HuskConfigContainer) -> Re
|
||||
add::dispatch(add_cmd, config).await?;
|
||||
},
|
||||
IntroducerSubcommand::Remove(rm_cmd) => {
|
||||
remove::dispatch(rm_cmd, &config).await?;
|
||||
remove::dispatch(rm_cmd, config).await?;
|
||||
},
|
||||
IntroducerSubcommand::List => {
|
||||
println!("list");
|
||||
|
||||
@@ -1,11 +1,30 @@
|
||||
use anyhow::Result;
|
||||
|
||||
use crate::cli::cli_args::IntroducerRemoveCommand;
|
||||
use crate::config::HuskConfigContainer;
|
||||
use sequoia_openpgp::{Fingerprint, KeyHandle};
|
||||
use sequoia_cert_store::Store;
|
||||
|
||||
pub async fn dispatch(cmd: IntroducerRemoveCommand, _config: &HuskConfigContainer) -> Result<()> {
|
||||
use crate::cli::cli_args::IntroducerRemoveCommand;
|
||||
use crate::commands::CommandError;
|
||||
use crate::config::HuskConfigContainer;
|
||||
use crate::types::husk_context::HuskContext;
|
||||
use crate::types::introducer::Introducer;
|
||||
|
||||
pub async fn dispatch(cmd: IntroducerRemoveCommand, config: HuskConfigContainer) -> Result<()> {
|
||||
println!("remove");
|
||||
println!(" {:?}", cmd.cert);
|
||||
println!(" {:?}", cmd.demote);
|
||||
|
||||
let context = HuskContext::new(&config.into())?;
|
||||
let policy = &context.policy;
|
||||
let cert_store = &context.cert_store;
|
||||
|
||||
// Get the certificate
|
||||
let fpr = Fingerprint::from_hex(&cmd.cert)?;
|
||||
let certs = cert_store.lookup_by_cert(&KeyHandle::try_from(&fpr)?)
|
||||
.map_err(|_| CommandError::CertNotFound(fpr.clone()))?;
|
||||
|
||||
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
//
|
||||
// Husk milter
|
||||
//
|
||||
// cryptographic functions
|
||||
//
|
||||
//! cryptographic functions
|
||||
|
||||
use std::io::Write;
|
||||
use std::sync::Arc;
|
||||
@@ -1 +1,2 @@
|
||||
pub mod crypto;
|
||||
pub mod escape;
|
||||
|
||||
+2
-6
@@ -1,8 +1,4 @@
|
||||
//
|
||||
// Husk milter
|
||||
//
|
||||
// the actual daemon
|
||||
//
|
||||
//! the actual daemon
|
||||
|
||||
use anyhow;
|
||||
use bytes::Bytes;
|
||||
@@ -25,7 +21,7 @@ use indymilter::{
|
||||
use crate::types::husk_context::HuskContext;
|
||||
use crate::config::{HuskConfig, HuskConfigContainer};
|
||||
use crate::mail;
|
||||
use crate::crypto;
|
||||
use crate::common::crypto;
|
||||
use crate::types::mail_context::ProtectionPossibility;
|
||||
|
||||
pub struct Daemon { }
|
||||
|
||||
@@ -14,7 +14,6 @@ pub mod commands;
|
||||
pub mod config;
|
||||
use config::{HuskConfig, HuskConfigContainer};
|
||||
pub mod types;
|
||||
pub mod crypto;
|
||||
pub mod mail;
|
||||
pub mod daemon;
|
||||
use daemon::Daemon;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//
|
||||
// Some defaults
|
||||
//
|
||||
//! Defaults
|
||||
|
||||
pub const CONFIG_FILE_LOCATION: &'static str = "/etc/husk/config.toml";
|
||||
|
||||
+1
-5
@@ -1,8 +1,4 @@
|
||||
//
|
||||
// Husk milter
|
||||
//
|
||||
// Error typ
|
||||
//
|
||||
//! Error typ
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
//
|
||||
// Husk milter
|
||||
//
|
||||
// Context
|
||||
//
|
||||
//! HuskContext
|
||||
//!
|
||||
//! Keep data in HuskContext while processing a mail.
|
||||
|
||||
use anyhow;
|
||||
use sequoia_openpgp::policy::StandardPolicy;
|
||||
@@ -11,7 +9,8 @@ use sequoia_openpgp::Cert;
|
||||
use sequoia_cert_store::CertStore;
|
||||
use sequoia_directories::Home;
|
||||
|
||||
use crate::{config::HuskConfig, crypto};
|
||||
use crate::config::HuskConfig;
|
||||
use crate::common::crypto;
|
||||
use crate::types::mail_context::MailContext;
|
||||
|
||||
use crate::types::introducer::Introducer;
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
//
|
||||
// husk-milter
|
||||
//
|
||||
// introducers
|
||||
//
|
||||
//! introducers
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::collections::HashSet;
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
//
|
||||
// Husk milter
|
||||
//
|
||||
// Mail Context
|
||||
//
|
||||
//! Mail Context
|
||||
|
||||
use std::sync::Arc;
|
||||
use bytes::{Bytes, BytesMut};
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
//
|
||||
// Husk milter
|
||||
//
|
||||
// Recipient
|
||||
//
|
||||
//! Recipient
|
||||
|
||||
use anyhow;
|
||||
use std::sync::Arc;
|
||||
|
||||
Reference in New Issue
Block a user