Merge pull request #11 from scsibug/master

Fork Sync: Update from parent repository
This commit is contained in:
github-actions[bot] 2023-09-05 02:07:55 +00:00 committed by GitHub
commit b20a5397a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 303 additions and 304 deletions

558
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
[package]
name = "nostr-rs-relay"
version = "0.8.12"
version = "0.8.13"
edition = "2021"
authors = ["Greg Heartsfield <scsibug@imap.cc>"]
description = "A relay implementation for the Nostr protocol"
@ -39,7 +39,7 @@ lazy_static = "1.4"
governor = "0.4"
nonzero_ext = "0.3"
hyper = { version="0.14", features=["client", "server","http1","http2","tcp"] }
hyper-tls = "0.5"
hyper-rustls = { version = "0.24" }
http = { version = "0.2" }
parse_duration = "2"
rand = "0.8"

View File

@ -355,7 +355,7 @@ impl Event {
return Err(EventInvalidId);
}
// * validate the message digest (sig) using the pubkey & computed sha256 message hash.
let sig = schnorr::Signature::from_str(&self.sig).unwrap();
let sig = schnorr::Signature::from_str(&self.sig).map_err(|_| EventInvalidSignature)?;
if let Ok(msg) = secp256k1::Message::from_slice(digest.as_ref()) {
if let Ok(pubkey) = XOnlyPublicKey::from_str(&self.pubkey) {
SECP.verify_schnorr(&sig, &msg, &pubkey)

View File

@ -11,7 +11,7 @@ use crate::repo::NostrRepo;
use hyper::body::HttpBody;
use hyper::client::connect::HttpConnector;
use hyper::Client;
use hyper_tls::HttpsConnector;
use hyper_rustls::HttpsConnector;
use std::sync::Arc;
use std::time::Duration;
use std::time::Instant;
@ -133,7 +133,12 @@ impl Verifier {
) -> Result<Self> {
info!("creating NIP-05 verifier");
// setup hyper client
let https = HttpsConnector::new();
let https = hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()
.https_or_http()
.enable_http1()
.build();
let client = Client::builder().build::<_, hyper::Body>(https);
// After all accounts have been re-verified, don't check again

View File

@ -2,7 +2,7 @@
use http::Uri;
use hyper::client::connect::HttpConnector;
use hyper::Client;
use hyper_tls::HttpsConnector;
use hyper_rustls::HttpsConnector;
use nostr::Keys;
use serde::{Deserialize, Serialize};
use serde_json::Value;
@ -72,7 +72,11 @@ pub struct LNBitsPaymentProcessor {
impl LNBitsPaymentProcessor {
pub fn new(settings: &Settings) -> Self {
// setup hyper client
let https = HttpsConnector::new();
let https = hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()
.https_only()
.enable_http1()
.build();
let client = Client::builder().build::<_, hyper::Body>(https);
Self {

View File

@ -52,7 +52,7 @@ mod tests {
let challenge = client_conn.auth_challenge().unwrap();
let event = auth_event(challenge);
let result = client_conn.authenticate(&event, &RELAY.into());
let result = client_conn.authenticate(&event, RELAY.into());
assert!(matches!(result, Ok(())));
assert_eq!(client_conn.auth_challenge(), None);
@ -67,7 +67,7 @@ mod tests {
assert_eq!(client_conn.auth_pubkey(), None);
let event = auth_event(&"challenge".into());
let result = client_conn.authenticate(&event, &RELAY.into());
let result = client_conn.authenticate(&event, RELAY.into());
assert!(matches!(result, Err(Error::AuthFailure)));
}
@ -87,14 +87,14 @@ mod tests {
let challenge = client_conn.auth_challenge().unwrap().clone();
let event = auth_event(&challenge);
let result = client_conn.authenticate(&event, &RELAY.into());
let result = client_conn.authenticate(&event, RELAY.into());
assert!(matches!(result, Ok(())));
assert_eq!(client_conn.auth_challenge(), None);
assert_eq!(client_conn.auth_pubkey(), Some(&event.pubkey));
let event1 = auth_event(&challenge);
let result1 = client_conn.authenticate(&event1, &RELAY.into());
let result1 = client_conn.authenticate(&event1, RELAY.into());
assert!(matches!(result1, Ok(())));
assert_eq!(client_conn.auth_challenge(), None);
@ -118,7 +118,7 @@ mod tests {
let mut event = auth_event(challenge);
event.sig = event.sig.chars().rev().collect::<String>();
let result = client_conn.authenticate(&event, &RELAY.into());
let result = client_conn.authenticate(&event, RELAY.into());
assert!(matches!(result, Err(Error::AuthFailure)));
}
@ -138,7 +138,7 @@ mod tests {
let challenge = client_conn.auth_challenge().unwrap();
let event = auth_event_with_kind(challenge, 9999999999999999);
let result = client_conn.authenticate(&event, &RELAY.into());
let result = client_conn.authenticate(&event, RELAY.into());
assert!(matches!(result, Err(Error::AuthFailure)));
}
@ -158,7 +158,7 @@ mod tests {
let challenge = client_conn.auth_challenge().unwrap();
let event = auth_event_with_created_at(challenge, unix_time() - 1200); // 20 minutes
let result = client_conn.authenticate(&event, &RELAY.into());
let result = client_conn.authenticate(&event, RELAY.into());
assert!(matches!(result, Err(Error::AuthFailure)));
}
@ -178,7 +178,7 @@ mod tests {
let challenge = client_conn.auth_challenge().unwrap();
let event = auth_event_with_created_at(challenge, unix_time() + 1200); // 20 minutes
let result = client_conn.authenticate(&event, &RELAY.into());
let result = client_conn.authenticate(&event, RELAY.into());
assert!(matches!(result, Err(Error::AuthFailure)));
}
@ -197,7 +197,7 @@ mod tests {
let event = auth_event_without_tags();
let result = client_conn.authenticate(&event, &RELAY.into());
let result = client_conn.authenticate(&event, RELAY.into());
assert!(matches!(result, Err(Error::AuthFailure)));
}
@ -216,7 +216,7 @@ mod tests {
let event = auth_event_without_challenge();
let result = client_conn.authenticate(&event, &RELAY.into());
let result = client_conn.authenticate(&event, RELAY.into());
assert!(matches!(result, Err(Error::AuthFailure)));
}
@ -236,7 +236,7 @@ mod tests {
let challenge = client_conn.auth_challenge().unwrap();
let event = auth_event_without_relay(challenge);
let result = client_conn.authenticate(&event, &RELAY.into());
let result = client_conn.authenticate(&event, RELAY.into());
assert!(matches!(result, Err(Error::AuthFailure)));
}
@ -255,7 +255,7 @@ mod tests {
let event = auth_event(&"invalid challenge".into());
let result = client_conn.authenticate(&event, &RELAY.into());
let result = client_conn.authenticate(&event, RELAY.into());
assert!(matches!(result, Err(Error::AuthFailure)));
}
@ -275,7 +275,7 @@ mod tests {
let challenge = client_conn.auth_challenge().unwrap();
let event = auth_event_with_relay(challenge, &"xyz".into());
let result = client_conn.authenticate(&event, &RELAY.into());
let result = client_conn.authenticate(&event, RELAY.into());
assert!(matches!(result, Err(Error::AuthFailure)));
}