IP
This commit is contained in:
@@ -9,9 +9,9 @@ use std::{
|
||||
};
|
||||
use tokio::sync::mpsc::UnboundedSender;
|
||||
|
||||
pub fn connect(handle: AppHandle) {
|
||||
pub fn connect(handle: AppHandle, ip: String) {
|
||||
std::thread::spawn(|| {
|
||||
connect_the(handle).unwrap();
|
||||
connect_the(handle, ip).unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ pub enum NetCmd {
|
||||
pub type NetSender = UnboundedSender<NetCmd>;
|
||||
|
||||
#[tokio::main]
|
||||
async fn connect_the(handle: AppHandle) -> anyhow::Result<()> {
|
||||
async fn connect_the(handle: AppHandle, ip: String) -> 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")) {
|
||||
@@ -43,7 +43,8 @@ async fn connect_the(handle: AppHandle) -> anyhow::Result<()> {
|
||||
quinn::ClientConfig::new(Arc::new(QuicClientConfig::try_from(client_crypto)?));
|
||||
let mut endpoint = quinn::Endpoint::client(SocketAddr::from_str("[::]:0").unwrap())?;
|
||||
endpoint.set_default_client_config(client_config);
|
||||
let remote = SocketAddr::new(IpAddr::V6(Ipv6Addr::LOCALHOST), 4433);
|
||||
let remote = SocketAddr::from_str(&ip).unwrap();
|
||||
// let remote = SocketAddr::new(IpAddr::V6(Ipv6Addr::LOCALHOST), 4433);
|
||||
let host = "localhost";
|
||||
let conn = endpoint
|
||||
.connect(remote, host)?
|
||||
@@ -64,7 +65,9 @@ async fn connect_the(handle: AppHandle) -> anyhow::Result<()> {
|
||||
|
||||
drop(recv);
|
||||
|
||||
send.write_all(content.as_bytes()).await.expect("failed to send");
|
||||
send.write_all(content.as_bytes())
|
||||
.await
|
||||
.expect("failed to send");
|
||||
send.finish().unwrap();
|
||||
send.stopped().await.unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user