feat: add Android APK with embedded I2P browser and torrent manager
- Add an Android app (org.mooni2p.browser) with an I2P WebView browser defaulting to insulaocculta.i2p, bookmarks, and a diagnostics dialog. - Run the router in a foreground service and add a Torrents & DHT tab backed by the router API (manager.html). - Handle magnet links and .torrent files from intents, the file picker, and .i2p downloads. - Add scripts/build_apk.py and a `just apk` target that builds arm64-v8a and x86_64 APKs. - Document the APK build and install steps in the README. - Include related bittorrent, router, streaming, and ntcp2_net updates.
This commit is contained in:
1 parent
fbe6818c4e
commit
7a1b4325f9
16 files changed
+3041
-78
No files matched your search
@@ -119,6 +119,11 @@ test "Peer wire framing, BEP 10/9, i2p_pex, i2p_dht, and chunked I2P HTTP tracke
|
||||
Bitfield(b"\x80"),
|
||||
Request(1, 0, 16384),
|
||||
Piece(1, 0, b"payload-bytes"),
|
||||
SuggestPiece(3U),
|
||||
HaveAll,
|
||||
HaveNone,
|
||||
RejectRequest(2, 16384, 16384),
|
||||
AllowedFast(5U),
|
||||
Extended(b'\x00', @bittorrent.encode_ext_handshake(metadata_size=Some(512))),
|
||||
Extended(b'\x03', @bittorrent.encode_i2p_dht_ext(6881U, 6882U)),
|
||||
]
|
||||
@@ -141,6 +146,7 @@ test "Peer wire framing, BEP 10/9, i2p_pex, i2p_dht, and chunked I2P HTTP tracke
|
||||
assert_eq(rext.ut_metadata_id, Some(b'\x02'))
|
||||
assert_eq(rext.i2p_dht_id, Some(b'\x03'))
|
||||
assert_eq(rext.metadata_size, Some(512))
|
||||
assert_eq(rext.client_name, "moon-i2p/0.1")
|
||||
assert_eq(
|
||||
@bittorrent.decode_i2p_dht_ext(@bittorrent.encode_i2p_dht_ext(6881U, 6882U)),
|
||||
Some((6881U, 6882U)),
|
||||
|
||||
@@ -213,6 +213,11 @@ pub(all) enum PeerMessage {
|
||||
Request(Int32, Int32, Int32)
|
||||
Piece(Int32, Int32, Bytes)
|
||||
Cancel(Int32, Int32, Int32)
|
||||
SuggestPiece(UInt32)
|
||||
HaveAll
|
||||
HaveNone
|
||||
RejectRequest(Int32, Int32, Int32)
|
||||
AllowedFast(UInt32)
|
||||
Extended(Byte, Bytes)
|
||||
}
|
||||
|
||||
@@ -222,6 +227,7 @@ pub(all) struct RemoteExtensions {
|
||||
mut i2p_pex_id : Byte?
|
||||
mut i2p_dht_id : Byte?
|
||||
mut metadata_size : Int32?
|
||||
mut client_name : String
|
||||
}
|
||||
|
||||
#derive(Eq, @debug.Debug)
|
||||
|
||||
@@ -65,6 +65,11 @@ pub(all) enum PeerMessage {
|
||||
Request(Int32, Int32, Int32)
|
||||
Piece(Int32, Int32, Bytes)
|
||||
Cancel(Int32, Int32, Int32)
|
||||
SuggestPiece(UInt32)
|
||||
HaveAll
|
||||
HaveNone
|
||||
RejectRequest(Int32, Int32, Int32)
|
||||
AllowedFast(UInt32)
|
||||
Extended(Byte, Bytes)
|
||||
}
|
||||
|
||||
@@ -121,6 +126,31 @@ pub fn encode_peer_message(msg : PeerMessage) -> Bytes {
|
||||
w.write_u32_be(begin.reinterpret_as_uint())
|
||||
w.write_u32_be(len.reinterpret_as_uint())
|
||||
}
|
||||
SuggestPiece(idx) => {
|
||||
w.write_u32_be(5U)
|
||||
w.write_u8(b'\x0d')
|
||||
w.write_u32_be(idx)
|
||||
}
|
||||
HaveAll => {
|
||||
w.write_u32_be(1U)
|
||||
w.write_u8(b'\x0e')
|
||||
}
|
||||
HaveNone => {
|
||||
w.write_u32_be(1U)
|
||||
w.write_u8(b'\x0f')
|
||||
}
|
||||
RejectRequest(idx, begin, len) => {
|
||||
w.write_u32_be(13U)
|
||||
w.write_u8(b'\x10')
|
||||
w.write_u32_be(idx.reinterpret_as_uint())
|
||||
w.write_u32_be(begin.reinterpret_as_uint())
|
||||
w.write_u32_be(len.reinterpret_as_uint())
|
||||
}
|
||||
AllowedFast(idx) => {
|
||||
w.write_u32_be(5U)
|
||||
w.write_u8(b'\x11')
|
||||
w.write_u32_be(idx)
|
||||
}
|
||||
Extended(ext_id, payload) => {
|
||||
w.write_u32_be((2 + payload.length()).reinterpret_as_uint())
|
||||
w.write_u8(b'\x14')
|
||||
@@ -205,6 +235,22 @@ pub fn try_decode_peer_message(buf : Array[Byte]) -> PeerMessage? raise BtError
|
||||
let len = (r.read_u32_be() catch { e => raise Encoding(e) }).reinterpret_as_int()
|
||||
Some(Cancel(idx, begin, len))
|
||||
}
|
||||
b'\x0d' => {
|
||||
let idx = r.read_u32_be() catch { e => raise Encoding(e) }
|
||||
Some(SuggestPiece(idx))
|
||||
}
|
||||
b'\x0e' => Some(HaveAll)
|
||||
b'\x0f' => Some(HaveNone)
|
||||
b'\x10' => {
|
||||
let idx = (r.read_u32_be() catch { e => raise Encoding(e) }).reinterpret_as_int()
|
||||
let begin = (r.read_u32_be() catch { e => raise Encoding(e) }).reinterpret_as_int()
|
||||
let len = (r.read_u32_be() catch { e => raise Encoding(e) }).reinterpret_as_int()
|
||||
Some(RejectRequest(idx, begin, len))
|
||||
}
|
||||
b'\x11' => {
|
||||
let idx = r.read_u32_be() catch { e => raise Encoding(e) }
|
||||
Some(AllowedFast(idx))
|
||||
}
|
||||
b'\x14' => {
|
||||
let ext_id = r.read_u8() catch { e => raise Encoding(e) }
|
||||
Some(Extended(ext_id, r.read_remaining()))
|
||||
@@ -220,6 +266,7 @@ pub(all) struct RemoteExtensions {
|
||||
mut i2p_pex_id : Byte?
|
||||
mut i2p_dht_id : Byte?
|
||||
mut metadata_size : Int32?
|
||||
mut client_name : String
|
||||
}
|
||||
|
||||
///|
|
||||
@@ -252,6 +299,7 @@ pub fn decode_ext_handshake(payload : Bytes) -> RemoteExtensions raise BtError {
|
||||
i2p_pex_id: None,
|
||||
i2p_dht_id: None,
|
||||
metadata_size: None,
|
||||
client_name: "",
|
||||
}
|
||||
match bdict_get(d, "m") {
|
||||
Some(m) => {
|
||||
@@ -275,6 +323,10 @@ pub fn decode_ext_handshake(payload : Bytes) -> RemoteExtensions raise BtError {
|
||||
res.metadata_size = Some(sz.to_int())
|
||||
_ => ()
|
||||
}
|
||||
match bdict_get_string(d, "v") {
|
||||
Some(v) => res.client_name = v
|
||||
None => ()
|
||||
}
|
||||
res
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user