dns

package
v0.8.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2025 License: Unlicense Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dns is an implementation of the specification of NIP-05, providing DNS based verification for nostr identities.

Index

Constants

This section is empty.

Variables

View Source
var Nip05Regex = regexp.MustCompile(`^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$`)

Nip05Regex is an regular expression that matches up with the same pattern as an email address.

Functions

func IsValidIdentifier

func IsValidIdentifier(input string) bool

IsValidIdentifier verifies that an identifier matches a correct NIP-05 username@domain

func NormalizeIdentifier

func NormalizeIdentifier(account string) string

NormalizeIdentifier mainly removes the `_@` from the base username so that only the domain remains.

func ParseIdentifier

func ParseIdentifier(account string) (name, domain string, err error)

ParseIdentifier searches a string for a valid NIP-05 username@domain

func QueryIdentifier

func QueryIdentifier(c context.T, account string) (
	prf *pointers.Profile,
	err error,
)

QueryIdentifier queries a web server from the domain of a NIP-05 DNS identifier

func StringSliceToByteSlice

func StringSliceToByteSlice(ss []string) (bs [][]byte)

StringSliceToByteSlice converts a slice of strings to a slice of slices of bytes.

Types

type WellKnownResponse

type WellKnownResponse struct {
	// Names is a list of usernames associated with the DNS identity as in <name>@<domain>
	Names map[string]string `json:"names"`
	// Relays associates one of the public keys from Names to a list of relay URLs
	// that are recommended for that user.
	Relays map[string][]string `json:"relays,omitempty"`
	NIP46  map[string][]string `json:"nip46,omitempty"` // todo: is this obsolete?
}

WellKnownResponse is the structure of the JSON to be found at <url>/.well-known/nostr.json

func Fetch

func Fetch(c context.T, account string) (
	resp *WellKnownResponse,
	name string, err error,
)

Fetch parses a DNS identity to find the URL to query for a NIP-05 identity verification document.

func NewWellKnownResponse

func NewWellKnownResponse() *WellKnownResponse

NewWellKnownResponse creates a new WellKnownResponse and is required as all the fields are maps and need to be allocated.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL