feat: add non-blocking NTCP2 sends and Firefox settings sync
- NTCP2: queue outbound data frames and flush them without blocking (send_blocks_nb, send_i2np_nb, flush_nonblocking) - NTCP2: bound write_all with a deadline and set TCP keepalive and user timeout on peer sockets - Firefox extension 0.1.3: save settings as a patch, keep unsaved form fields from being overwritten on refresh, add timeouts to router API calls, and honor the interceptTorrents toggle in the content script
This commit is contained in:
1 parent
82aaa9f11e
commit
9aa15f9ae8
18 files changed
+1323
-239
No files matched your search
+35
-3
@@ -248,12 +248,44 @@ fn api_send_response(
|
||||
}
|
||||
sb.write_string("Connection: close\r\n\r\n")
|
||||
let hdr_bytes = @encoding.string_to_utf8_bytes(sb.to_string())
|
||||
let _ = sock.write_all(hdr_bytes) catch { _ => () }
|
||||
let _ = sock.write_all(hdr_bytes, timeout_ms=500) catch { _ => () }
|
||||
if body_bytes.length() > 0 {
|
||||
let _ = sock.write_all(body_bytes) catch { _ => () }
|
||||
let _ = sock.write_all(body_bytes, timeout_ms=500) catch { _ => () }
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
/// Decodes standard (`+`/`/`), URL-safe (`-`/`_`), or I2P (`-`/`~`) Base64 strings,
|
||||
/// restoring omitted trailing `=` padding when needed.
|
||||
fn api_decode_base64_flexible(
|
||||
b64 : String,
|
||||
) -> Bytes raise @encoding.EncodingError {
|
||||
let sb = StringBuilder()
|
||||
let mut len = 0
|
||||
for ch in b64 {
|
||||
if ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r' {
|
||||
continue
|
||||
}
|
||||
let mapped = match ch {
|
||||
'+' => '-'
|
||||
'/' => '~'
|
||||
'_' => '~'
|
||||
_ => ch
|
||||
}
|
||||
sb.write_char(mapped)
|
||||
len += 1
|
||||
}
|
||||
if len > 0 {
|
||||
let rem = len % 4
|
||||
if rem == 2 {
|
||||
sb.write_string("==")
|
||||
} else if rem == 3 {
|
||||
sb.write_char('=')
|
||||
}
|
||||
}
|
||||
@encoding.base64_decode(sb.to_string())
|
||||
}
|
||||
|
||||
///|
|
||||
fn api_router_err_msg(e : RouterError) -> String {
|
||||
match e {
|
||||
@@ -641,7 +673,7 @@ fn Router::dispatch_torrent_api_request(
|
||||
(body.length() > 0 && body[0] == b'{') {
|
||||
match api_json_get_string(body_str, "torrent_b64") {
|
||||
Some(b64) =>
|
||||
@encoding.base64_decode(b64) catch {
|
||||
api_decode_base64_flexible(b64) catch {
|
||||
_ => {
|
||||
api_send_response(
|
||||
ac.sock,
|
||||
|
||||
Reference in new issue
Block a user