Successful compilation :D

This commit is contained in:
techmetx11 2024-04-28 15:37:02 +01:00
parent 0ab1304580
commit 2e63d3c20c
No known key found for this signature in database
GPG Key ID: 20E0C88A0E7E5AF2
3 changed files with 17 additions and 10 deletions

View File

@ -1 +1 @@
pub static DEFAULT_SOCK_PATH: String = "/tmp/inv_sig_helper.sock";
pub static DEFAULT_SOCK_PATH: &str = "/tmp/inv_sig_helper.sock";

View File

@ -14,4 +14,5 @@ impl From<u8> for JobOpcode {
}
}
pub async fn process_fetch_update() {}
pub async fn process_decrypt_n_signature(sig: String) {}

View File

@ -2,7 +2,7 @@ mod consts;
mod jobs;
use consts::DEFAULT_SOCK_PATH;
use jobs::{process_decrypt_n_signature, JobOpcode};
use jobs::{process_decrypt_n_signature, process_fetch_update, JobOpcode};
use std::env::args;
use tokio::{
io::{AsyncReadExt, BufReader},
@ -24,7 +24,10 @@ macro_rules! break_fail {
#[tokio::main]
async fn main() {
let args: Vec<String> = args().collect();
let socket_url: &String = args.get(1).unwrap_or(&DEFAULT_SOCK_PATH);
let socket_url: &str = match args.get(1) {
Some(stringref) => stringref,
None => DEFAULT_SOCK_PATH,
};
let socket = UnixListener::bind(socket_url).unwrap();
@ -32,7 +35,7 @@ async fn main() {
let (socket, _addr) = socket.accept().await.unwrap();
tokio::spawn(async move {
process_socket(socket);
process_socket(socket).await;
});
}
}
@ -42,21 +45,24 @@ async fn process_socket(socket: UnixStream) {
loop {
let opcode_byte: u8 = break_fail!(bufreader.read_u8().await);
let opcode: JobOpcode = opcode_byte.try_into().unwrap();
let opcode: JobOpcode = opcode_byte.into();
match opcode {
JobOpcode::ForceUpdate => {}
JobOpcode::ForceUpdate => {
tokio::spawn(async move {
process_fetch_update().await;
});
}
JobOpcode::DecryptNSignature => {
let sig_size: usize =
usize::try_from(break_fail!(bufreader.read_u16().await)).unwrap();
let sig_size: usize = usize::from(break_fail!(bufreader.read_u16().await));
let mut buf = vec![0u8; sig_size];
bufreader.read_exact(&mut buf).await;
break_fail!(bufreader.read_exact(&mut buf).await);
let _str = break_fail!(String::from_utf8(buf));
tokio::spawn(async move {
process_decrypt_n_signature(_str);
process_decrypt_n_signature(_str).await;
});
}
_ => {}