Documentation
¶
Index ¶
- Constants
- Variables
- func SendDNSAction[R any, T DNSAction](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
- type DNSBaseAction
- type DNSCert
- type DNSCertAction
- type DNSCertResponse
- type DNSDeleteAction
- type DNSRecordType
- type DNSResponse
- type Dns
- type Message
- type RecordType
- type Result
- type StatusType
- type Subscriber
- type Transport
- type WithConfig
Constants ¶
const DefaultDNSTimeout = 10 * time.Second
DefaultDNSTimeout is the default timeout for a DNS action which is 10 seconds
Variables ¶
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 SendDNSAction ¶ added in v1.0.48
func SendDNSAction[R any, T DNSAction](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 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)
}
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 time.Duration `json:"ttl,omitempty"`
Expires time.Duration `json:"expires,omitempty"`
TLSCert string `json:"tls_cert,omitempty"`
}
func AddDNSAction ¶ added in v1.0.48
func AddDNSAction(name string, recordType DNSRecordType, value string, ttl time.Duration, expires time.Duration, tlsCert string) *DNSAddAction
AddDNSAction adds a DNS action to the DNS server
type DNSBaseAction ¶ added in v1.0.48
type DNSBaseAction struct {
ID string `json:"id"`
Action string `json:"action"`
Reply string `json:"reply,omitempty"`
}
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 DNSCertResponse ¶ added in v1.0.48
type DNSCertResponse struct {
DNSResponse[DNSCert]
}
type DNSDeleteAction ¶ added in v1.0.48
type DNSDeleteAction struct {
DNSBaseAction
Name string `json:"name"`
}
func DeleteDNSAction ¶ added in v1.0.48
func DeleteDNSAction(name 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" )
type DNSResponse ¶ added in v1.0.48
type Dns ¶
type Dns struct {
// contains filtered or unexported fields
}
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 WithConfig ¶
type WithConfig func(config *dnsConfig)
func WithFailIfLocal ¶
func WithFailIfLocal() WithConfig
WithFailIfLocal will cause the DNS resolver to fail if the hostname is a local hostname.