mirror of
https://github.com/iv-org/inv_sig_helper.git
synced 2024-12-04 03:40:55 +00:00
Successful compilation :D
This commit is contained in:
parent
0ab1304580
commit
2e63d3c20c
@ -1 +1 @@
|
|||||||
pub static DEFAULT_SOCK_PATH: String = "/tmp/inv_sig_helper.sock";
|
pub static DEFAULT_SOCK_PATH: &str = "/tmp/inv_sig_helper.sock";
|
||||||
|
@ -14,4 +14,5 @@ impl From<u8> for JobOpcode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn process_fetch_update() {}
|
||||||
pub async fn process_decrypt_n_signature(sig: String) {}
|
pub async fn process_decrypt_n_signature(sig: String) {}
|
||||||
|
24
src/main.rs
24
src/main.rs
@ -2,7 +2,7 @@ mod consts;
|
|||||||
mod jobs;
|
mod jobs;
|
||||||
|
|
||||||
use consts::DEFAULT_SOCK_PATH;
|
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 std::env::args;
|
||||||
use tokio::{
|
use tokio::{
|
||||||
io::{AsyncReadExt, BufReader},
|
io::{AsyncReadExt, BufReader},
|
||||||
@ -24,7 +24,10 @@ macro_rules! break_fail {
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
let args: Vec<String> = args().collect();
|
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();
|
let socket = UnixListener::bind(socket_url).unwrap();
|
||||||
|
|
||||||
@ -32,7 +35,7 @@ async fn main() {
|
|||||||
let (socket, _addr) = socket.accept().await.unwrap();
|
let (socket, _addr) = socket.accept().await.unwrap();
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
process_socket(socket);
|
process_socket(socket).await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -42,21 +45,24 @@ async fn process_socket(socket: UnixStream) {
|
|||||||
|
|
||||||
loop {
|
loop {
|
||||||
let opcode_byte: u8 = break_fail!(bufreader.read_u8().await);
|
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 {
|
match opcode {
|
||||||
JobOpcode::ForceUpdate => {}
|
JobOpcode::ForceUpdate => {
|
||||||
|
tokio::spawn(async move {
|
||||||
|
process_fetch_update().await;
|
||||||
|
});
|
||||||
|
}
|
||||||
JobOpcode::DecryptNSignature => {
|
JobOpcode::DecryptNSignature => {
|
||||||
let sig_size: usize =
|
let sig_size: usize = usize::from(break_fail!(bufreader.read_u16().await));
|
||||||
usize::try_from(break_fail!(bufreader.read_u16().await)).unwrap();
|
|
||||||
let mut buf = vec![0u8; sig_size];
|
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));
|
let _str = break_fail!(String::from_utf8(buf));
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
process_decrypt_n_signature(_str);
|
process_decrypt_n_signature(_str).await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
Loading…
Reference in New Issue
Block a user