diff --git a/crates/librqbit/src/lib.rs b/crates/librqbit/src/lib.rs index 110781d..f8543c9 100644 --- a/crates/librqbit/src/lib.rs +++ b/crates/librqbit/src/lib.rs @@ -93,10 +93,14 @@ pub use librqbit_core::torrent_metainfo::*; mod tests; /// The cargo version of librqbit. -pub fn version() -> &'static str { +pub const fn version() -> &'static str { env!("CARGO_PKG_VERSION") } +pub const fn client_name_and_version() -> &'static str { + concat!("rqbit ", env!("CARGO_PKG_VERSION")) +} + pub fn try_increase_nofile_limit() -> anyhow::Result { Ok(rlimit::increase_nofile_limit(1024 * 1024)?) } diff --git a/crates/librqbit/src/peer_connection.rs b/crates/librqbit/src/peer_connection.rs index 58db889..e39b3bf 100644 --- a/crates/librqbit/src/peer_connection.rs +++ b/crates/librqbit/src/peer_connection.rs @@ -247,6 +247,7 @@ impl PeerConnection { if supports_extended { let mut my_extended = ExtendedHandshake::new(); + my_extended.v = Some(ByteBuf(crate::client_name_and_version().as_bytes())); self.handler .update_my_extended_handshake(&mut my_extended)?; let my_extended = Message::Extended(ExtendedMessage::Handshake(my_extended));