nostr-rs-relay

My dev fork of nostr-rs-relay
git clone git://jb55.com/nostr-rs-relay
Log | Files | Refs | README | LICENSE

commit 79a982e3efb63e372a0c743313fb6ebd1f11b5de
parent 01d81db617f0122502c397bdb59dc0783735ff22
Author: Greg Heartsfield <scsibug@imap.cc>
Date:   Sun, 21 Aug 2022 09:28:31 -0700

improvement: send NOTICE for too-large messages

Diffstat:
Msrc/main.rs | 5+++++
1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -34,6 +34,7 @@ use tokio::sync::broadcast::{self, Receiver, Sender}; use tokio::sync::mpsc; use tokio::sync::oneshot; use tokio_tungstenite::WebSocketStream; +use tungstenite::error::CapacityError::MessageTooLong; use tungstenite::error::Error as WsError; use tungstenite::handshake; use tungstenite::protocol::Message; @@ -476,6 +477,10 @@ async fn nostr_server( // send responses automatically. continue; }, + Some(Err(WsError::Capacity(MessageTooLong{size, max_size}))) => { + ws_stream.send(make_notice_message(&format!("message too large ({} > {})",size, max_size))).await.ok(); + continue; + }, None | Some(Ok(Message::Close(_))) | Some(Err(WsError::AlreadyClosed)) |