Merge branch 'main' of github.com:Tensamin/Omega

This commit is contained in:
Alex Emmet 2026-03-06 20:36:03 +01:00
commit dde32812d3
2 changed files with 15 additions and 17 deletions

View file

@ -7,9 +7,11 @@ use crate::sql::sql::initialize_db;
use crate::sql::sql::print_users;
use crate::util::crypto_helper::load_public_key;
use crate::util::crypto_helper::load_secret_key;
use crate::util::logger::PrintType;
use crate::util::logger::startup;
use dotenv::dotenv;
use once_cell::sync::Lazy;
use rustls::crypto::aws_lc_rs::default_provider;
use std::env;
static PRIVATE_KEY: Lazy<String> = Lazy::new(|| env::var("PRIVATE_KEY").unwrap());
@ -23,13 +25,20 @@ pub fn get_public_key() -> x448::PublicKey {
#[tokio::main]
async fn main() {
if let Err(_) = default_provider().install_default() {
println!("Error loading Provider");
return;
}
dotenv().ok();
startup();
log_in!("Incoming messages");
log_out!("Outgoing messages");
tokio::spawn(async move {
let _ = omikron_connection::start(9187).await;
match omikron_connection::start(9187).await {
Err(e) => log_err!(0, PrintType::General, "{:?}", e),
_ => {}
}
});
log!("Started");

21
src/server/omikron_connection.rs Executable file → Normal file
View file

@ -6,22 +6,14 @@ use crate::{
sql::{self, get_by_user_id, get_by_username, get_iota_by_id, get_omikron_by_id},
user_online_tracker::{self},
},
util::{
crypto_helper::encrypt,
file_util::{load_file_buf, load_file_vec},
logger::PrintType,
},
util::{crypto_helper::encrypt, file_util::load_file_vec, logger::PrintType},
};
use base64::{Engine as _, engine::general_purpose::STANDARD};
use dashmap::DashMap;
use epsilon_core::{CommunicationType, CommunicationValue, DataTypes, DataValue};
use epsilon_native::{Host, Receiver, Sender};
use quinn::crypto::rustls::QuicServerConfig;
use quinn::{Endpoint, ServerConfig};
use rand::{Rng, distributions::Alphanumeric};
use rustls::{ServerConfig as CryptoConfig, crypto::aws_lc_rs};
use std::{
net::SocketAddr,
sync::Arc,
time::{Duration, Instant},
};
@ -1090,12 +1082,6 @@ impl OmikronConnection {
}
}
fn arc_self(self: Arc<Self>) -> Arc<Self> {
// This is a bit of a hack - in practice you'd store the Arc in the struct
// or use weak references. For now, we rely on the caller having the Arc.
panic!("Use the Arc<OmikronConnection> directly")
}
// Public API for external use
pub async fn is_authenticated(self: Arc<Self>) -> bool {
self.state.read().await.is_authenticated()
@ -1115,7 +1101,10 @@ impl OmikronConnection {
// ============================================================================
pub async fn start(port: u16) -> Result<(), Box<dyn std::error::Error>> {
let _ = aws_lc_rs::default_provider().install_default();
let cert_pem = load_file_vec("certs", "cert.pem")
.map_err(|e| format!("Failed to load certificate: {}", e))?;
let key_pem = load_file_vec("certs", "key.pem")
.map_err(|e| format!("Failed to load private key: {}", e))?;
let cert_pem = load_file_vec("certs", "cert.pem").expect("Error loading Pemfile");