Use real config for RID NIP-11
This commit is contained in:
parent
bf08ac12e0
commit
645d125077
|
@ -11,18 +11,12 @@ pub async fn ws_handler(
|
||||||
Ok(ws.on_upgrade(move |socket| ws::client_connection(socket, context, real_client_ip)))
|
Ok(ws.on_upgrade(move |socket| ws::client_connection(socket, context, real_client_ip)))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn relay_config(header: String) -> Result<impl Reply, Rejection> {
|
pub async fn relay_config(header: String, context: Context) -> Result<impl Reply, Rejection> {
|
||||||
if header != "application/nostr+json" {
|
if header != "application/nostr+json" {
|
||||||
Err(warp::reject::not_found())
|
Err(warp::reject::not_found())
|
||||||
} else {
|
} else {
|
||||||
let res = serde_json::json!({
|
let config = context.config.get_relay_config_json();
|
||||||
"contact": "klink@zhitno.st",
|
|
||||||
"name": "zhitno.st",
|
Ok(warp::reply::json(&config))
|
||||||
"description": "Very *special* nostr relay",
|
|
||||||
"supported_nips": [ 1, 9, 11, 12, 15, 16, 20, 22, 28, 33 ],
|
|
||||||
"software": "git+https://git.zhitno.st/Klink/sneedstr.git",
|
|
||||||
"version": "0.1.0"
|
|
||||||
});
|
|
||||||
Ok(warp::reply::json(&res))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,19 +12,15 @@ pub fn routes(context: Context) -> impl Filter<Extract = impl Reply, Error = Rej
|
||||||
fn index(context: Context) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
|
fn index(context: Context) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
|
||||||
// let real_client_ip = warp::header::optional::<std::net::SocketAddr>("X-Real-IP");
|
// let real_client_ip = warp::header::optional::<std::net::SocketAddr>("X-Real-IP");
|
||||||
let real_client_ip = warp::addr::remote();
|
let real_client_ip = warp::addr::remote();
|
||||||
let accept_application_json_header = warp::header::header("Accept");
|
|
||||||
let cors = warp::cors().allow_any_origin();
|
let cors = warp::cors().allow_any_origin();
|
||||||
|
|
||||||
warp::path::end().and(
|
let relay_information_document_path = warp::path::end().and(warp::header::header("Accept").and(with_context(context.clone())).and_then(handler::relay_config)).with(&cors);
|
||||||
accept_application_json_header
|
let nostr_relay_path = warp::path::end().and(warp::ws().and(with_context(context.clone()))
|
||||||
.and_then(handler::relay_config)
|
|
||||||
.with(&cors)
|
|
||||||
.or(warp::ws()
|
|
||||||
.and(with_context(context))
|
|
||||||
.and(real_client_ip)
|
.and(real_client_ip)
|
||||||
.and_then(handler::ws_handler)
|
.and_then(handler::ws_handler)
|
||||||
.with(&cors)),
|
.with(&cors));
|
||||||
)
|
|
||||||
|
relay_information_document_path.or(nostr_relay_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn static_files() -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
|
fn static_files() -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
|
||||||
|
|
|
@ -45,7 +45,7 @@ impl Config {
|
||||||
"description": "Very *special* nostr relay",
|
"description": "Very *special* nostr relay",
|
||||||
"supported_nips": [ 1, 2, 9, 11, 12, 15, 16, 20, 22, 28, 33, 40, 45 ],
|
"supported_nips": [ 1, 2, 9, 11, 12, 15, 16, 20, 22, 28, 33, 40, 45 ],
|
||||||
"software": "git+https://git.zhitno.st/Klink/sneedstr.git",
|
"software": "git+https://git.zhitno.st/Klink/sneedstr.git",
|
||||||
"version": "0.1.0"
|
"version": "0.1.1"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue