diff --git a/src/auth/auth_connector.rs b/src/auth/auth_connector.rs index 3066b5b..ecd6c63 100644 --- a/src/auth/auth_connector.rs +++ b/src/auth/auth_connector.rs @@ -127,9 +127,7 @@ pub async fn complete_register(user_profile: &UserProfile, iota_id: &str) -> boo .await .unwrap(); - println!("Status: {}", res.status()); let body = res.text().await.unwrap(); - println!("Response body:\n{}", body); CommunicationValue::from_json(&body).is_type(CommunicationType::success) } diff --git a/src/main.rs b/src/main.rs index ffac830..dfc3870 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,6 +40,7 @@ pub static APP_STATE: LazyLock>> = LazyLock::new(|| Arc::new(Mutex::new(AppState::new()))); pub static SHUTDOWN: Lazy> = Lazy::new(|| RwLock::new(false)); +pub static RECONNECT: Lazy> = Lazy::new(|| RwLock::new(false)); #[tokio::main(flavor = "multi_thread", worker_threads = 8)] #[allow(unused_must_use, dead_code)] diff --git a/src/omikron/omikron_connection.rs b/src/omikron/omikron_connection.rs index cc2f635..544850d 100644 --- a/src/omikron/omikron_connection.rs +++ b/src/omikron/omikron_connection.rs @@ -1,4 +1,3 @@ -use crate::SHUTDOWN; use crate::auth::local_auth; use crate::data::communication::{CommunicationType, CommunicationValue, DataTypes}; use crate::gui::log_panel::{log_cv, log_message, log_message_trans}; @@ -8,6 +7,7 @@ use crate::users::user_community_util::UserCommunityUtil; use crate::util::chat_files; use crate::util::chats_util::{get_user, get_users, mod_user}; use crate::util::file_util::{get_children, load_file, save_file}; +use crate::{RECONNECT, SHUTDOWN}; use futures::Stream; use futures::stream::{SplitSink, SplitStream}; use futures_util::sink::Sink; @@ -91,6 +91,9 @@ impl OmikronConnection { if *SHUTDOWN.read().await { break; } + if *RECONNECT.read().await { + break; + } match connect_async("wss://app.tensamin.net/ws/iota/").await { Ok((ws_stream, _)) => { let (write_half, read_half) = ws_stream.split(); @@ -105,6 +108,9 @@ impl OmikronConnection { if *SHUTDOWN.read().await { break; } + if *RECONNECT.read().await { + break; + } cloned_self.send_ping().await; sleep(Duration::from_secs(1)).await; } @@ -149,6 +155,9 @@ impl OmikronConnection { if *SHUTDOWN.read().await { break; } + if *RECONNECT.read().await { + break; + } let waiting = waiting_out.clone(); let writer = writer_out.clone(); let is_connected = is_connected_out.clone(); diff --git a/src/server/server.rs b/src/server/server.rs index 6e1fc83..e465a5a 100644 --- a/src/server/server.rs +++ b/src/server/server.rs @@ -202,23 +202,8 @@ impl Service> for HttpService { } fn is_local_network(addr: IpAddr) -> bool { - if addr.is_loopback() { - return true; - } - - if let IpAddr::V4(ipv4) = addr { - if ipv4.octets()[0] == 169 && ipv4.octets()[1] == 254 { - return true; - } - } - - if let IpAddr::V6(ipv6) = addr { - if (ipv6.segments()[0] & 0xfe00) == 0xfc00 { - return true; - } - } - - false + // PLACEHOLDER + return true; } async fn run_http_server(port: u16) -> bool { diff --git a/src/users/user_manager.rs b/src/users/user_manager.rs index 77a64d8..263cde9 100644 --- a/src/users/user_manager.rs +++ b/src/users/user_manager.rs @@ -1,4 +1,6 @@ +use crate::RECONNECT; use crate::auth::{auth_connector, crypto_helper}; +use crate::gui::log_panel::log_message; use crate::users::user_profile::UserProfile; use crate::util::config_util::CONFIG; use crate::util::file_util::{load_file, save_file}; @@ -71,6 +73,8 @@ pub async fn create_user(username: &str) -> (Option, Option ); auth_connector::complete_register(&up, &CONFIG.read().await.get_iota_id().to_string()).await; + *RECONNECT.write().await = true; + log_message("Created User"); save_file( "", &format!("{}.tu", username),