Source File
signedpacket.go
Belonging Package
github.com/tmc/go-iroh/dns
package dnsimport ()// MaxSignedPacketSize is the maximum wire size of a signed packet, including// its public key.const MaxSignedPacketSize = pkarr.MaxBytes// SignedPacket is a signed DNS packet in the pkarr format used for iroh// endpoint discovery.//// A SignedPacket is immutable. Accessors return copies where mutation would// otherwise affect the packet.type SignedPacket struct {packet *pkarr.SignedPacket}// SignedPacketFromBytes parses and verifies a signed packet from its wire// representation.func ( []byte) (*SignedPacket, error) {, := pkarr.FromBytes()if != nil {return nil,}return &SignedPacket{packet: }, nil}// SignedPacketFromBytesUnchecked parses a signed packet without verifying its// signature. It still validates the minimum length and DNS packet encoding.func ( []byte) (*SignedPacket, error) {, := pkarr.FromBytesUnchecked()if != nil {return nil,}return &SignedPacket{packet: }, nil}func signedPacketFromInternal( *pkarr.SignedPacket) *SignedPacket {return &SignedPacket{packet: }}// Bytes returns the full serialized wire bytes.func ( *SignedPacket) () []byte {if == nil || .packet == nil {return nil}return bytes.Clone(.packet.Bytes())}// RelayPayload returns the relay payload: everything after the public key.func ( *SignedPacket) () []byte {if == nil || .packet == nil {return nil}return .packet.RelayPayload()}// PublicKey returns the signer's public key.func ( *SignedPacket) () key.PublicKey {if == nil || .packet == nil {return key.PublicKey{}}return .packet.PublicKey()}// TimestampMicros returns the packet timestamp in microseconds since the UNIX// epoch.func ( *SignedPacket) () uint64 {if == nil || .packet == nil {return 0}return uint64(.packet.Timestamp())}// MoreRecentThan reports whether p should replace other. Equal timestamps are// ordered by their encoded DNS packets, matching pkarr's conflict rule.func ( *SignedPacket) ( *SignedPacket) bool {if == nil || .packet == nil {return false}if == nil || .packet == nil {return true}return .packet.MoreRecentThan(.packet)}// TXTRecords returns the TXT string values under name, normalized relative to// the signer's z-base-32 public key.func ( *SignedPacket) ( string) []string {if == nil || .packet == nil {return nil}return .packet.TxtRecords()}
![]() |
The pages are generated with Golds v0.8.4. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |