Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
354 changes: 82 additions & 272 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions nostr-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@

## Unreleased

### Breaking changes

- Replace `async-wsocket` with `yawc`. Custom `WebSocketTransport` sinks and streams
now use `yawc::frame::Frame` instead of `async_wsocket::Message`; use `Frame::text`
to build frames and `Frame::opcode` to match them
- Remove the `native-tls`, `native-tls-vendored` and `rustls-tls-native-roots`
features from `nostr-sdk`, `nwc` and `nostr-connect`. `ring` and `aws_lc_rs` now
select yawc's rustls backends; `rustls-tls-webpki-roots` remains a no-op because
yawc always trusts the webpki roots

### Changed

- Use `socks5h` for proxied relay connections so the proxy resolves names, including
`.onion` addresses
- Serve the local relay listener with hyper. `LocalRelay::take_connection` is unchanged

### Added

- Add `LocalRelay::connections_left` (https://github.com/nostrdevkit/nostr/pull/1459)
Expand Down
16 changes: 8 additions & 8 deletions nostr-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@ rustdoc-args = ["--cfg", "docsrs"]

[features]
default = ["ring", "rustls-tls-webpki-roots"]
aws_lc_rs = ["async-wsocket/aws_lc_rs"]
native-tls = ["async-wsocket/native-tls"]
native-tls-vendored = ["async-wsocket/native-tls-vendored"]
ring = ["async-wsocket/ring"]
rustls-tls-native-roots = ["async-wsocket/rustls-tls-native-roots"]
rustls-tls-webpki-roots = ["async-wsocket/rustls-tls-webpki-roots"]
local-relay = ["dep:nostr-memory", "tokio/net"]
aws_lc_rs = ["yawc/rustls-aws-lc-rs"]
ring = ["yawc/rustls-ring"]
# Kept for compatibility: yawc always trusts the webpki roots, so this selects nothing.
rustls-tls-webpki-roots = []
local-relay = ["dep:hyper", "dep:hyper-util", "dep:nostr-memory", "tokio/net"]

[dependencies]
async-utility.workspace = true
async-wsocket = { version = "0.17", features = ["socks"] }
faster-hex = { workspace = true, features = ["std"] }
futures = "0.3"
hyper = { version = "1.9", features = ["server", "http1"], optional = true }
hyper-util = { version = "0.1", features = ["tokio"], optional = true }
lru.workspace = true
negentropy = { workspace = true, features = ["std"] }
nostr = { workspace = true, features = ["std", "rand", "os-rng"] }
Expand All @@ -42,6 +41,7 @@ tokio = { workspace = true, features = ["macros", "sync"] }
tokio-stream = { version = "0.1", features = ["sync"] }
tracing = { workspace = true, features = ["std"] }
universal-time = { workspace = true, features = ["std"] }
yawc = { version = "0.4", default-features = false }

[dev-dependencies]
base64 = { workspace = true, features = ["std"] }
Expand Down
15 changes: 6 additions & 9 deletions nostr-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,12 @@ More examples can be found in the [examples directory](./examples).

The following crate feature flags are available:

| Feature | Default | Description |
|---------------------------|:-------:|--------------------------------------------------|
| `ring` | Yes | Enable `ring` crypto provider |
| `rustls-tls-webpki-roots` | Yes | Enable rustls with bundled Mozilla root certs |
| `aws_lc_rs` | No | Enable `aws-lc-rs` crypto provider |
| `native-tls` | No | Enable platform-native TLS |
| `native-tls-vendored` | No | Enable platform-native TLS with vendored OpenSSL |
| `rustls-tls-native-roots` | No | Enable rustls with platform-native root certs |
| `local-relay` | No | Enable `nostr_sdk::local_relay` module |
| Feature | Default | Description |
|---------------------------|:-------:|-----------------------------------------------------|
| `ring` | Yes | Enable the `ring` crypto provider |
| `rustls-tls-webpki-roots` | Yes | Compatibility feature; webpki roots are always used |
| `aws_lc_rs` | No | Enable the `aws-lc-rs` crypto provider |
| `local-relay` | No | Enable the `nostr_sdk::local_relay` module |

## Local Relay supported NIPs

Expand Down
4 changes: 1 addition & 3 deletions nostr-sdk/examples/local-relay-hyper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ struct HttpServer {
remote: SocketAddr,
}

/// Copied from https://github.com/snapview/tungstenite-rs/blob/c16778797b2eeb118aa064aa5b483f90c3989627/src/handshake/mod.rs#L112C1-L125C1
/// Derive the `Sec-WebSocket-Accept` response header from a `Sec-WebSocket-Key` request header.
///
/// This function can be used to perform a handshake before passing a raw TCP stream to
/// [`WebSocket::from_raw_socket`][crate::protocol::WebSocket::from_raw_socket].
/// Complete the handshake before passing the upgraded stream to [`LocalRelay::take_connection`].
pub fn derive_accept_key(request_key: &[u8]) -> String {
// ... field is constructed by concatenating /key/ ...
// ... with the string "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" (RFC 6455)
Expand Down
4 changes: 2 additions & 2 deletions nostr-sdk/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use std::error;

use nostr::types::RelayUrl;
use yawc::WebSocketError;

opaquerr::define_kind! {
/// SDK error kind.
Expand Down Expand Up @@ -53,8 +54,7 @@ opaquerr::define_error! {
nostr_gossip::error::Error => ErrorKind::Gossip,
faster_hex::Error => ErrorKind::Protocol,
negentropy::Error => ErrorKind::Protocol,
#[cfg(any(feature = "local-relay", test))]
async_wsocket::Error => ErrorKind::Other,
WebSocketError => ErrorKind::Transport,
tokio::sync::oneshot::error::RecvError => ErrorKind::Other,
tokio::sync::broadcast::error::RecvError => ErrorKind::Other,
#[cfg(any(feature = "local-relay", test))]
Expand Down
Loading