[Fix] Omikron Connection
This commit is contained in:
parent
6f3bf3692d
commit
a4f7a9387d
3 changed files with 38 additions and 57 deletions
59
Cargo.lock
generated
59
Cargo.lock
generated
|
|
@ -982,10 +982,10 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "epsilon-core"
|
name = "epsilon-core"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/Tensamin/Epsilon.git#1eb12cceb70d99dded2327e0a5f215a5cd137eb3"
|
source = "git+https://github.com/Tensamin/Epsilon.git#809a32581843e663d35d4b3222f2cc59371d2786"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"base64",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"quinn",
|
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"strum 0.28.0",
|
"strum 0.28.0",
|
||||||
"strum_macros 0.28.0",
|
"strum_macros 0.28.0",
|
||||||
|
|
@ -994,21 +994,15 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "epsilon-native"
|
name = "epsilon-native"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/Tensamin/Epsilon.git#1eb12cceb70d99dded2327e0a5f215a5cd137eb3"
|
source = "git+https://github.com/Tensamin/Epsilon.git#809a32581843e663d35d4b3222f2cc59371d2786"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
|
||||||
"async-trait",
|
|
||||||
"aws-lc-rs",
|
|
||||||
"bytes",
|
|
||||||
"epsilon-core",
|
"epsilon-core",
|
||||||
"quinn",
|
"quinn",
|
||||||
"rcgen",
|
|
||||||
"rustls",
|
"rustls",
|
||||||
"rustls-native-certs",
|
"rustls-native-certs",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.18",
|
||||||
"tokio",
|
"tokio",
|
||||||
"wtransport",
|
"wtransport",
|
||||||
"wtransport-proto",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -1046,18 +1040,6 @@ dependencies = [
|
||||||
"regex",
|
"regex",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fastbloom"
|
|
||||||
version = "0.14.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4e7f34442dbe69c60fe8eaf58a8cafff81a1f278816d8ab4db255b3bef4ac3c4"
|
|
||||||
dependencies = [
|
|
||||||
"getrandom 0.3.4",
|
|
||||||
"libm",
|
|
||||||
"rand 0.9.2",
|
|
||||||
"siphasher",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fastrand"
|
name = "fastrand"
|
||||||
version = "2.3.0"
|
version = "2.3.0"
|
||||||
|
|
@ -1942,12 +1924,6 @@ version = "0.2.183"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d"
|
checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libm"
|
|
||||||
version = "0.2.16"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "line-clipping"
|
name = "line-clipping"
|
||||||
version = "0.3.5"
|
version = "0.3.5"
|
||||||
|
|
@ -2218,18 +2194,18 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objc2-core-foundation"
|
name = "objc2-core-foundation"
|
||||||
version = "0.3.1"
|
version = "0.3.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1c10c2894a6fed806ade6027bcd50662746363a9589d3ec9d9bef30a4e4bc166"
|
checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.11.0",
|
"bitflags 2.11.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objc2-io-kit"
|
name = "objc2-io-kit"
|
||||||
version = "0.3.1"
|
version = "0.3.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "71c1c64d6120e51cd86033f67176b1cb66780c2efe34dec55176f77befd93c0a"
|
checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"objc2-core-foundation",
|
"objc2-core-foundation",
|
||||||
|
|
@ -2694,13 +2670,12 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quinn-proto"
|
name = "quinn-proto"
|
||||||
version = "0.11.13"
|
version = "0.11.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f1906b49b0c3bc04b5fe5d86a77925ae6524a19b816ae38ce1e426255f1d8a31"
|
checksum = "434b42fec591c96ef50e21e886936e66d3cc3f737104fdb9b737c40ffb94c098"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aws-lc-rs",
|
"aws-lc-rs",
|
||||||
"bytes",
|
"bytes",
|
||||||
"fastbloom",
|
|
||||||
"getrandom 0.3.4",
|
"getrandom 0.3.4",
|
||||||
"lru-slab",
|
"lru-slab",
|
||||||
"rand 0.9.2",
|
"rand 0.9.2",
|
||||||
|
|
@ -2708,7 +2683,6 @@ dependencies = [
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"rustls",
|
"rustls",
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
"rustls-platform-verifier",
|
|
||||||
"slab",
|
"slab",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.18",
|
||||||
"tinyvec",
|
"tinyvec",
|
||||||
|
|
@ -2908,8 +2882,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "10b99e0098aa4082912d4c649628623db6aba77335e4f4569ff5083a6448b32e"
|
checksum = "10b99e0098aa4082912d4c649628623db6aba77335e4f4569ff5083a6448b32e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aws-lc-rs",
|
"aws-lc-rs",
|
||||||
"pem",
|
|
||||||
"ring",
|
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
"time",
|
"time",
|
||||||
"x509-parser 0.18.1",
|
"x509-parser 0.18.1",
|
||||||
|
|
@ -3471,9 +3443,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sysinfo"
|
name = "sysinfo"
|
||||||
version = "0.38.3"
|
version = "0.38.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d03c61d2a49c649a15c407338afe7accafde9dac869995dccb73e5f7ef7d9034"
|
checksum = "92ab6a2f8bfe508deb3c6406578252e491d299cbbf3bc0529ecc3313aee4a52f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"memchr",
|
"memchr",
|
||||||
|
|
@ -4801,7 +4773,6 @@ dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"nom",
|
"nom",
|
||||||
"oid-registry",
|
"oid-registry",
|
||||||
"ring",
|
|
||||||
"rusticata-macros",
|
"rusticata-macros",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.18",
|
||||||
"time",
|
"time",
|
||||||
|
|
@ -4841,18 +4812,18 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zerocopy"
|
name = "zerocopy"
|
||||||
version = "0.8.40"
|
version = "0.8.42"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a789c6e490b576db9f7e6b6d661bcc9799f7c0ac8352f56ea20193b2681532e5"
|
checksum = "f2578b716f8a7a858b7f02d5bd870c14bf4ddbbcf3a4c05414ba6503640505e3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zerocopy-derive",
|
"zerocopy-derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zerocopy-derive"
|
name = "zerocopy-derive"
|
||||||
version = "0.8.40"
|
version = "0.8.42"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f65c489a7071a749c849713807783f70672b28094011623e200cb86dcb835953"
|
checksum = "7e6cc098ea4d3bd6246687de65af3f920c430e236bee1e3bf2e441463f08a02f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use crate::util::crypto_util::{DataFormat, SecurePayload};
|
||||||
use crate::util::file_util::{get_children, load_file, save_file};
|
use crate::util::file_util::{get_children, load_file, save_file};
|
||||||
use crate::util::{chat_files, chats_util};
|
use crate::util::{chat_files, chats_util};
|
||||||
use crate::util::{config_util::CONFIG, crypto_helper};
|
use crate::util::{config_util::CONFIG, crypto_helper};
|
||||||
use crate::{ACTIVE_TASKS, SHUTDOWN, log, log_cv_in, log_t};
|
use crate::{ACTIVE_TASKS, SHUTDOWN, log, log_cv_in, log_cv_out, log_t};
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use epsilon_core::{CommunicationType, CommunicationValue, DataTypes, DataValue};
|
use epsilon_core::{CommunicationType, CommunicationValue, DataTypes, DataValue};
|
||||||
use epsilon_native::{Receiver, Sender};
|
use epsilon_native::{Receiver, Sender};
|
||||||
|
|
@ -28,7 +28,7 @@ const OMIKRON_PORT_DEFAULT: u16 = 959;
|
||||||
const RECONNECT_DELAY: Duration = Duration::from_secs(5);
|
const RECONNECT_DELAY: Duration = Duration::from_secs(5);
|
||||||
const MAX_RECONNECT_DELAY: Duration = Duration::from_secs(300);
|
const MAX_RECONNECT_DELAY: Duration = Duration::from_secs(300);
|
||||||
const CONNECTION_TIMEOUT: Duration = Duration::from_secs(10);
|
const CONNECTION_TIMEOUT: Duration = Duration::from_secs(10);
|
||||||
const HEARTBEAT_INTERVAL: Duration = Duration::from_secs(10);
|
const HEARTBEAT_INTERVAL: Duration = Duration::from_secs(5);
|
||||||
const TASK_CLEANUP_INTERVAL: Duration = Duration::from_secs(60);
|
const TASK_CLEANUP_INTERVAL: Duration = Duration::from_secs(60);
|
||||||
const TASK_MAX_AGE: Duration = Duration::from_secs(60);
|
const TASK_MAX_AGE: Duration = Duration::from_secs(60);
|
||||||
|
|
||||||
|
|
@ -282,6 +282,7 @@ impl OmikronConnection {
|
||||||
|
|
||||||
if iota_id == 0 || public_key.is_none() || private_key.is_none() {
|
if iota_id == 0 || public_key.is_none() || private_key.is_none() {
|
||||||
log_t!("iota_register_new");
|
log_t!("iota_register_new");
|
||||||
|
|
||||||
let key_pair = crypto_helper::generate_keypair();
|
let key_pair = crypto_helper::generate_keypair();
|
||||||
let public_key_base64 = crypto_helper::public_key_to_base64(&key_pair.public);
|
let public_key_base64 = crypto_helper::public_key_to_base64(&key_pair.public);
|
||||||
let private_key_base64 = crypto_helper::secret_key_to_base64(&key_pair.secret);
|
let private_key_base64 = crypto_helper::secret_key_to_base64(&key_pair.secret);
|
||||||
|
|
@ -351,12 +352,20 @@ impl OmikronConnection {
|
||||||
self.clone().handle_message(cv).await;
|
self.clone().handle_message(cv).await;
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log!("Receive error: {}", e);
|
log!(
|
||||||
|
"Receive error: {} connection_id={} receiver_open={}",
|
||||||
|
e,
|
||||||
|
self.connection_id,
|
||||||
|
receiver.is_open()
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !receiver.is_open() {
|
if !receiver.is_open() {
|
||||||
log!("Connection closed ");
|
log!(
|
||||||
|
"Connection closed connection_id={} receiver_open=false",
|
||||||
|
self.connection_id
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -387,7 +396,9 @@ impl OmikronConnection {
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
pub async fn handle_message(self: Arc<Self>, cv: CommunicationValue) {
|
pub async fn handle_message(self: Arc<Self>, cv: CommunicationValue) {
|
||||||
log_cv_in!(&cv);
|
if !cv.is_type(CommunicationType::ping) && !cv.is_type(CommunicationType::pong) {
|
||||||
|
log_cv_in!(&cv);
|
||||||
|
}
|
||||||
|
|
||||||
let msg_id = cv.get_id();
|
let msg_id = cv.get_id();
|
||||||
|
|
||||||
|
|
@ -436,7 +447,6 @@ impl OmikronConnection {
|
||||||
|
|
||||||
if cv.is_type(CommunicationType::identification_response) {
|
if cv.is_type(CommunicationType::identification_response) {
|
||||||
if let Some(accepted) = cv.get_data(DataTypes::accepted).as_bool() {
|
if let Some(accepted) = cv.get_data(DataTypes::accepted).as_bool() {
|
||||||
log!("Omikron connected: {}", accepted.to_string());
|
|
||||||
let mut state = self.state.write().await;
|
let mut state = self.state.write().await;
|
||||||
if let ConnectionState::Connected { identified: _ } = *state {
|
if let ConnectionState::Connected { identified: _ } = *state {
|
||||||
*state = ConnectionState::Connected { identified: true };
|
*state = ConnectionState::Connected { identified: true };
|
||||||
|
|
@ -771,16 +781,13 @@ impl OmikronConnection {
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(decrypted) = solved_challenge {
|
if let Some(decrypted) = solved_challenge {
|
||||||
|
let solved = decrypted.export(DataFormat::Raw);
|
||||||
|
|
||||||
let response = CommunicationValue::new(CommunicationType::challenge_response)
|
let response = CommunicationValue::new(CommunicationType::challenge_response)
|
||||||
.with_id(cv.get_id())
|
.with_id(cv.get_id())
|
||||||
.add_data(
|
.add_data(DataTypes::challenge, DataValue::Str(solved));
|
||||||
DataTypes::challenge,
|
|
||||||
DataValue::Str(decrypted.export(DataFormat::Base64)),
|
|
||||||
);
|
|
||||||
|
|
||||||
self.send_message(&response).await;
|
self.send_message(&response).await;
|
||||||
} else {
|
|
||||||
log!("Failed to decrypt challenge");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -803,6 +810,9 @@ impl OmikronConnection {
|
||||||
let sender_clone = Arc::clone(sender);
|
let sender_clone = Arc::clone(sender);
|
||||||
drop(sender_guard);
|
drop(sender_guard);
|
||||||
|
|
||||||
|
if !cv.is_type(CommunicationType::ping) && !cv.is_type(CommunicationType::pong) {
|
||||||
|
log_cv_out!(&cv);
|
||||||
|
}
|
||||||
if let Err(e) = sender_clone.send(cv).await {
|
if let Err(e) = sender_clone.send(cv).await {
|
||||||
log_t!("send_message_failed", e.to_string());
|
log_t!("send_message_failed", e.to_string());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ impl OmikronConnection {
|
||||||
.with_id(id)
|
.with_id(id)
|
||||||
.add_data(
|
.add_data(
|
||||||
DataTypes::last_ping,
|
DataTypes::last_ping,
|
||||||
DataValue::Number(*self.last_ping.lock().await),
|
DataValue::Array(vec![DataValue::Number(*self.last_ping.lock().await)]),
|
||||||
);
|
);
|
||||||
|
|
||||||
self.send_message(&ping_message).await;
|
self.send_message(&ping_message).await;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue