aboutsummaryrefslogtreecommitdiffstats
path: root/src/protocol.rs
diff options
context:
space:
mode:
authormurilo ijanc2026-03-27 21:54:25 -0300
committermurilo ijanc2026-03-27 21:54:25 -0300
commitb4228aa74f6ef4720167236cb072b84d94aa6d2a (patch)
tree5a43a68455a06009d0c288e786a4bc000a406a8c /src/protocol.rs
parent75fddf425102369828f7e8366ebdad4ea086fd07 (diff)
downloadtesseras-paste-b4228aa74f6ef4720167236cb072b84d94aa6d2a.tar.gz
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
Diffstat (limited to 'src/protocol.rs')
-rw-r--r--src/protocol.rs34
1 files changed, 34 insertions, 0 deletions
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 <ttl_secs> <content>\n
//! PUTP <ttl_secs> <content>\n
+//! PUTC <ttl_secs> <content>\n (store chunk)
+//! PUTM <ttl_secs> <content>\n (store manifest)
//! GET <key>\n
//! DEL <key>\n
//! PIN <key>\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<Request, String> {
encrypt: cmd == "PUT",
})
}
+ "PUTC" => {
+ let ttl_str =
+ parts.next().ok_or("PUTC requires: PUTC <ttl> <data>")?;
+ let content_b58 =
+ parts.next().ok_or("PUTC requires: PUTC <ttl> <data>")?;
+ 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 <ttl> <data>")?;
+ let content_b58 =
+ parts.next().ok_or("PUTM requires: PUTM <ttl> <data>")?;
+ 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 <key>")?;
Ok(Request::Get {