Add trust migration server handling
This commit is contained in:
parent
11071756d4
commit
984bbe9370
|
@ -100,6 +100,10 @@ async fn handle(
|
||||||
let bytes = body::to_bytes(req.into_body()).await.unwrap();
|
let bytes = body::to_bytes(req.into_body()).await.unwrap();
|
||||||
verify_and_send_trust_promo(bytes, context.ba)
|
verify_and_send_trust_promo(bytes, context.ba)
|
||||||
}),
|
}),
|
||||||
|
(&Method::POST, "/trustmig") => Ok::<_, Infallible>({
|
||||||
|
let bytes = body::to_bytes(req.into_body()).await.unwrap();
|
||||||
|
verify_and_send_trust_migration(bytes, context.ba)
|
||||||
|
}),
|
||||||
_ => {
|
_ => {
|
||||||
// Return 404 not found response.
|
// Return 404 not found response.
|
||||||
Ok(Response::builder()
|
Ok(Response::builder()
|
||||||
|
@ -124,6 +128,7 @@ fn generate_invite(db: Arc<Mutex<lox::BridgeDb>>) -> Response<Body> {
|
||||||
resp
|
resp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn send_reachability_cred(ba: Arc<Mutex<BridgeAuth>>) -> Response<Body> {
|
fn send_reachability_cred(ba: Arc<Mutex<BridgeAuth>>) -> Response<Body> {
|
||||||
let ba_obj = ba.lock().unwrap();
|
let ba_obj = ba.lock().unwrap();
|
||||||
let mut resp = Response::new(Body::from(serde_json::to_string(&ba_obj.reachability_pub).unwrap()));
|
let mut resp = Response::new(Body::from(serde_json::to_string(&ba_obj.reachability_pub).unwrap()));
|
||||||
|
@ -172,6 +177,18 @@ fn verify_and_send_trust_promo(request: Bytes, ba: Arc<Mutex<BridgeAuth>>) -> Re
|
||||||
.insert("Access-Control-Allow-Origin", HeaderValue::from_static("*"));
|
.insert("Access-Control-Allow-Origin", HeaderValue::from_static("*"));
|
||||||
resp
|
resp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn verify_and_send_trust_migration(request: Bytes, ba: Arc<Mutex<BridgeAuth>>) -> Response<Body> {
|
||||||
|
let req: proto::migration::Request = serde_json::from_slice(&request).unwrap();
|
||||||
|
let mut ba_obj = ba.lock().unwrap();
|
||||||
|
let response = ba_obj.handle_migration(req).unwrap();
|
||||||
|
let trust_migration_resp_str = serde_json::to_string(&response).unwrap();
|
||||||
|
let mut resp = Response::new(Body::from(trust_migration_resp_str));
|
||||||
|
resp.headers_mut()
|
||||||
|
.insert("Access-Control-Allow-Origin", HeaderValue::from_static("*"));
|
||||||
|
resp
|
||||||
|
}
|
||||||
|
|
||||||
async fn shutdown_signal() {
|
async fn shutdown_signal() {
|
||||||
tokio::signal::ctrl_c()
|
tokio::signal::ctrl_c()
|
||||||
.await
|
.await
|
||||||
|
|
Loading…
Reference in New Issue