mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2025-09-01 11:40:48 -04:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
8a8ee5c425 | ||
|
55bb6bd440 | ||
|
7933abaa48 |
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -435,7 +435,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr-rs-relay"
|
name = "nostr-rs-relay"
|
||||||
version = "0.1.4"
|
version = "0.1.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitcoin_hashes",
|
"bitcoin_hashes",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "nostr-rs-relay"
|
name = "nostr-rs-relay"
|
||||||
version = "0.1.4"
|
version = "0.1.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@@ -53,7 +53,7 @@ impl ClientConn {
|
|||||||
v.push(id);
|
v.push(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return v;
|
v
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a new subscription for this connection.
|
/// Add a new subscription for this connection.
|
||||||
|
10
src/main.rs
10
src/main.rs
@@ -18,6 +18,7 @@ use tokio::sync::broadcast;
|
|||||||
use tokio::sync::broadcast::{Receiver, Sender};
|
use tokio::sync::broadcast::{Receiver, Sender};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use tokio::sync::oneshot;
|
use tokio::sync::oneshot;
|
||||||
|
use tungstenite::protocol::WebSocketConfig;
|
||||||
|
|
||||||
/// Start running a Nostr relay server.
|
/// Start running a Nostr relay server.
|
||||||
fn main() -> Result<(), Error> {
|
fn main() -> Result<(), Error> {
|
||||||
@@ -93,8 +94,15 @@ async fn nostr_server(
|
|||||||
) {
|
) {
|
||||||
// get a broadcast channel for clients to communicate on
|
// get a broadcast channel for clients to communicate on
|
||||||
let mut bcast_rx = broadcast.subscribe();
|
let mut bcast_rx = broadcast.subscribe();
|
||||||
|
// websocket configuration / limits
|
||||||
|
let config = WebSocketConfig {
|
||||||
|
max_send_queue: None,
|
||||||
|
max_message_size: Some(2 << 19), // 512K
|
||||||
|
max_frame_size: Some(2 << 19), // 512k
|
||||||
|
accept_unmasked_frames: false, // follow the spec
|
||||||
|
};
|
||||||
// upgrade the TCP connection to WebSocket
|
// upgrade the TCP connection to WebSocket
|
||||||
let conn = tokio_tungstenite::accept_async(stream).await;
|
let conn = tokio_tungstenite::accept_async_with_config(stream, Some(config)).await;
|
||||||
let ws_stream = conn.expect("websocket handshake error");
|
let ws_stream = conn.expect("websocket handshake error");
|
||||||
// wrap websocket into a stream & sink of Nostr protocol messages
|
// wrap websocket into a stream & sink of Nostr protocol messages
|
||||||
let mut nostr_stream = protostream::wrap_ws_in_nostr(ws_stream);
|
let mut nostr_stream = protostream::wrap_ws_in_nostr(ws_stream);
|
||||||
|
@@ -16,7 +16,6 @@ pub struct Subscription {
|
|||||||
/// element can be present if it should be used in filtering, or
|
/// element can be present if it should be used in filtering, or
|
||||||
/// absent ([`None`]) if it should be ignored.
|
/// absent ([`None`]) if it should be ignored.
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||||
#[serde(deny_unknown_fields)]
|
|
||||||
pub struct ReqFilter {
|
pub struct ReqFilter {
|
||||||
/// Event hash
|
/// Event hash
|
||||||
pub id: Option<String>,
|
pub id: Option<String>,
|
||||||
|
Reference in New Issue
Block a user