Send client name in extended handshake

This commit is contained in:
Igor Katson 2024-08-29 13:08:55 +01:00
parent bafd958d0d
commit 1d48a5198b
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
2 changed files with 6 additions and 1 deletions

View file

@ -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<u64> {
Ok(rlimit::increase_nofile_limit(1024 * 1024)?)
}

View file

@ -247,6 +247,7 @@ impl<H: PeerConnectionHandler> PeerConnection<H> {
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));