Documentation
¶
Index ¶
- func DNSLookup(domain, resolverAddr string) ([]Record, TrustLevel, []ParseFailure, error)
- func DomainOf(recipient string) string
- func HTTPSLookup(domain string, timeout time.Duration) ([]Record, []ParseFailure, error)
- func IsFullAddress(recipient string) bool
- func ParseRecordsAndFailures(body string) ([]Record, []ParseFailure)
- type ParseFailure
- type Record
- type Result
- type Service
- type TrustLevel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DNSLookup ¶
func DNSLookup(domain, resolverAddr string) ([]Record, TrustLevel, []ParseFailure, error)
DNSLookup queries _age.<domain> TXT records for age key entries. resolverAddr is optional (e.g. "8.8.8.8:53"); empty means system default. It also returns any parse failures encountered, so callers can warn the user about malformed published records.
func DomainOf ¶
DomainOf extracts the domain from a recipient string. "user@domain.de" → "domain.de", "domain.de" → "domain.de".
func HTTPSLookup ¶
HTTPSLookup fetches https://<domain>/.well-known/age and parses age records. It also returns parse failures so callers can warn about malformed records.
func IsFullAddress ¶
IsFullAddress returns true if the recipient looks like user@domain.
func ParseRecordsAndFailures ¶
func ParseRecordsAndFailures(body string) ([]Record, []ParseFailure)
ParseRecordsAndFailures parses multiple lines and returns both the valid records and a list of parse failures (with the raw offending line).
Types ¶
type ParseFailure ¶
ParseFailure describes a record line that could not be parsed.
type Record ¶
type Record struct {
Match string // bare domain or user@domain
Delivery string // delivery mailbox (RCPT TO), empty = deliver to Match
AgeKey string // age public key (age1... or age1pq1...)
}
Record is a single entry from a DNS TXT or HTTPS well-known file.
func ParseRecord ¶
ParseRecord parses a single semicolon-separated line into a Record. Format: match;delivery;age-key
func ParseRecords ¶
ParseRecords parses multiple lines (e.g. from a well-known file), discarding parse failures. Use ParseRecordsAndFailures when you need to surface them.
type Result ¶
type Result struct {
Recipient string `json:"recipient"`
Found bool `json:"found"`
Trust TrustLevel `json:"trust,omitempty"`
Keys []string `json:"recipients,omitempty"` // JSON field = "recipients" per §4.4
SelectedKey string `json:"selected_key,omitempty"`
SelectionReason string `json:"selection_reason,omitempty"` // "single", "pq-preferred", "pq-unavailable"
Delivery string `json:"delivery,omitempty"`
Warnings []string `json:"warnings,omitempty"`
}
Result is the response returned by a lookup.
type TrustLevel ¶
type TrustLevel string
TrustLevel indicates how the key was discovered and how trustworthy that is.
const ( TrustHTTPS TrustLevel = "https" // Web PKI / TLS authenticated TrustDNSSEC TrustLevel = "dnssec" // DNSSEC validated (AD bit) TrustDNS TrustLevel = "dns" // Plain DNS, unauthenticated )