Struct trust_dns_proto::udp::UdpClientStream
source · pub struct UdpClientStream<S, MF = NoopMessageFinalizer>where
S: Send,
MF: MessageFinalizer,{ /* private fields */ }
Expand description
A UDP client stream of DNS binary packets
This stream will create a new UDP socket for every request. This is to avoid potential cache poisoning during use by UDP based attacks.
Implementations§
source§impl<S: UdpSocket + Send + 'static> UdpClientStream<S, NoopMessageFinalizer>
impl<S: UdpSocket + Send + 'static> UdpClientStream<S, NoopMessageFinalizer>
sourcepub fn new(name_server: SocketAddr) -> UdpClientConnect<S, NoopMessageFinalizer> ⓘ
pub fn new(name_server: SocketAddr) -> UdpClientConnect<S, NoopMessageFinalizer> ⓘ
it is expected that the resolver wrapper will be responsible for creating and managing new UdpClients such that each new client would have a random port (reduce chance of cache poisoning)
§Return
a tuple of a Future Stream which will handle sending and receiving messages, and a handle which can be used to send messages into the stream.
sourcepub fn with_timeout(
name_server: SocketAddr,
timeout: Duration,
) -> UdpClientConnect<S, NoopMessageFinalizer> ⓘ
pub fn with_timeout( name_server: SocketAddr, timeout: Duration, ) -> UdpClientConnect<S, NoopMessageFinalizer> ⓘ
Constructs a new UdpStream for a client to the specified SocketAddr.
§Arguments
name_server
- the IP and Port of the DNS server to connect totimeout
- connection timeout
sourcepub fn with_bind_addr_and_timeout(
name_server: SocketAddr,
bind_addr: Option<SocketAddr>,
timeout: Duration,
) -> UdpClientConnect<S, NoopMessageFinalizer> ⓘ
pub fn with_bind_addr_and_timeout( name_server: SocketAddr, bind_addr: Option<SocketAddr>, timeout: Duration, ) -> UdpClientConnect<S, NoopMessageFinalizer> ⓘ
Constructs a new UdpStream for a client to the specified SocketAddr.
§Arguments
name_server
- the IP and Port of the DNS server to connect tobind_addr
- the IP and port to connect fromtimeout
- connection timeout
source§impl<S: UdpSocket + Send + 'static, MF: MessageFinalizer> UdpClientStream<S, MF>
impl<S: UdpSocket + Send + 'static, MF: MessageFinalizer> UdpClientStream<S, MF>
sourcepub fn with_timeout_and_signer(
name_server: SocketAddr,
timeout: Duration,
signer: Option<Arc<MF>>,
) -> UdpClientConnect<S, MF> ⓘ
pub fn with_timeout_and_signer( name_server: SocketAddr, timeout: Duration, signer: Option<Arc<MF>>, ) -> UdpClientConnect<S, MF> ⓘ
Constructs a new UdpStream for a client to the specified SocketAddr.
§Arguments
name_server
- the IP and Port of the DNS server to connect totimeout
- connection timeout
sourcepub fn with_timeout_and_signer_and_bind_addr(
name_server: SocketAddr,
timeout: Duration,
signer: Option<Arc<MF>>,
bind_addr: Option<SocketAddr>,
) -> UdpClientConnect<S, MF> ⓘ
pub fn with_timeout_and_signer_and_bind_addr( name_server: SocketAddr, timeout: Duration, signer: Option<Arc<MF>>, bind_addr: Option<SocketAddr>, ) -> UdpClientConnect<S, MF> ⓘ
Constructs a new UdpStream for a client to the specified SocketAddr.
§Arguments
name_server
- the IP and Port of the DNS server to connect totimeout
- connection timeoutbind_addr
- the IP address and port to connect from
source§impl<S: DnsUdpSocket + Send, MF: MessageFinalizer> UdpClientStream<S, MF>
impl<S: DnsUdpSocket + Send, MF: MessageFinalizer> UdpClientStream<S, MF>
sourcepub fn with_creator(
name_server: SocketAddr,
signer: Option<Arc<MF>>,
timeout: Duration,
creator: Arc<dyn Send + Sync + Fn(SocketAddr, SocketAddr) -> Pin<Box<dyn Send + Future<Output = Result<S, Error>>>>>,
) -> UdpClientConnect<S, MF> ⓘ
pub fn with_creator( name_server: SocketAddr, signer: Option<Arc<MF>>, timeout: Duration, creator: Arc<dyn Send + Sync + Fn(SocketAddr, SocketAddr) -> Pin<Box<dyn Send + Future<Output = Result<S, Error>>>>>, ) -> UdpClientConnect<S, MF> ⓘ
Constructs a new UdpStream for a client to the specified SocketAddr.
§Arguments
name_server
- the IP and Port of the DNS server to connect tosigner
- optional final amendmenttimeout
- connection timeoutcreator
- function that binds a local address to a newly created UDP socket
Trait Implementations§
source§impl<S: Send, MF: MessageFinalizer> Display for UdpClientStream<S, MF>
impl<S: Send, MF: MessageFinalizer> Display for UdpClientStream<S, MF>
source§impl<S: DnsUdpSocket + Send + 'static, MF: MessageFinalizer> DnsRequestSender for UdpClientStream<S, MF>
impl<S: DnsUdpSocket + Send + 'static, MF: MessageFinalizer> DnsRequestSender for UdpClientStream<S, MF>
source§fn send_message(&mut self, message: DnsRequest) -> DnsResponseStream
fn send_message(&mut self, message: DnsRequest) -> DnsResponseStream
source§fn shutdown(&mut self)
fn shutdown(&mut self)
source§fn is_shutdown(&self) -> bool
fn is_shutdown(&self) -> bool
shutdown
source§impl<S: Send, MF: MessageFinalizer> Stream for UdpClientStream<S, MF>
impl<S: Send, MF: MessageFinalizer> Stream for UdpClientStream<S, MF>
§type Item = Result<(), ProtoError>
type Item = Result<(), ProtoError>
Auto Trait Implementations§
impl<S, MF> Freeze for UdpClientStream<S, MF>
impl<S, MF = NoopMessageFinalizer> !RefUnwindSafe for UdpClientStream<S, MF>
impl<S, MF> Send for UdpClientStream<S, MF>
impl<S, MF> Sync for UdpClientStream<S, MF>where
S: Sync,
impl<S, MF> Unpin for UdpClientStream<S, MF>where
S: Unpin,
impl<S, MF = NoopMessageFinalizer> !UnwindSafe for UdpClientStream<S, MF>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<E, S, T> FirstAnswer<T, E> for S
impl<E, S, T> FirstAnswer<T, E> for S
source§fn first_answer(self) -> FirstAnswerFuture<Self> ⓘ
fn first_answer(self) -> FirstAnswerFuture<Self> ⓘ
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> StreamExt for T
impl<T> StreamExt for T
source§fn next(&mut self) -> Next<'_, Self>where
Self: Unpin,
fn next(&mut self) -> Next<'_, Self>where
Self: Unpin,
source§fn into_future(self) -> StreamFuture<Self>
fn into_future(self) -> StreamFuture<Self>
source§fn map<T, F>(self, f: F) -> Map<Self, F>
fn map<T, F>(self, f: F) -> Map<Self, F>
source§fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
source§fn filter<Fut, F>(self, f: F) -> Filter<Self, Fut, F>
fn filter<Fut, F>(self, f: F) -> Filter<Self, Fut, F>
source§fn filter_map<Fut, T, F>(self, f: F) -> FilterMap<Self, Fut, F>
fn filter_map<Fut, T, F>(self, f: F) -> FilterMap<Self, Fut, F>
source§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
source§fn collect<C>(self) -> Collect<Self, C>
fn collect<C>(self) -> Collect<Self, C>
source§fn unzip<A, B, FromA, FromB>(self) -> Unzip<Self, FromA, FromB>
fn unzip<A, B, FromA, FromB>(self) -> Unzip<Self, FromA, FromB>
source§fn concat(self) -> Concat<Self>
fn concat(self) -> Concat<Self>
source§fn count(self) -> Count<Self>where
Self: Sized,
fn count(self) -> Count<Self>where
Self: Sized,
source§fn fold<T, Fut, F>(self, init: T, f: F) -> Fold<Self, Fut, T, F>
fn fold<T, Fut, F>(self, init: T, f: F) -> Fold<Self, Fut, T, F>
source§fn any<Fut, F>(self, f: F) -> Any<Self, Fut, F>
fn any<Fut, F>(self, f: F) -> Any<Self, Fut, F>
true
if any element in stream satisfied a predicate. Read moresource§fn all<Fut, F>(self, f: F) -> All<Self, Fut, F>
fn all<Fut, F>(self, f: F) -> All<Self, Fut, F>
true
if all element in stream satisfied a predicate. Read moresource§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
source§fn flatten_unordered(
self,
limit: impl Into<Option<usize>>,
) -> FlattenUnorderedWithFlowController<Self, ()>
fn flatten_unordered( self, limit: impl Into<Option<usize>>, ) -> FlattenUnorderedWithFlowController<Self, ()>
source§fn flat_map_unordered<U, F>(
self,
limit: impl Into<Option<usize>>,
f: F,
) -> FlatMapUnordered<Self, U, F>
fn flat_map_unordered<U, F>( self, limit: impl Into<Option<usize>>, f: F, ) -> FlatMapUnordered<Self, U, F>
StreamExt::map
but flattens nested Stream
s
and polls them concurrently, yielding items in any order, as they made
available. Read moresource§fn scan<S, B, Fut, F>(self, initial_state: S, f: F) -> Scan<Self, S, Fut, F>
fn scan<S, B, Fut, F>(self, initial_state: S, f: F) -> Scan<Self, S, Fut, F>
StreamExt::fold
that holds internal state
and produces a new stream. Read moresource§fn skip_while<Fut, F>(self, f: F) -> SkipWhile<Self, Fut, F>
fn skip_while<Fut, F>(self, f: F) -> SkipWhile<Self, Fut, F>
true
. Read moresource§fn take_while<Fut, F>(self, f: F) -> TakeWhile<Self, Fut, F>
fn take_while<Fut, F>(self, f: F) -> TakeWhile<Self, Fut, F>
true
. Read moresource§fn take_until<Fut>(self, fut: Fut) -> TakeUntil<Self, Fut>
fn take_until<Fut>(self, fut: Fut) -> TakeUntil<Self, Fut>
source§fn for_each<Fut, F>(self, f: F) -> ForEach<Self, Fut, F>
fn for_each<Fut, F>(self, f: F) -> ForEach<Self, Fut, F>
source§fn for_each_concurrent<Fut, F>(
self,
limit: impl Into<Option<usize>>,
f: F,
) -> ForEachConcurrent<Self, Fut, F>
fn for_each_concurrent<Fut, F>( self, limit: impl Into<Option<usize>>, f: F, ) -> ForEachConcurrent<Self, Fut, F>
source§fn take(self, n: usize) -> Take<Self>where
Self: Sized,
fn take(self, n: usize) -> Take<Self>where
Self: Sized,
n
items of the underlying stream. Read moresource§fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
n
items of the underlying stream. Read moresource§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
source§fn boxed<'a>(self) -> Pin<Box<dyn Stream<Item = Self::Item> + Send + 'a>>
fn boxed<'a>(self) -> Pin<Box<dyn Stream<Item = Self::Item> + Send + 'a>>
source§fn boxed_local<'a>(self) -> Pin<Box<dyn Stream<Item = Self::Item> + 'a>>where
Self: Sized + 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Stream<Item = Self::Item> + 'a>>where
Self: Sized + 'a,
source§fn buffered(self, n: usize) -> Buffered<Self>
fn buffered(self, n: usize) -> Buffered<Self>
source§fn buffer_unordered(self, n: usize) -> BufferUnordered<Self>
fn buffer_unordered(self, n: usize) -> BufferUnordered<Self>
source§fn zip<St>(self, other: St) -> Zip<Self, St>
fn zip<St>(self, other: St) -> Zip<Self, St>
source§fn peekable(self) -> Peekable<Self>where
Self: Sized,
fn peekable(self) -> Peekable<Self>where
Self: Sized,
peek
method. Read moresource§fn chunks(self, capacity: usize) -> Chunks<Self>where
Self: Sized,
fn chunks(self, capacity: usize) -> Chunks<Self>where
Self: Sized,
source§fn ready_chunks(self, capacity: usize) -> ReadyChunks<Self>where
Self: Sized,
fn ready_chunks(self, capacity: usize) -> ReadyChunks<Self>where
Self: Sized,
source§fn forward<S>(self, sink: S) -> Forward<Self, S>
fn forward<S>(self, sink: S) -> Forward<Self, S>
source§fn split<Item>(self) -> (SplitSink<Self, Item>, SplitStream<Self>)
fn split<Item>(self) -> (SplitSink<Self, Item>, SplitStream<Self>)
source§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
source§fn left_stream<B>(self) -> Either<Self, B>
fn left_stream<B>(self) -> Either<Self, B>
source§fn right_stream<B>(self) -> Either<B, Self>
fn right_stream<B>(self) -> Either<B, Self>
source§fn poll_next_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>where
Self: Unpin,
fn poll_next_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>where
Self: Unpin,
Stream::poll_next
on Unpin
stream types.source§fn select_next_some(&mut self) -> SelectNextSome<'_, Self>where
Self: Unpin + FusedStream,
fn select_next_some(&mut self) -> SelectNextSome<'_, Self>where
Self: Unpin + FusedStream,
source§impl<S> TryStreamExt for S
impl<S> TryStreamExt for S
source§fn err_into<E>(self) -> ErrInto<Self, E>
fn err_into<E>(self) -> ErrInto<Self, E>
source§fn map_ok<T, F>(self, f: F) -> MapOk<Self, F>
fn map_ok<T, F>(self, f: F) -> MapOk<Self, F>
source§fn map_err<E, F>(self, f: F) -> MapErr<Self, F>
fn map_err<E, F>(self, f: F) -> MapErr<Self, F>
source§fn and_then<Fut, F>(self, f: F) -> AndThen<Self, Fut, F>
fn and_then<Fut, F>(self, f: F) -> AndThen<Self, Fut, F>
f
. Read moresource§fn or_else<Fut, F>(self, f: F) -> OrElse<Self, Fut, F>
fn or_else<Fut, F>(self, f: F) -> OrElse<Self, Fut, F>
f
. Read moresource§fn inspect_ok<F>(self, f: F) -> InspectOk<Self, F>
fn inspect_ok<F>(self, f: F) -> InspectOk<Self, F>
source§fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
source§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
source§fn try_next(&mut self) -> TryNext<'_, Self>where
Self: Unpin,
fn try_next(&mut self) -> TryNext<'_, Self>where
Self: Unpin,
source§fn try_for_each<Fut, F>(self, f: F) -> TryForEach<Self, Fut, F>
fn try_for_each<Fut, F>(self, f: F) -> TryForEach<Self, Fut, F>
source§fn try_skip_while<Fut, F>(self, f: F) -> TrySkipWhile<Self, Fut, F>
fn try_skip_while<Fut, F>(self, f: F) -> TrySkipWhile<Self, Fut, F>
true
. Read moresource§fn try_take_while<Fut, F>(self, f: F) -> TryTakeWhile<Self, Fut, F>
fn try_take_while<Fut, F>(self, f: F) -> TryTakeWhile<Self, Fut, F>
true
. Read moresource§fn try_for_each_concurrent<Fut, F>(
self,
limit: impl Into<Option<usize>>,
f: F,
) -> TryForEachConcurrent<Self, Fut, F>
fn try_for_each_concurrent<Fut, F>( self, limit: impl Into<Option<usize>>, f: F, ) -> TryForEachConcurrent<Self, Fut, F>
source§fn try_collect<C>(self) -> TryCollect<Self, C>
fn try_collect<C>(self) -> TryCollect<Self, C>
source§fn try_chunks(self, capacity: usize) -> TryChunks<Self>where
Self: Sized,
fn try_chunks(self, capacity: usize) -> TryChunks<Self>where
Self: Sized,
source§fn try_ready_chunks(self, capacity: usize) -> TryReadyChunks<Self>where
Self: Sized,
fn try_ready_chunks(self, capacity: usize) -> TryReadyChunks<Self>where
Self: Sized,
source§fn try_filter<Fut, F>(self, f: F) -> TryFilter<Self, Fut, F>
fn try_filter<Fut, F>(self, f: F) -> TryFilter<Self, Fut, F>
source§fn try_filter_map<Fut, F, T>(self, f: F) -> TryFilterMap<Self, Fut, F>
fn try_filter_map<Fut, F, T>(self, f: F) -> TryFilterMap<Self, Fut, F>
source§fn try_flatten_unordered(
self,
limit: impl Into<Option<usize>>,
) -> TryFlattenUnordered<Self>
fn try_flatten_unordered( self, limit: impl Into<Option<usize>>, ) -> TryFlattenUnordered<Self>
source§fn try_flatten(self) -> TryFlatten<Self>
fn try_flatten(self) -> TryFlatten<Self>
source§fn try_fold<T, Fut, F>(self, init: T, f: F) -> TryFold<Self, Fut, T, F>
fn try_fold<T, Fut, F>(self, init: T, f: F) -> TryFold<Self, Fut, T, F>
source§fn try_concat(self) -> TryConcat<Self>
fn try_concat(self) -> TryConcat<Self>
source§fn try_buffer_unordered(self, n: usize) -> TryBufferUnordered<Self>
fn try_buffer_unordered(self, n: usize) -> TryBufferUnordered<Self>
source§fn try_buffered(self, n: usize) -> TryBuffered<Self>
fn try_buffered(self, n: usize) -> TryBuffered<Self>
source§fn try_poll_next_unpin(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Option<Result<Self::Ok, Self::Error>>>where
Self: Unpin,
fn try_poll_next_unpin(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Option<Result<Self::Ok, Self::Error>>>where
Self: Unpin,
TryStream::try_poll_next
on Unpin
stream types.source§fn into_async_read(self) -> IntoAsyncRead<Self>
fn into_async_read(self) -> IntoAsyncRead<Self>
AsyncBufRead
. Read moresource§fn try_all<Fut, F>(self, f: F) -> TryAll<Self, Fut, F>
fn try_all<Fut, F>(self, f: F) -> TryAll<Self, Fut, F>
Err
is encountered or if an Ok
item is found
that does not satisfy the predicate. Read more