pub struct SignedPacket { /* private fields */ }Expand description
A signed DNS packet in the pkarr format.
Wire format: <32 bytes pubkey><64 bytes signature><8 bytes BE timestamp><DNS wire format>
The DNS packet must be at most 1000 bytes. Total max size is 1104 bytes.
Implementations§
Source§impl SignedPacket
impl SignedPacket
Sourcepub fn from_txt_strings(
secret_key: &SecretKey,
name: &str,
values: impl IntoIterator<Item = impl AsRef<str>>,
ttl: u32,
) -> Result<SignedPacket, SignedPacketBuildError>
pub fn from_txt_strings( secret_key: &SecretKey, name: &str, values: impl IntoIterator<Item = impl AsRef<str>>, ttl: u32, ) -> Result<SignedPacket, SignedPacketBuildError>
Create a signed packet containing TXT records under a single name.
This is the common case: multiple TXT values under the same DNS name (e.g. "_iroh").
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<SignedPacket, SignedPacketVerifyError>
pub fn from_bytes(bytes: &[u8]) -> Result<SignedPacket, SignedPacketVerifyError>
Parse and verify a signed packet from its wire representation.
Sourcepub fn from_relay_payload(
public_key: &PublicKey,
payload: &[u8],
) -> Result<SignedPacket, SignedPacketVerifyError>
pub fn from_relay_payload( public_key: &PublicKey, payload: &[u8], ) -> Result<SignedPacket, SignedPacketVerifyError>
Create from a public key and relay payload (signature + timestamp + dns).
Sourcepub fn from_bytes_unchecked(
bytes: &[u8],
) -> Result<SignedPacket, SignedPacketVerifyError>
pub fn from_bytes_unchecked( bytes: &[u8], ) -> Result<SignedPacket, SignedPacketVerifyError>
Parse a signed packet without verifying the signature.
Still validates minimum length and DNS parsing.
Sourcepub fn to_relay_payload(&self) -> Vec<u8> ⓘ
pub fn to_relay_payload(&self) -> Vec<u8> ⓘ
Return the relay payload (everything after the public key).
Sourcepub fn public_key(&self) -> PublicKey
pub fn public_key(&self) -> PublicKey
Return the public key.
Sourcepub fn encoded_packet(&self) -> &[u8] ⓘ
pub fn encoded_packet(&self) -> &[u8] ⓘ
Return the encoded DNS packet bytes.
Sourcepub fn txt_records(&self, name: &str) -> Vec<String>
pub fn txt_records(&self, name: &str) -> Vec<String>
Iterate over TXT records under a specific DNS name.
The name is normalized relative to the signer’s z-base-32 public key.
Returns the TXT string values.
Sourcepub fn all_txt_records(&self) -> Vec<(String, String)>
pub fn all_txt_records(&self) -> Vec<(String, String)>
Iterate over all TXT records, yielding (name_relative_to_origin, value) pairs.
The name is the part before the z-base-32 public key zone.
Sourcepub fn from_parts_unchecked(
public_key: &[u8],
signature: &[u8],
timestamp: Timestamp,
encoded_packet: &[u8],
) -> Result<Self, SignedPacketVerifyError>
pub fn from_parts_unchecked( public_key: &[u8], signature: &[u8], timestamp: Timestamp, encoded_packet: &[u8], ) -> Result<Self, SignedPacketVerifyError>
Reconstruct a signed packet from its raw parts without verifying the signature.
This is useful for reconstructing a packet from storage or DHT mutable items where the components are stored separately.
Sourcepub fn more_recent_than(&self, other: &SignedPacket) -> bool
pub fn more_recent_than(&self, other: &SignedPacket) -> bool
Return whether this packet is more recent than another.
Trait Implementations§
Source§impl Clone for SignedPacket
impl Clone for SignedPacket
Source§fn clone(&self) -> SignedPacket
fn clone(&self) -> SignedPacket
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SignedPacket
impl Debug for SignedPacket
Source§impl Display for SignedPacket
impl Display for SignedPacket
Source§impl PartialEq for SignedPacket
impl PartialEq for SignedPacket
impl Eq for SignedPacket
impl StructuralPartialEq for SignedPacket
Auto Trait Implementations§
impl Freeze for SignedPacket
impl RefUnwindSafe for SignedPacket
impl Send for SignedPacket
impl Sync for SignedPacket
impl Unpin for SignedPacket
impl UnwindSafe for SignedPacket
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.