Documentation
¶
Index ¶
- Constants
- Variables
- func ActionFromChannel(channel string) (string, error)
- func FetchTLSCert(ctx context.Context, client *redis.Client, name string) (*tls.Certificate, time.Time, error)
- func SendDNSAction[R any, T TypedDNSAction[R]](ctx context.Context, action T, opts ...optionHandler) (*R, error)
- func WithRedis(redis *redis.Client) optionHandler
- func WithReply(reply bool) optionHandler
- func WithTimeout(timeout time.Duration) optionHandler
- func WithTransport(transport Transport) optionHandler
- type Answer
- type DNS
- type DNSAction
- type DNSAddAction
- func (a *DNSAddAction) WithExpires(expires time.Duration) *DNSAddAction
- func (a *DNSAddAction) WithPort(port int) *DNSAddAction
- func (a *DNSAddAction) WithPriority(priority int) *DNSAddAction
- func (a *DNSAddAction) WithTTL(ttl time.Duration) *DNSAddAction
- func (a *DNSAddAction) WithWeight(weight int) *DNSAddAction
- type DNSBaseAction
- type DNSCert
- type DNSCertAction
- type DNSDeleteAction
- type DNSRecord
- type DNSRecordType
- type DNSResponse
- type Dns
- type Message
- type RecordType
- type Result
- type StatusType
- type Subscriber
- type Transport
- type TypedDNSAction
- type WithConfig
Constants ¶
const DefaultDNSTimeout = 10 * time.Second
DefaultDNSTimeout is the default timeout for a DNS action which is 10 seconds
Variables ¶
var DefaultDNS = New()
var DefaultDNSServers = []string{
"ns0.agentuity.com:53",
"ns1.agentuity.com:53",
"ns2.agentuity.com:53",
}
var ErrClosed = errors.New("closed")
var ErrInvalidIP = fmt.Errorf("invalid ip address resolved for hostname")
var ErrTimeout = errors.New("timeout")
var ErrTransportRequired = errors.New("transport is required")
Functions ¶
func ActionFromChannel ¶ added in v1.0.49
ActionFromChannel returns the action from the channel string
func FetchTLSCert ¶ added in v1.0.63
func FetchTLSCert(ctx context.Context, client *redis.Client, name string) (*tls.Certificate, time.Time, error)
FetchTLSCert fetches a TLS certificate from aether
func SendDNSAction ¶ added in v1.0.48
func SendDNSAction[R any, T TypedDNSAction[R]](ctx context.Context, action T, opts ...optionHandler) (*R, error)
SendDNSAction sends a DNS action to the DNS server with a timeout. If the timeout is 0, the default timeout will be used.
func WithRedis ¶ added in v1.0.48
func WithRedis(redis *redis.Client) optionHandler
WithRedis uses a redis client as the transport for the DNS action
func WithReply ¶ added in v1.0.48
func WithReply(reply bool) optionHandler
WithReply sets whether the DNS action should wait for a reply from the DNS server
func WithTimeout ¶ added in v1.0.48
WithTimeout sets a custom timeout for the DNS action
func WithTransport ¶ added in v1.0.48
func WithTransport(transport Transport) optionHandler
WithTransport sets a custom transport for the DNS action
Types ¶
type Answer ¶
type Answer struct { Name string `json:"name"` Type RecordType `json:"type"` TTL uint `json:"ttl"` Data string `json:"data"` }
type DNSAction ¶ added in v1.0.48
type DNSAction interface { // GetID returns the unique ID of the DNS action GetID() string // GetReply returns the reply of the DNS action GetReply() string // SetReply sets the reply of the DNS action SetReply(string) // GetAction returns the action of the DNS action GetAction() string }
DNSAction is an interface for a DNS action
type DNSAddAction ¶ added in v1.0.48
type DNSAddAction struct { DNSBaseAction Name string `json:"name"` Type string `json:"type,omitempty"` Value string `json:"value,omitempty"` // TTL is the DNS TTL for the record TTL time.Duration `json:"ttl,omitempty"` // Expires is the expiration time of the DNS record // if not provided the record will never expire Expires time.Duration `json:"expires,omitempty"` // Priority is the priority of the DNS record // only used for MX and SRV records Priority int `json:"priority,omitempty"` // Weight is the weight of the DNS record // only used for SRV records Weight int `json:"weight,omitempty"` // Port is the port of the DNS record // only used for SRV records Port int `json:"port,omitempty"` }
func AddDNSAction ¶ added in v1.0.48
func AddDNSAction(name string, recordType DNSRecordType, value string, ttl time.Duration, expires time.Duration) *DNSAddAction
AddDNSAction adds a DNS action to the DNS server
func NewAddAction ¶ added in v1.0.65
func NewAddAction(name string, recordType DNSRecordType, value string) *DNSAddAction
NewAddDNSAction creates a new DNS add action
func (*DNSAddAction) WithExpires ¶ added in v1.0.65
func (a *DNSAddAction) WithExpires(expires time.Duration) *DNSAddAction
WithExpires sets the expiration if not provided the record will never expire
func (*DNSAddAction) WithPort ¶ added in v1.0.65
func (a *DNSAddAction) WithPort(port int) *DNSAddAction
WithPort sets the port of the DNS action only used for SRV records
func (*DNSAddAction) WithPriority ¶ added in v1.0.65
func (a *DNSAddAction) WithPriority(priority int) *DNSAddAction
WithPriority sets the priority of the DNS action only used for MX and SRV records
func (*DNSAddAction) WithTTL ¶ added in v1.0.65
func (a *DNSAddAction) WithTTL(ttl time.Duration) *DNSAddAction
func (*DNSAddAction) WithWeight ¶ added in v1.0.65
func (a *DNSAddAction) WithWeight(weight int) *DNSAddAction
WithWeight sets the weight of the DNS action only used for SRV records
type DNSBaseAction ¶ added in v1.0.48
type DNSBaseAction struct { MsgID string `json:"msg_id"` Action string `json:"action"` Reply string `json:"reply,omitempty"` }
func (DNSBaseAction) GetAction ¶ added in v1.0.49
func (a DNSBaseAction) GetAction() string
GetAction returns the action of the DNS action
func (DNSBaseAction) GetID ¶ added in v1.0.48
func (a DNSBaseAction) GetID() string
GetID returns the unique ID of the DNS action
func (DNSBaseAction) GetReply ¶ added in v1.0.48
func (a DNSBaseAction) GetReply() string
GetReply returns the reply of the DNS action
func (*DNSBaseAction) SetReply ¶ added in v1.0.48
func (a *DNSBaseAction) SetReply(reply string)
SetReply sets the reply of the DNS action
type DNSCertAction ¶ added in v1.0.48
type DNSCertAction struct { DNSBaseAction Name string `json:"name"` }
func CertRequestDNSAction ¶ added in v1.0.48
func CertRequestDNSAction(name string) *DNSCertAction
CertRequestDNSAction requests a certificate from the DNS server
type DNSDeleteAction ¶ added in v1.0.48
type DNSDeleteAction struct { DNSBaseAction // Name is the name of the DNS record to delete. Name string `json:"name"` // IDs are the IDs of the DNS records to delete (within a name). This allows for clients to manage a specific record if they keep track of the ID. // If not provided, any name match will be deleted. IDs []string `json:"ids,omitempty"` }
func DeleteDNSAction ¶ added in v1.0.48
func DeleteDNSAction(name string, ids ...string) *DNSDeleteAction
DeleteDNSAction deletes a DNS action from the DNS server
type DNSRecordType ¶ added in v1.0.48
type DNSRecordType string
const ( RecordTypeA DNSRecordType = "A" RecordTypeAAAA DNSRecordType = "AAAA" RecordTypeCNAME DNSRecordType = "CNAME" RecordTypeMX DNSRecordType = "MX" RecordTypeNS DNSRecordType = "NS" RecordTypeTXT DNSRecordType = "TXT" RecordTypeSRV DNSRecordType = "SRV" )
type DNSResponse ¶ added in v1.0.48
type DNSResponse[T any] struct { MsgID string `json:"msg_id"` Success bool `json:"success"` Error string `json:"error,omitempty"` Data *T `json:"data,omitempty"` }
func NewDNSResponse ¶ added in v1.0.55
func NewDNSResponse[R any, T TypedDNSAction[R]](action T, data *R, err error) *DNSResponse[R]
type Message ¶ added in v1.0.48
type Message struct {
Payload []byte
}
Message is a message from the transport layer
type Result ¶
type Result struct { Status StatusType `json:"Status"` Answer []Answer `json:"Answer"` }
type StatusType ¶
type StatusType uint8
const ( NoError StatusType = 0 FormErr StatusType = 1 ServFail StatusType = 2 NXDomain StatusType = 3 Refused StatusType = 5 NotAuth StatusType = 9 NotZone StatusType = 10 )
func (StatusType) String ¶
func (s StatusType) String() string
type Subscriber ¶ added in v1.0.48
type Subscriber interface { // Close closes the subscriber Close() error // Channel returns a channel of messages Channel() <-chan *Message }
Subscriber is an interface for a subscriber to the transport layer
type Transport ¶ added in v1.0.48
type Transport interface { Subscribe(ctx context.Context, channel string) Subscriber Publish(ctx context.Context, channel string, payload []byte) error }
Transport is an interface for a transport layer for the DNS server
type TypedDNSAction ¶ added in v1.0.55
TypedDNSAction is an interface for a DNS action that also specifies its expected response data type.
type WithConfig ¶
type WithConfig func(config *dnsConfig)
func WithCache ¶ added in v1.0.51
func WithCache(cache cache.Cache) WithConfig
WithCache will set the cache for the DNS resolver.
func WithFailIfLocal ¶
func WithFailIfLocal() WithConfig
WithFailIfLocal will cause the DNS resolver to fail if the hostname is a local hostname.