[WIP] QUIC connection
This commit is contained in:
parent
26b8480372
commit
cf38693810
6 changed files with 1092 additions and 894 deletions
|
|
@ -27,6 +27,9 @@ async fn main() {
|
|||
startup();
|
||||
log_in!("Incoming messages");
|
||||
log_out!("Outgoing messages");
|
||||
|
||||
let _ = omikron_connection::start(9187).await;
|
||||
|
||||
log!("Started");
|
||||
log!(" .env");
|
||||
if let Err(e) = initialize_db().await {
|
||||
|
|
@ -43,7 +46,8 @@ async fn main() {
|
|||
} else {
|
||||
log!(" Users");
|
||||
}
|
||||
|
||||
let _ = server::server::start(9188).await;
|
||||
let _ = omikron_connection::OmikronServer::start(9187).await;
|
||||
|
||||
tokio::signal::ctrl_c().await.unwrap();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,16 +65,20 @@ pub async fn handle(path: &str, body_string: Option<String>) -> HttpResponse {
|
|||
// ==================================================
|
||||
["api", "get", "omikron"] => {
|
||||
if let Ok(omikron_conn) = get_random_omikron().await {
|
||||
let id = omikron_conn.get_omikron_id().await;
|
||||
if let Some(id) = omikron_conn.get_omikron_id().await {
|
||||
if let Ok((public_key, ip_address)) = sql::get_omikron_by_id(id).await {
|
||||
let mut res = JsonValue::new_object();
|
||||
res["status"] = "success".into();
|
||||
res["id"] = id.into();
|
||||
res["public_key"] = public_key.into();
|
||||
res["ip_address"] = ip_address.into();
|
||||
|
||||
if let Ok((public_key, ip_address)) = sql::get_omikron_by_id(id).await {
|
||||
let mut res = JsonValue::new_object();
|
||||
res["status"] = "success".into();
|
||||
res["id"] = id.into();
|
||||
res["public_key"] = public_key.into();
|
||||
res["ip_address"] = ip_address.into();
|
||||
|
||||
(StatusCode::OK, res.dump())
|
||||
(StatusCode::OK, res.dump())
|
||||
} else {
|
||||
let mut res = JsonValue::new_object();
|
||||
res["status"] = "error".into();
|
||||
(StatusCode::INTERNAL_SERVER_ERROR, res.dump())
|
||||
}
|
||||
} else {
|
||||
let mut res = JsonValue::new_object();
|
||||
res["status"] = "error".into();
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -8,7 +8,13 @@ pub static OMIKRON_CONNECTIONS: Lazy<DashMap<i64, Arc<OmikronConnection>>> =
|
|||
Lazy::new(|| DashMap::new());
|
||||
|
||||
pub async fn add_omikron(conn: Arc<OmikronConnection>) {
|
||||
let id = conn.get_omikron_id().await;
|
||||
let id = match conn.get_omikron_id().await {
|
||||
Some(id) => id,
|
||||
_ => {
|
||||
conn.close().await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
if let Some(old) = OMIKRON_CONNECTIONS.insert(id, conn.clone()) {
|
||||
old.close().await;
|
||||
|
|
|
|||
Loading…
Reference in a new issue