UDP send errors now kill requests right away
This commit is contained in:
parent
e9b7103c26
commit
7da46d0bbf
3 changed files with 85 additions and 75 deletions
|
|
@ -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>),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue