From b3fbfa627594610a1b9c1693e10a45f525cb0c87 Mon Sep 17 00:00:00 2001 From: joalopez Date: Wed, 17 Jul 2024 12:50:20 -0400 Subject: [PATCH] feat: Add immediate_process_tsig function for immediate TSIG processing --- src/tsig.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/tsig.rs b/src/tsig.rs index 02e4551b..d5d58af5 100644 --- a/src/tsig.rs +++ b/src/tsig.rs @@ -3,7 +3,7 @@ use std::fmt::{self,Display,Debug}; //aquí debe ir todo lo relacionado a la implementación de tsig como módulo use crypto::mac::MacResult; use crate::domain_name::DomainName; - +use std::time::SystemTime; use crate::message::rclass::Rclass; use crate::message::resource_record::{ResourceRecord, ToBytes}; @@ -379,6 +379,14 @@ pub fn process_tsig(msg: &DnsMessage, key:&[u8], key_name: String, time: u64, (true, TsigErrorCode::NOERR) } + +pub fn immediate_process_tsig(msg: &DnsMessage, key:&[u8], key_name: String, + available_algorithm: Vec<(String, bool)>, mac_to_process: Vec) -> (bool, TsigErrorCode) { + + let time = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs(); + process_tsig(msg, key, key_name, time, available_algorithm, mac_to_process) +} + //Auxiliar function to create the TSIG variables and resource recrods #[doc= r"This function helps to set create a partial TSIG resource record on a DNS query"] fn set_tsig_vars(alg_name: &str, name: &str, time_signed: u64, fudge: u16) -> ResourceRecord{