mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 19:46:50 +00:00
NIP-05 fetch to have no redirects
This commit is contained in:
parent
ac79ab3c6b
commit
d9cf30dc7a
@ -147,14 +147,16 @@ fn parse_dns_id(dns_id: &str) -> Result<(String, String), Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn fetch_nip05(user: &str, domain: &str) -> Result<Nip05, Error> {
|
async fn fetch_nip05(user: &str, domain: &str) -> Result<Nip05, Error> {
|
||||||
let nip05_future = reqwest::Client::new()
|
let nip05_future = reqwest::Client::builder()
|
||||||
|
.timeout(std::time::Duration::new(60, 0))
|
||||||
|
.redirect(reqwest::redirect::Policy::none()) // see NIP-05
|
||||||
|
.build()?
|
||||||
.get(format!(
|
.get(format!(
|
||||||
"https://{}/.well-known/nostr.json?name={}",
|
"https://{}/.well-known/nostr.json?name={}",
|
||||||
domain, user
|
domain, user
|
||||||
))
|
))
|
||||||
.header("Host", domain)
|
.header("Host", domain)
|
||||||
.send();
|
.send();
|
||||||
let timeout_future = tokio::time::timeout(std::time::Duration::new(15, 0), nip05_future);
|
let response = nip05_future.await?;
|
||||||
let response = timeout_future.await??;
|
|
||||||
Ok(response.json::<Nip05>().await?)
|
Ok(response.json::<Nip05>().await?)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user