Skip to main content

ClientTransaction

Struct ClientTransaction 

Source
pub struct ClientTransaction<K> { /* private fields */ }
Available on crate feature tsig only.
Expand description

TSIG Client transaction state.

This types allows signing a DNS request with a given key and validate an answer received for it.

You create both a signed message and a client transaction by calling the request function. You can then send out the signed message and wait for answers. If an answer is received, you pass it into the answer method. This method will remove a TSIG record if it is present directly in the message and then verify that this record is correctly signing the transaction. If the message doesn’t, you can drop it and try with the next answer received. The transaction will remain valid.

Implementations§

Source§

impl<K: AsRef<Key>> ClientTransaction<K>

Source

pub fn request<Target: Composer>( key: K, message: &mut AdditionalBuilder<Target>, now: Time48, ) -> Result<Self, PushError>

Creates a transaction for a request.

The method takes a complete message in the form of an additional builder and a key. It signs the message with the key and adds the signature as a TSIG record to the message’s additional section. It also creates a transaction value that can later be used to validate the response. It modifies the given message and returns the created transaction.

The function can fail if the TSIG record doesn’t fit into the message. In this case, the function returns an error and leave the given message unmodified.

Unlike request_with_fudge, this function uses the recommended default value for fudge: 300 seconds.

Source

pub fn request_with_fudge<Target>( key: K, message: &mut AdditionalBuilder<Target>, now: Time48, fudge: u16, ) -> Result<Self, PushError>
where Target: Composer,

Creates a transaction for a request with provided fudge.

The method takes a complete message in the form of an additional builder and a key. It signs the message with the key and adds the signature as a TSIG record to the message’s additional section. It also creates a transaction value that can later be used to validate the response. It returns both the message and the transaction.

The fudge argument provides the number of seconds that the receiver’s clock may be off from this system’s current time when it receives the message. The specification recommends a value of 300 seconds. Unless there is good reason to not use this recommendation, you can simply use request instead.

The function can fail if the TSIG record doesn’t actually fit into the message anymore. In this case, the function returns an error and the untouched message.

Source

pub fn answer<Octs: Octets + AsMut<[u8]> + ?Sized>( &self, message: &mut Message<Octs>, now: Time48, ) -> Result<(), ValidationError>

Validates an answer.

Takes a message and checks whether it is a correctly signed answer for this transaction.

First, if the last record in the message’s additional section is the only TSIG record in the message, it takes it out. It then checks whether this record is a correct record for this transaction and if it correctly signs the answer for this transaction. If any of this fails, returns an error.

Source

pub fn key(&self) -> &Key

Returns a reference to the transaction’s key.

Trait Implementations§

Source§

impl<K: Clone> Clone for ClientTransaction<K>

Source§

fn clone(&self) -> ClientTransaction<K>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K: Debug> Debug for ClientTransaction<K>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<K> Freeze for ClientTransaction<K>
where K: Freeze,

§

impl<K> RefUnwindSafe for ClientTransaction<K>
where K: RefUnwindSafe,

§

impl<K> Send for ClientTransaction<K>
where K: Send,

§

impl<K> Sync for ClientTransaction<K>
where K: Sync,

§

impl<K> Unpin for ClientTransaction<K>
where K: Unpin,

§

impl<K> UnsafeUnpin for ClientTransaction<K>
where K: UnsafeUnpin,

§

impl<K> UnwindSafe for ClientTransaction<K>
where K: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<Source, Target> OctetsInto<Target> for Source
where Target: OctetsFrom<Source>,

Source§

type Error = <Target as OctetsFrom<Source>>::Error

Source§

fn try_octets_into( self, ) -> Result<Target, <Source as OctetsInto<Target>>::Error>

Performs the conversion.
Source§

fn octets_into(self) -> Target
where Self::Error: Into<Infallible>,

Performs an infallible conversion.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more