diff --git a/crates/librqbit/src/peer_connection.rs b/crates/librqbit/src/peer_connection.rs index aec95640..9f99f0d0 100644 --- a/crates/librqbit/src/peer_connection.rs +++ b/crates/librqbit/src/peer_connection.rs @@ -14,7 +14,7 @@ use librqbit_core::{ }; use parking_lot::RwLock; use peer_binary_protocol::{ - extended::{handshake::ExtendedHandshake, ExtendedMessage}, + extended::{handshake::{ExtendedHandshake, YourIP}, ExtendedMessage}, serialize_piece_preamble, Handshake, Message, MessageOwned, PIECE_MESSAGE_DEFAULT_LEN, }; use serde::{Deserialize, Serialize}; @@ -245,7 +245,9 @@ impl PeerConnection { let supports_extended = handshake_supports_extended; if supports_extended { + let your_ip = self.addr.ip(); let mut my_extended = ExtendedHandshake::new(); + my_extended.yourip = Some(YourIP(your_ip)); self.handler .update_my_extended_handshake(&mut my_extended)?; let my_extended = Message::Extended(ExtendedMessage::Handshake(my_extended)); diff --git a/crates/peer_binary_protocol/src/extended/handshake.rs b/crates/peer_binary_protocol/src/extended/handshake.rs index 2a438bc6..3b1a3d5e 100644 --- a/crates/peer_binary_protocol/src/extended/handshake.rs +++ b/crates/peer_binary_protocol/src/extended/handshake.rs @@ -96,7 +96,10 @@ impl Serialize for YourIP { let buf = ipv4.octets(); serializer.serialize_bytes(&buf) } - IpAddr::V6(_) => todo!(), + IpAddr::V6(ipv6) => { + let buf = ipv6.octets(); + serializer.serialize_bytes(&buf) + }, } } }