encrypt/decrypt and db interaction

This commit is contained in:
2022-12-03 21:47:09 -08:00
parent 196510e9a2
commit 1e4e1c9a5f
9 changed files with 375 additions and 49 deletions

View File

@ -45,6 +45,11 @@ async fn handle(mut stream: TcpStream, app_handle: AppHandle) -> Result<(), Requ
let (chan_send, chan_recv) = oneshot::channel();
let app_state = app_handle.state::<crate::state::AppState>();
let request_id = app_state.register_request(chan_send);
if let std::net::SocketAddr::V4(addr) = stream.peer_addr()? {
crate::clientinfo::get_client_info(addr.port());
}
// Do we want to panic if this fails? Does that mean the frontend is dead?
app_handle.emit_all("credentials-request", Request {id: request_id}).unwrap();
@ -77,7 +82,7 @@ async fn handle(mut stream: TcpStream, app_handle: AppHandle) -> Result<(), Requ
return Ok(());
}
let creds = app_state.get_creds_serialized();
let creds = app_state.get_creds_serialized()?;
stream.write(b"\r\nContent-Length: ").await?;
stream.write(creds.as_bytes().len().to_string().as_bytes()).await?;