Struct domain::tsig::ClientTransaction
source · [−]pub struct ClientTransaction<K> { /* private fields */ }
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
sourceimpl<K: AsRef<Key>> ClientTransaction<K>
impl<K: AsRef<Key>> ClientTransaction<K>
sourcepub fn request<Target: OctetsBuilder + AsRef<[u8]> + AsMut<[u8]>>(
key: K,
message: &mut AdditionalBuilder<Target>
) -> Result<Self, ShortBuf>
pub fn request<Target: OctetsBuilder + AsRef<[u8]> + AsMut<[u8]>>(
key: K,
message: &mut AdditionalBuilder<Target>
) -> Result<Self, ShortBuf>
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 returns both the message and the transaction.
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.
Unlike request_with_fudge
, this function uses the
recommended default value for fudge: 300 seconds.
sourcepub fn request_with_fudge<Target>(
key: K,
message: &mut AdditionalBuilder<Target>,
fudge: u16
) -> Result<Self, ShortBuf>where
Target: OctetsBuilder + AsRef<[u8]> + AsMut<[u8]>,
pub fn request_with_fudge<Target>(
key: K,
message: &mut AdditionalBuilder<Target>,
fudge: u16
) -> Result<Self, ShortBuf>where
Target: OctetsBuilder + AsRef<[u8]> + AsMut<[u8]>,
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.
sourcepub fn answer<Octets>(
&self,
message: &mut Message<Octets>
) -> Result<(), ValidationError>where
Octets: AsRef<[u8]> + AsMut<[u8]>,
for<'a> &'a Octets: OctetsRef,
pub fn answer<Octets>(
&self,
message: &mut Message<Octets>
) -> Result<(), ValidationError>where
Octets: AsRef<[u8]> + AsMut<[u8]>,
for<'a> &'a Octets: OctetsRef,
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.
Trait Implementations
sourceimpl<K: Clone> Clone for ClientTransaction<K>
impl<K: Clone> Clone for ClientTransaction<K>
sourcefn clone(&self) -> ClientTransaction<K>
fn clone(&self) -> ClientTransaction<K>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
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> UnwindSafe for ClientTransaction<K>where
K: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Source, Target> OctetsInto<Target> for Sourcewhere
Target: OctetsFrom<Source>,
impl<Source, Target> OctetsInto<Target> for Sourcewhere
Target: OctetsFrom<Source>,
sourcefn octets_into(self) -> Result<Target, ShortBuf>
fn octets_into(self) -> Result<Target, ShortBuf>
Performs the conversion.