UDP send errors now kill requests right away

This commit is contained in:
Igor Katson 2023-11-28 11:31:34 +00:00
parent e9b7103c26
commit 7da46d0bbf
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
3 changed files with 85 additions and 75 deletions

View file

@ -4,7 +4,7 @@ use std::{
net::{Ipv4Addr, SocketAddrV4},
};
use bencode::ByteBuf;
use bencode::{ByteBuf, ByteString};
use clone_to_owned::CloneToOwned;
use librqbit_core::id20::Id20;
use serde::{
@ -332,6 +332,16 @@ pub struct Message<BufT> {
pub kind: MessageKind<BufT>,
}
impl Message<ByteString> {
pub fn get_transaction_id(&self) -> Option<u16> {
if self.transaction_id.len() != 2 {
return None;
}
let tid = ((self.transaction_id[0] as u16) << 8) + (self.transaction_id[1] as u16);
Some(tid)
}
}
#[derive(Debug)]
pub enum MessageKind<BufT> {
Error(ErrorDescription<BufT>),