cvm12-rs/src/main.rs
modeco80 37339e2580 auth: new module
a client for cvmauth (the server side bit needed to actually do the magic)! just needs a couple todos and it should be good enough for server usage later on
2024-05-10 07:09:51 -04:00

62 lines
1.7 KiB
Rust

//use cvm12_rs::qmp;
//use tokio::net::UnixStream;
//use std::time::Duration;
#[tokio::main]
async fn main() {
let subscriber = tracing_subscriber::FmtSubscriber::builder()
.with_max_level(tracing::Level::TRACE)
.finish();
tracing::subscriber::set_global_default(subscriber).expect("You Banned");
/*
// Create a stream to connect
let stream = UnixStream::connect("/home/lily/vms/xpiss/qmp.sock")
.await
.expect("Could not connect");
let client = qmp::Client::new(stream);
// Handshake QMP
client.handshake().await.expect("Could not handshake QMP");
println!("Connected to QMP server");
// Create a copy of the client handle so we can issue a command in this other task.
// This other task waits 120 seconds and closes the client, which causes the actor to stop.
let copy = client.clone();
tokio::spawn(async move {
tokio::time::sleep(Duration::from_secs(120)).await;
println!("Closing client after 120 seconds");
copy.close().await.expect("Closing shouldn't fail");
});
println!(
"info block command: {}",
client
.execute_hmp("info block".into())
.await
.expect("this shouldn't fail")
);
// let's try to get all STOP events from QMP now.
let mut rx = client.subscribe_to_event("STOP".into()).await.unwrap();
// If this worked, then now we can recieve all the events.
// This code here allows running a VM with the -no-shutdown option,
// automatially resetting it on shutdown.
while let Some(message) = rx.recv().await {
println!("Got stop event! {:?}", message);
let res1 = client
.execute("system_reset".into(), None)
.await
.expect("FUCK");
let res2 = client.execute("cont".into(), None).await.expect("FUCK");
println!("Result of running: {:?}, {:?}", res1, res2);
}
*/
}