more work on identity->chat hello/handshake
This commit is contained in:
parent
1e53661b0a
commit
041531e88a
12 changed files with 96 additions and 40 deletions
|
@ -27,15 +27,15 @@ pub fn is_valid_domain(domain: &str) -> bool {
|
|||
|
||||
pub async fn get<R: DeserializeOwned>(
|
||||
private_key: &RsaPrivateKey,
|
||||
self_domain: String,
|
||||
host: String,
|
||||
path: String,
|
||||
self_domain: &str,
|
||||
host: &str,
|
||||
path: &str,
|
||||
user_id: Option<&str>,
|
||||
) -> Result<R> {
|
||||
let (signature, date) = build_signature(
|
||||
private_key,
|
||||
host.clone(),
|
||||
path.clone(),
|
||||
host,
|
||||
path,
|
||||
None,
|
||||
user_id.clone(),
|
||||
);
|
||||
|
@ -58,9 +58,9 @@ pub async fn get<R: DeserializeOwned>(
|
|||
|
||||
pub async fn post<T: Serialize, R: DeserializeOwned>(
|
||||
private_key: &RsaPrivateKey,
|
||||
self_domain: String,
|
||||
host: String,
|
||||
path: String,
|
||||
self_domain: &str,
|
||||
host: &str,
|
||||
path: &str,
|
||||
user_id: Option<&str>,
|
||||
body: &T,
|
||||
) -> Result<R> {
|
||||
|
@ -68,8 +68,8 @@ pub async fn post<T: Serialize, R: DeserializeOwned>(
|
|||
|
||||
let (signature, date) = build_signature(
|
||||
private_key,
|
||||
host.clone(),
|
||||
path.clone(),
|
||||
host,
|
||||
path,
|
||||
Some(body.len()),
|
||||
user_id.clone(),
|
||||
);
|
||||
|
|
|
@ -10,8 +10,8 @@ use crate::FoxError;
|
|||
|
||||
pub fn build_signature(
|
||||
private_key: &RsaPrivateKey,
|
||||
host: String,
|
||||
request_path: String,
|
||||
host: &str,
|
||||
request_path: &str,
|
||||
content_length: Option<usize>,
|
||||
user_id: Option<&str>,
|
||||
) -> (String, DateTime<Utc>) {
|
||||
|
|
18
foxchat/src/s2s/http/hello.rs
Normal file
18
foxchat/src/s2s/http/hello.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
use serde::{Serialize, Deserialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct HelloRequest {
|
||||
pub host: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct HelloResponse {
|
||||
pub public_key: String,
|
||||
pub host: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct NodeResponse {
|
||||
pub software: String,
|
||||
pub public_key: String,
|
||||
}
|
3
foxchat/src/s2s/http/mod.rs
Normal file
3
foxchat/src/s2s/http/mod.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
mod hello;
|
||||
|
||||
pub use hello::{HelloRequest, HelloResponse, NodeResponse};
|
|
@ -1,3 +1,4 @@
|
|||
mod event;
|
||||
pub mod http;
|
||||
|
||||
pub use event::{DispatchEvent, Payload};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue