From b4228aa74f6ef4720167236cb072b84d94aa6d2a Mon Sep 17 00:00:00 2001 From: murilo ijanc Date: Fri, 27 Mar 2026 21:54:25 -0300 Subject: Add chunked paste support for content up to 1.44 MB Large pastes are split into 8 KiB chunks on the client side, each stored separately in a dedicated chunks/ directory. A version-2 manifest paste lists the chunk hashes and is announced to the DHT; chunks replicate via periodic republish with per-put throttling to avoid rate-limit bans. - New PUTC/PUTM protocol commands for chunks and manifests - Client-side chunking avoids O(n^2) base58 on large content - HTTP handler reassembles chunks directly from store - DHT sync routes incoming chunks to chunks/ directory - Republish interval reduced to 5 min with 200ms throttle - tp.1 updated with new 1.44 MB limit --- src/protocol.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/protocol.rs') diff --git a/src/protocol.rs b/src/protocol.rs index d45cdd8..cb90f5b 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -3,6 +3,8 @@ //! Simple line-oriented text protocol: //! PUT \n //! PUTP \n +//! PUTC \n (store chunk) +//! PUTM \n (store manifest) //! GET \n //! DEL \n //! PIN \n @@ -21,6 +23,14 @@ pub enum Request { content_b58: String, encrypt: bool, }, + PutChunk { + ttl_secs: u64, + content_b58: String, + }, + PutManifest { + ttl_secs: u64, + content_b58: String, + }, Get { key: String, }, @@ -67,6 +77,30 @@ pub fn parse_request(line: &str) -> Result { encrypt: cmd == "PUT", }) } + "PUTC" => { + let ttl_str = + parts.next().ok_or("PUTC requires: PUTC ")?; + let content_b58 = + parts.next().ok_or("PUTC requires: PUTC ")?; + let ttl_secs: u64 = + ttl_str.parse().map_err(|_| "invalid TTL number")?; + Ok(Request::PutChunk { + ttl_secs, + content_b58: content_b58.to_string(), + }) + } + "PUTM" => { + let ttl_str = + parts.next().ok_or("PUTM requires: PUTM ")?; + let content_b58 = + parts.next().ok_or("PUTM requires: PUTM ")?; + let ttl_secs: u64 = + ttl_str.parse().map_err(|_| "invalid TTL number")?; + Ok(Request::PutManifest { + ttl_secs, + content_b58: content_b58.to_string(), + }) + } "GET" => { let key = parts.next().ok_or("GET requires: GET ")?; Ok(Request::Get { -- cgit v1.2.3