login screen
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use crate::client::{AppHandle, ClientEvent};
|
||||
use quinn::{crypto::rustls::QuicClientConfig, rustls::pki_types::CertificateDer};
|
||||
use std::{
|
||||
fs,
|
||||
@@ -7,8 +8,14 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
pub fn connect(handle: AppHandle) {
|
||||
std::thread::spawn(|| {
|
||||
connect_the(handle).unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
pub async fn connect() -> anyhow::Result<()> {
|
||||
async fn connect_the(handle: AppHandle) -> anyhow::Result<()> {
|
||||
let dirs = directories_next::ProjectDirs::from("", "", "openworm").unwrap();
|
||||
let mut roots = quinn::rustls::RootCertStore::empty();
|
||||
match fs::read(dirs.data_local_dir().join("cert.der")) {
|
||||
@@ -36,13 +43,15 @@ pub async fn connect() -> anyhow::Result<()> {
|
||||
.await
|
||||
.map_err(|e| anyhow::anyhow!("failed to connect: {}", e))?;
|
||||
|
||||
let (mut send, mut recv) = conn
|
||||
let (mut send, recv) = conn
|
||||
.open_bi()
|
||||
.await
|
||||
.map_err(|e| anyhow::anyhow!("failed to open stream: {}", e))?;
|
||||
|
||||
drop(recv);
|
||||
|
||||
handle.send(ClientEvent::Connect);
|
||||
|
||||
send.write_all(&[39]).await.expect("failed to send");
|
||||
send.finish().unwrap();
|
||||
send.stopped().await.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user