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§
Source§impl<K: AsRef<Key>> ClientTransaction<K>
impl<K: AsRef<Key>> ClientTransaction<K>
Sourcepub fn request<Target: Composer>(
key: K,
message: &mut AdditionalBuilder<Target>,
now: Time48,
) -> Result<Self, PushError>
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.
Sourcepub fn request_with_fudge<Target>(
key: K,
message: &mut AdditionalBuilder<Target>,
now: Time48,
fudge: u16,
) -> Result<Self, PushError>where
Target: Composer,
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.
Sourcepub fn answer<Octs: Octets + AsMut<[u8]> + ?Sized>(
&self,
message: &mut Message<Octs>,
now: Time48,
) -> Result<(), ValidationError>
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.
Trait Implementations§
Source§impl<K: Clone> Clone for ClientTransaction<K>
impl<K: Clone> Clone for ClientTransaction<K>
Source§fn clone(&self) -> ClientTransaction<K>
fn clone(&self) -> ClientTransaction<K>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more