feat: add ratchet, streaming, SU3 reseed, and router floodfill
- Add ratchet/ with ECIES-X25519-AEAD-Ratchet (Proposal 144), Garlic cloves, and ECIES DatabaseLookup replies - Add streaming/ with Ed25519-signed I2P Streaming (SYN/ACK/NACK/CLOSE/RESET, retransmit, window) and Repliable/Raw Datagrams - Add common/su3.mbt to parse and verify reseed .su3 bundles - Add Elligator2 encoding in crypto/ and OfflineSignature support in LeaseSet2 (flags bit 0) - Router: NTCP2 peer pool, floodfill NetDB crawl, transit tunnel relay, and Garlic/Streaming bridge - cmd/router: add --peer-dir, --su3, --reseed, --floodfill, --no-clock-skew - cmd/client: add --dest for persistent destination keys - Mark Phase 6 complete in README and document the transport scope (NTCP2 only, no SSU2)
This commit is contained in:
1 parent
8eafa11b22
commit
ae72b00323
54 files changed
+9607
-704
No files matched your search
@@ -47,12 +47,74 @@ extern "C" fn c_read_stdin(buf : FixedArray[Byte], max_len : Int32) -> Int32 = "
|
||||
///|
|
||||
extern "C" fn c_flush_stdout() -> Unit = "moon_i2p_flush_stdout"
|
||||
|
||||
///|
|
||||
#borrow(path)
|
||||
extern "C" fn c_file_size(path : Bytes, path_len : Int32) -> Int32 = "moon_i2p_file_size"
|
||||
|
||||
///|
|
||||
#borrow(path, dst)
|
||||
extern "C" fn c_read_file(
|
||||
path : Bytes,
|
||||
path_len : Int32,
|
||||
dst : FixedArray[Byte],
|
||||
max_len : Int32,
|
||||
) -> Int32 = "moon_i2p_read_file"
|
||||
|
||||
///|
|
||||
/// Flushes standard output (useful before blocking on `stream_accept`).
|
||||
pub fn flush_stdout() -> Unit {
|
||||
c_flush_stdout()
|
||||
}
|
||||
|
||||
///|
|
||||
/// Returns `true` if `path` exists as a regular file.
|
||||
pub fn file_exists(path : String) -> Bool {
|
||||
let pb = @encoding.string_to_utf8_bytes(path)
|
||||
c_file_size(pb, pb.length()) >= 0
|
||||
}
|
||||
|
||||
///|
|
||||
/// Reads a UTF-8 text file and strips leading/trailing ASCII whitespace.
|
||||
pub fn read_trimmed_text_file(path : String) -> String raise SamClientError {
|
||||
let pb = @encoding.string_to_utf8_bytes(path)
|
||||
let sz = c_file_size(pb, pb.length())
|
||||
if sz < 0 {
|
||||
raise IoError("failed to stat '\{path}': \{last_os_error()}")
|
||||
}
|
||||
let bytes = if sz == 0 {
|
||||
b""
|
||||
} else {
|
||||
let buf = FixedArray::make(sz, b'\x00')
|
||||
let n = c_read_file(pb, pb.length(), buf, sz)
|
||||
if n < 0 {
|
||||
raise IoError("failed to read '\{path}': \{last_os_error()}")
|
||||
}
|
||||
Bytes::from_array(buf)[:n].to_owned()
|
||||
}
|
||||
let text = @encoding.utf8_bytes_to_string(bytes) catch {
|
||||
_ => raise IoError("invalid UTF-8 in '\{path}'")
|
||||
}
|
||||
let mut start = 0
|
||||
let mut end = text.length()
|
||||
while start < end {
|
||||
let c = text[start].to_int()
|
||||
if c == 32 || c == 9 || c == 13 || c == 10 {
|
||||
start += 1
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
while end > start {
|
||||
let c = text[end - 1].to_int()
|
||||
if c == 32 || c == 9 || c == 13 || c == 10 {
|
||||
end -= 1
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
text[start:end].to_owned()
|
||||
}
|
||||
|
||||
///|
|
||||
fn last_os_error() -> String {
|
||||
let n = c_last_error_len()
|
||||
|
||||
Reference in new issue
Block a user