From 4b5a10db9589d2270d12946c98d3cd8e4f97c530 Mon Sep 17 00:00:00 2001 From: EAimTY Date: Tue, 30 May 2023 19:39:11 +0900 Subject: [PATCH] adding methods for getting packet source --- tuic-quinn/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tuic-quinn/src/lib.rs b/tuic-quinn/src/lib.rs index a7e626a..d606b1f 100644 --- a/tuic-quinn/src/lib.rs +++ b/tuic-quinn/src/lib.rs @@ -505,6 +505,16 @@ impl Packet { self.model.frag_total() } + /// Whether the packet is from UDP relay mode `quic` + pub fn is_from_quic(&self) -> bool { + matches!(self.src, PacketSource::Quic(_)) + } + + /// Whether the packet is from UDP relay mode `native` + pub fn is_from_native(&self) -> bool { + matches!(self.src, PacketSource::Native(_)) + } + /// Accepts the packet payload. If the packet is fragmented and not yet fully assembled, `Ok(None)` is returned. pub async fn accept(self) -> Result, Error> { let pkt = match self.src {