package dns

Import Path
	github.com/tmc/go-iroh/dns (on go.dev)

Dependency Relation
	imports 18 packages, and imported by one package

Involved Source Files attrs.go Package dns provides DNS-based endpoint discovery for go-iroh: publishing and resolving endpoint addressing information via DNS using the pkarr signed packet format. It is a port of the Rust crate iroh-dns. The central types are [EndpointData] (a relay URL, direct addresses, and optional user data about an endpoint) and [EndpointInfo] (an [key.EndpointID] coupled with its [EndpointData]). Records are published under the name "_iroh.<z32-endpoint-id>.<origin>" as TXT records of the form "key=value" (RFC 1464), with keys "relay", "addr", and "user-data". [EndpointInfo] converts to and from both TXT record sets and pkarr signed packets. The Go API is not stable before v1 and may change in any v0 release. doh.go dot.go endpointinfo.go resolver.go signedpacket.go
Package-Level Type Names (total 9)
/* sort by: | */
DoHLookuper resolves TXT records using DNS-over-HTTPS. It sends RFC 8484 POST requests with Content-Type application/dns-message. The zero value is not usable; set URL before calling LookupTXT. HTTPClient sends requests. If nil, [http.DefaultClient] is used. URL is the DNS-over-HTTPS endpoint. LookupTXT resolves name as TXT using DNS-over-HTTPS. *DoHLookuper : TXTLookuper
DoTLookuper resolves TXT records using DNS-over-TLS. Address is a host:port pair. TLSConfig may be nil to use the default TLS configuration. Address string Dialer *net.Dialer TLSConfig *tls.Config LookupTXT resolves name as TXT using DNS-over-TLS. *DoTLookuper : TXTLookuper
EndpointData is the addressing and metadata published about an endpoint: a set of transport addresses (in priority order) and optional [UserData]. It does not include the endpoint's id; see [EndpointInfo]. The zero value is an empty EndpointData and is ready to use. AddAddrs adds addresses in order, skipping duplicates and ones already present. Duplicate filtering preserves the existing order. AddIPAddrs adds IP addresses in order, skipping duplicates and existing ones. AddRelayURL adds a relay URL to the end of the address list, unless already present. Addrs returns the ordered transport addresses. ClearIPAddrs removes all direct IP addresses. ClearRelayURLs removes all relay addresses. HasAddrs reports whether any addresses are present. IPAddrs returns the direct IP addresses in order. RelayURLs returns the relay URLs in order. SetUserData sets or clears the user data. String returns a diagnostic string for d. UserData returns the user data, or nil if unset. WithAddrs returns a copy of d with addrs added in order, skipping duplicates and existing ones. WithIPAddrs returns a copy of d with addrs added in order, skipping duplicates and existing ones. WithRelayURL returns a copy of d with u added to the end of the address list, unless already present. WithUserData returns a copy of d with the user data set or cleared. WithoutIPAddrs returns a copy of d with all direct IP addresses removed. WithoutRelayURLs returns a copy of d with all relay addresses removed. EndpointData : expvar.Var EndpointData : fmt.Stringer func EndpointDataFromAddr(addr netaddr.EndpointAddr) EndpointData func NewEndpointData(addrs ...netaddr.TransportAddr) EndpointData func EndpointData.WithAddrs(addrs ...netaddr.TransportAddr) EndpointData func EndpointData.WithIPAddrs(addrs ...netip.AddrPort) EndpointData func EndpointData.WithoutIPAddrs() EndpointData func EndpointData.WithoutRelayURLs() EndpointData func EndpointData.WithRelayURL(u netaddr.RelayURL) EndpointData func EndpointData.WithUserData(u *UserData) EndpointData func github.com/tmc/go-iroh/iroh.(*MemoryLookup).SetEndpointInfo(info EndpointInfo) (EndpointData, bool) func github.com/tmc/go-iroh/iroh.(*AddressLookupServices).Publish(data EndpointData) func github.com/tmc/go-iroh/iroh.AddressPublisher.Publish(data EndpointData) func github.com/tmc/go-iroh/iroh.AddressPublisherFunc.Publish(data EndpointData) func github.com/tmc/go-iroh/iroh.FilteredAddressPublisher.Publish(data EndpointData) func github.com/tmc/go-iroh/iroh.(*PkarrPublisher).Publish(data EndpointData)
EndpointInfo couples an [key.EndpointID] with the [EndpointData] published about it. Data is the addressing and metadata. ID is the endpoint this information is about. Addr converts the info into an [netaddr.EndpointAddr]. String returns a diagnostic string for e. ToSignedPacket builds a signed packet for this endpoint info, signed with secretKey and using the given record TTL in seconds. ToTXTStrings renders the endpoint info as "key=value" TXT record strings. EndpointInfo : expvar.Var EndpointInfo : fmt.Stringer func EndpointInfoFromAddr(addr netaddr.EndpointAddr) EndpointInfo func EndpointInfoFromSignedPacket(packet *SignedPacket) (EndpointInfo, error) func EndpointInfoFromTXTLookup(domainName string, values []string) (EndpointInfo, error) func (*Resolver).LookupEndpointByDomainName(ctx context.Context, name string) (EndpointInfo, error) func (*Resolver).LookupEndpointByID(ctx context.Context, id key.EndpointID, origin string) (EndpointInfo, error) func github.com/tmc/go-iroh/iroh.Item.EndpointInfo() EndpointInfo func github.com/tmc/go-iroh/iroh.(*MemoryLookup).GetEndpointInfo(id key.EndpointID) (EndpointInfo, bool) func github.com/tmc/go-iroh/iroh.(*MemoryLookup).RemoveEndpointInfo(id key.EndpointID) (EndpointInfo, bool) func github.com/tmc/go-iroh/iroh.MemoryLookupFromInfo(infos ...EndpointInfo) *iroh.MemoryLookup func github.com/tmc/go-iroh/iroh.NewItem(info EndpointInfo, provenance string, lastUpdated *uint64) iroh.Item func github.com/tmc/go-iroh/iroh.NewStaticLookup(infos ...EndpointInfo) *iroh.StaticLookup func github.com/tmc/go-iroh/iroh.NewStaticLookupWithProvenance(provenance string, infos ...EndpointInfo) *iroh.StaticLookup func github.com/tmc/go-iroh/iroh.(*MemoryLookup).AddEndpointInfo(info EndpointInfo) func github.com/tmc/go-iroh/iroh.(*MemoryLookup).SetEndpointInfo(info EndpointInfo) (EndpointData, bool)
Resolver resolves iroh endpoint information from DNS. The zero value uses the host's default DNS configuration; set [Resolver.Lookuper] to override. Lookuper performs the underlying TXT lookups. If nil, a [net.Resolver] with the default configuration is used. LookupEndpointByDomainName resolves the endpoint info from the TXT records at name, which must be of the form "_iroh.<z32-id>.<origin>". LookupEndpointByID resolves the endpoint info for id published under "_iroh.<z32-id>.<origin>". Pass [N0DNSEndpointOriginProd] for the number0 production service. func github.com/tmc/go-iroh/iroh.N0DNSAddressLookup(resolver *Resolver) *iroh.DNSAddressLookup func github.com/tmc/go-iroh/iroh.NewDNSAddressLookup(origin string, resolver *Resolver) *iroh.DNSAddressLookup func github.com/tmc/go-iroh/iroh.WithDNSResolver(r *Resolver) iroh.Option
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. Bytes returns the full serialized wire bytes. MoreRecentThan reports whether p should replace other. Equal timestamps are ordered by their encoded DNS packets, matching pkarr's conflict rule. PublicKey returns the signer's public key. RelayPayload returns the relay payload: everything after the public key. TXTRecords returns the TXT string values under name, normalized relative to the signer's z-base-32 public key. TimestampMicros returns the packet timestamp in microseconds since the UNIX epoch. *SignedPacket : github.com/apache/arrow-go/v18/internal/hashing.ByteSlice func SignedPacketFromBytes(b []byte) (*SignedPacket, error) func SignedPacketFromBytesUnchecked(b []byte) (*SignedPacket, error) func EndpointInfo.ToSignedPacket(secretKey key.SecretKey, ttl uint32) (*SignedPacket, error) func EndpointInfoFromSignedPacket(packet *SignedPacket) (EndpointInfo, error) func (*SignedPacket).MoreRecentThan(other *SignedPacket) bool
TXTLookuper looks up the TXT records for a DNS name. It is the minimal resolver seam: any implementation (the stdlib-backed [Resolver], a DoH/DoT client, or a test fake) satisfies it. It is the Go analog of iroh's Resolver trait, narrowed to the TXT lookup that endpoint discovery needs. LookupTXT returns the TXT record string values for name. *DoHLookuper *DoTLookuper TXTLookuperFunc github.com/libp2p/go-libp2p/p2p/net/swarm.ResolverFromMaDNS github.com/multiformats/go-multiaddr-dns.BasicResolver (interface) *github.com/multiformats/go-multiaddr-dns.MockResolver *github.com/multiformats/go-multiaddr-dns.Resolver google.golang.org/grpc/internal/resolver/dns/internal.NetResolver (interface) *net.Resolver
TXTLookuperFunc adapts a function to [TXTLookuper]. LookupTXT calls f(ctx, name). TXTLookuperFunc : TXTLookuper
UserData is application-defined data published and resolved through endpoint discovery. It is a UTF-8 string of at most [UserDataMaxLength] bytes. iroh neither inspects nor uses it. MarshalText implements encoding.TextMarshaler. String returns the user data string. UnmarshalText implements encoding.TextUnmarshaler. UserData : encoding.TextMarshaler *UserData : encoding.TextUnmarshaler UserData : expvar.Var UserData : fmt.Stringer func NewUserData(s string) (UserData, error) func EndpointData.UserData() *UserData func github.com/tmc/go-iroh/iroh.Item.UserData() (UserData, bool) func (*EndpointData).SetUserData(u *UserData) func EndpointData.WithUserData(u *UserData) EndpointData
Package-Level Functions (total 8)
EndpointDataFromAddr builds EndpointData from an [netaddr.EndpointAddr], taking its (already de-duplicated, sorted) addresses.
EndpointInfoFromAddr converts an [netaddr.EndpointAddr] into an EndpointInfo.
EndpointInfoFromSignedPacket parses an EndpointInfo from a signed packet.
EndpointInfoFromTXTLookup parses an EndpointInfo from DNS TXT lookup results. domainName is the queried name ("_iroh.<z32>.<origin>") and values are the TXT record string values.
NewEndpointData returns an EndpointData with the given addresses. Order is preserved; duplicates are removed.
NewUserData returns a UserData wrapping s, or [ErrUserDataTooLong] if s exceeds [UserDataMaxLength] bytes.
SignedPacketFromBytes parses and verifies a signed packet from its wire representation.
SignedPacketFromBytesUnchecked parses a signed packet without verifying its signature. It still validates the minimum length and DNS packet encoding.
Package-Level Variables (total 5)
ErrInvalidTXTAttr is returned for a TXT value not of the form key=value.
ErrNotIrohRecord is returned when the first label is not "_iroh".
ErrNumLabels is returned when a DNS name has too few labels.
ErrUnknownAttr is returned for an unrecognized attribute key.
ErrUserDataTooLong is returned when a [UserData] value exceeds [UserDataMaxLength].
Package-Level Constants (total 6)
DNSTimeout is the default per-lookup timeout.
IrohTXTName is the DNS record name under which iroh TXT records are published.
MaxSignedPacketSize is the maximum wire size of a signed packet, including its public key.
N0DNSEndpointOriginProd is the number0 production discovery origin.
N0DNSEndpointOriginStaging is the number0 staging discovery origin.
UserDataMaxLength is the maximum byte length of [UserData]. A DNS TXT character-string holds at most 255 bytes; subtracting the "user-data=" prefix leaves 245 bytes.