pub struct ServerCookie(/* private fields */);
Expand description
A server cookie for DNS cookies.
In the original specification, the server cookie was of variable length between 8 and 32 octets. It was supposed to be generated via some sort of message authentication code from the client cookie and a server secret. Leaving the concrete mechanism to the implementer resulted in interoperability problems if servers from multiple vendors were placed behind the same public address. Thus, RFC 9018 defined a standard mechanism of the content and generation of the cookie.
This standard server cookie consists of a 1 octet version number (currently 1), 3 reserved octets that must be zero, a 4 octet timestamp as seconds since the Unix epoch, and 8 octets of hash value.
In version 1, the hash is calculated feeding the SipHash-2-4 that has been initialized with a server secret the concatenation of client cookie, version, reserved, timestamp, client IP address.
Implementations§
source§impl ServerCookie
impl ServerCookie
sourcepub fn from_octets(slice: &[u8]) -> Self
pub fn from_octets(slice: &[u8]) -> Self
Creates a new server cookie from the given octets.
§Panics
The function panics if octets
is shorter than 8 octets or longer
than 32.
sourcepub fn parse<Octs: AsRef<[u8]> + ?Sized>(
parser: &mut Parser<'_, Octs>,
) -> Result<Self, ParseError>
pub fn parse<Octs: AsRef<[u8]> + ?Sized>( parser: &mut Parser<'_, Octs>, ) -> Result<Self, ParseError>
Parses a server cookie from its wire format.
sourcepub fn parse_opt<Octs: AsRef<[u8]> + ?Sized>(
parser: &mut Parser<'_, Octs>,
) -> Result<Option<Self>, ParseError>
pub fn parse_opt<Octs: AsRef<[u8]> + ?Sized>( parser: &mut Parser<'_, Octs>, ) -> Result<Option<Self>, ParseError>
Parses an optional server cookie from its wire format.
sourcepub fn try_to_standard(&self) -> Option<StandardServerCookie>
pub fn try_to_standard(&self) -> Option<StandardServerCookie>
Converts the cookie into a standard cookie if possible.
This is possible if the length of the cookie is 16 octets. Returns
None
otherwise.
sourcepub fn compose_len(&self) -> u16
pub fn compose_len(&self) -> u16
Returns the length of the wire format of the cookie.
sourcepub fn compose<Target: OctetsBuilder + ?Sized>(
&self,
target: &mut Target,
) -> Result<(), Target::AppendError>
pub fn compose<Target: OctetsBuilder + ?Sized>( &self, target: &mut Target, ) -> Result<(), Target::AppendError>
Appends the wire format of the cookie to the target.
Trait Implementations§
source§impl AsRef<[u8]> for ServerCookie
impl AsRef<[u8]> for ServerCookie
source§impl Clone for ServerCookie
impl Clone for ServerCookie
source§fn clone(&self) -> ServerCookie
fn clone(&self) -> ServerCookie
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ServerCookie
impl Debug for ServerCookie
source§impl Display for ServerCookie
impl Display for ServerCookie
source§impl From<StandardServerCookie> for ServerCookie
impl From<StandardServerCookie> for ServerCookie
source§fn from(src: StandardServerCookie) -> Self
fn from(src: StandardServerCookie) -> Self
source§impl Hash for ServerCookie
impl Hash for ServerCookie
source§impl Ord for ServerCookie
impl Ord for ServerCookie
source§fn cmp(&self, other: &ServerCookie) -> Ordering
fn cmp(&self, other: &ServerCookie) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for ServerCookie
impl PartialEq for ServerCookie
source§impl PartialOrd for ServerCookie
impl PartialOrd for ServerCookie
impl Eq for ServerCookie
impl StructuralPartialEq for ServerCookie
Auto Trait Implementations§
impl Freeze for ServerCookie
impl RefUnwindSafe for ServerCookie
impl Send for ServerCookie
impl Sync for ServerCookie
impl Unpin for ServerCookie
impl UnwindSafe for ServerCookie
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)