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

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.

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.

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.

Returns a reference to the transaction’s key.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Performs the conversion.

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.