Merge pull request #72 from jabedude/bep52-magnet-support

Add support for BTv2 magnet links
This commit is contained in:
Igor Katson 2024-01-08 11:27:27 +00:00 committed by GitHub
commit c8189de3d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 236 additions and 157 deletions

View file

@ -6,7 +6,7 @@ use std::{
use anyhow::{bail, Context};
use buffers::{ByteBuf, ByteString};
use clone_to_owned::CloneToOwned;
use librqbit_core::{id20::Id20, lengths::ChunkInfo, peer_id::try_decode_peer_id};
use librqbit_core::{hash_id::Id20, lengths::ChunkInfo, peer_id::try_decode_peer_id};
use parking_lot::RwLock;
use peer_binary_protocol::{
extended::{handshake::ExtendedHandshake, ExtendedMessage},
@ -120,7 +120,7 @@ impl<H: PeerConnectionHandler> PeerConnection<H> {
trace!(
"incoming connection: id={:?}",
try_decode_peer_id(Id20(handshake.peer_id))
try_decode_peer_id(Id20::new(handshake.peer_id))
);
let mut write_buf = Vec::<u8>::with_capacity(PIECE_MESSAGE_DEFAULT_LEN);
@ -181,7 +181,7 @@ impl<H: PeerConnectionHandler> PeerConnection<H> {
.await
.context("error reading handshake")?;
let h_supports_extended = h.supports_extended();
trace!("connected: id={:?}", try_decode_peer_id(Id20(h.peer_id)));
trace!("connected: id={:?}", try_decode_peer_id(Id20::new(h.peer_id)));
if h.info_hash != self.info_hash.0 {
anyhow::bail!("info hash does not match");
}