Documentation ¶
Overview ¶
Package landns is the core implementation of the Landns.
Please see also package github.com/macrat/client/go-client if you want make client of the Landns.
Index ¶
- Constants
- Variables
- func QtypeToString(qtype uint16) string
- type AddressRecord
- func (r AddressRecord) GetName() Domain
- func (r AddressRecord) GetQtype() uint16
- func (r AddressRecord) GetTTL() uint32
- func (r AddressRecord) IsV4() bool
- func (r AddressRecord) String() string
- func (r AddressRecord) ToRR() (dns.RR, error)
- func (r AddressRecord) Validate() error
- func (r AddressRecord) WithoutTTL() string
- type AlternateResolver
- type CnameRecord
- type Domain
- type DynamicAPI
- func (d DynamicAPI) DeleteRecordByID(path, req, remote string) (string, *HTTPError)
- func (d DynamicAPI) DeleteRecords(path, req, remote string) (string, *HTTPError)
- func (d DynamicAPI) GetAllRecords(path, req, remote string) (string, *HTTPError)
- func (d DynamicAPI) GetRecordByID(path, req, remote string) (string, *HTTPError)
- func (d DynamicAPI) GetRecordsByGlob(path, req, remote string) (string, *HTTPError)
- func (d DynamicAPI) GetRecordsBySuffix(path, req, remote string) (string, *HTTPError)
- func (d DynamicAPI) Handler() http.Handler
- func (d DynamicAPI) PostRecords(path, req, remote string) (string, *HTTPError)
- type DynamicRecord
- type DynamicRecordSet
- type DynamicResolver
- type Error
- type ErrorSet
- type ErrorType
- type EtcdResolver
- func (er *EtcdResolver) Close() error
- func (er *EtcdResolver) GetRecord(id int) (DynamicRecordSet, error)
- func (er *EtcdResolver) GlobRecords(glob string) (DynamicRecordSet, error)
- func (er *EtcdResolver) Records() (DynamicRecordSet, error)
- func (er *EtcdResolver) RecursionAvailable() bool
- func (er *EtcdResolver) RemoveRecord(id int) error
- func (er *EtcdResolver) Resolve(w ResponseWriter, r Request) error
- func (er *EtcdResolver) SearchRecords(d Domain) (DynamicRecordSet, error)
- func (er *EtcdResolver) SetRecords(rs DynamicRecordSet) error
- func (er *EtcdResolver) String() string
- type ForwardResolver
- type HTTPError
- type Handler
- type LocalCache
- type MessageBuilder
- type Metrics
- func (m *Metrics) CacheHit(req Request)
- func (m *Metrics) CacheMiss(req Request)
- func (m *Metrics) Collect(ch chan<- prometheus.Metric)
- func (m *Metrics) Describe(ch chan<- *prometheus.Desc)
- func (m *Metrics) Error(req Request, err error)
- func (m *Metrics) HTTPHandler() (http.Handler, error)
- func (m *Metrics) Start(request *dns.Msg) func(*dns.Msg)
- func (m *Metrics) UpstreamTime(duration time.Duration)
- type MxRecord
- type NsRecord
- type Proto
- type PtrRecord
- type Record
- type RedisCache
- type Request
- type Resolver
- type ResolverConfig
- type ResolverSet
- type ResponseCallback
- type ResponseWriter
- type ResponseWriterHook
- type Server
- type SimpleResolver
- type SqliteResolver
- func (sr *SqliteResolver) Close() error
- func (sr *SqliteResolver) GetRecord(id int) (DynamicRecordSet, error)
- func (sr *SqliteResolver) GlobRecords(pattern string) (DynamicRecordSet, error)
- func (sr *SqliteResolver) Records() (DynamicRecordSet, error)
- func (sr *SqliteResolver) RecursionAvailable() bool
- func (sr *SqliteResolver) RemoveRecord(id int) error
- func (sr *SqliteResolver) Resolve(w ResponseWriter, r Request) error
- func (sr *SqliteResolver) SearchRecords(suffix Domain) (DynamicRecordSet, error)
- func (sr *SqliteResolver) SetRecords(rs DynamicRecordSet) error
- func (sr *SqliteResolver) String() string
- type SrvRecord
- type SrvRecordConfig
- type TxtRecord
- type VolatileRecord
Examples ¶
Constants ¶
const ( // DefaultTTL is the default TTL in the configuration file. DefaultTTL uint32 = 3600 )
Variables ¶
var ( ErrMultiLineDynamicRecord = Error{Type: TypeArgumentError, Message: "DynamicRecord can't have multi line"} ErrInvalidDynamicRecordFormat = Error{Type: TypeArgumentError, Message: "DynamicRecord invalid format"} ErrNoSuchRecord = Error{Type: TypeArgumentError, Message: "no such record"} )
Functions ¶
func QtypeToString ¶
QtypeToString is helper for dns type number to human readable string like "A" or "TXT".
Types ¶
type AddressRecord ¶
AddressRecord is the Record of A or AAAA.
func (AddressRecord) GetName ¶
func (r AddressRecord) GetName() Domain
GetName is getter to name of record.
func (AddressRecord) GetQtype ¶
func (r AddressRecord) GetQtype() uint16
GetQtype is getter to query type number like dns.TypeA or dns.TypeTXT of package github.com/miekg/dns.
func (AddressRecord) GetTTL ¶
func (r AddressRecord) GetTTL() uint32
GetTTL is getter to TTL of record.
func (AddressRecord) IsV4 ¶
func (r AddressRecord) IsV4() bool
IsV4 is checker for guess that which of IPv4 (A record) or IPv6 (AAAA record).
func (AddressRecord) ToRR ¶
func (r AddressRecord) ToRR() (dns.RR, error)
ToRR is converter to dns.RR of package github.com/miekg/dns
func (AddressRecord) Validate ¶
func (r AddressRecord) Validate() error
Validate is validator of record.
func (AddressRecord) WithoutTTL ¶
func (r AddressRecord) WithoutTTL() string
WithoutTTL is make record string but mask TTL number.
type AlternateResolver ¶
type AlternateResolver []Resolver
AlternateResolver is list of Resolver.
AlternateResolver will response only first respond unlike ResolverSet.
func (AlternateResolver) Close ¶
func (ar AlternateResolver) Close() error
Close is close all upstream resolvers.
func (AlternateResolver) RecursionAvailable ¶
func (ar AlternateResolver) RecursionAvailable() bool
RecursionAvailable is returns `true` if upstream resolvers at least one returns `true`.
func (AlternateResolver) Resolve ¶
func (ar AlternateResolver) Resolve(resp ResponseWriter, req Request) error
Resolve is resolver using first respond upstream resolvers.
func (AlternateResolver) String ¶
func (ar AlternateResolver) String() string
String is returns simple human readable string.
type CnameRecord ¶
CnameRecord is the Record of CNAME.
func (CnameRecord) GetName ¶
func (r CnameRecord) GetName() Domain
GetName is getter to name of record.
func (CnameRecord) GetQtype ¶
func (r CnameRecord) GetQtype() uint16
GetQtype is getter to query type number like dns.TypeA or dns.TypeTXT of package github.com/miekg/dns.
func (CnameRecord) ToRR ¶
func (r CnameRecord) ToRR() (dns.RR, error)
ToRR is converter to dns.RR of package github.com/miekg/dns
func (CnameRecord) Validate ¶
func (r CnameRecord) Validate() error
Validate is validator of record.
func (CnameRecord) WithoutTTL ¶
func (r CnameRecord) WithoutTTL() string
WithoutTTL is make record string but mask TTL number.
type Domain ¶
type Domain string
Domain is the type for domain.
Example ¶
a := landns.Domain("example.com") b := a.Normalized() fmt.Println(string(a), "->", string(b)) c := landns.Domain("") d := c.Normalized() fmt.Println(string(c), "->", string(d))
Output: example.com -> example.com. -> .
func (Domain) MarshalText ¶
MarshalText is make bytes text.
func (Domain) Normalized ¶
Normalized is normalizer for make FQDN.
func (*Domain) UnmarshalText ¶
UnmarshalText is parse text from bytes.
type DynamicAPI ¶
type DynamicAPI struct {
Resolver DynamicResolver
}
DynamicAPI is API request handler.
func (DynamicAPI) DeleteRecordByID ¶
func (d DynamicAPI) DeleteRecordByID(path, req, remote string) (string, *HTTPError)
func (DynamicAPI) DeleteRecords ¶
func (d DynamicAPI) DeleteRecords(path, req, remote string) (string, *HTTPError)
func (DynamicAPI) GetAllRecords ¶
func (d DynamicAPI) GetAllRecords(path, req, remote string) (string, *HTTPError)
func (DynamicAPI) GetRecordByID ¶
func (d DynamicAPI) GetRecordByID(path, req, remote string) (string, *HTTPError)
func (DynamicAPI) GetRecordsByGlob ¶
func (d DynamicAPI) GetRecordsByGlob(path, req, remote string) (string, *HTTPError)
func (DynamicAPI) GetRecordsBySuffix ¶
func (d DynamicAPI) GetRecordsBySuffix(path, req, remote string) (string, *HTTPError)
func (DynamicAPI) Handler ¶
func (d DynamicAPI) Handler() http.Handler
func (DynamicAPI) PostRecords ¶
func (d DynamicAPI) PostRecords(path, req, remote string) (string, *HTTPError)
type DynamicRecord ¶
DynamicRecord is the record information for DynamicResolver.
Example ¶
record, _ := landns.NewDynamicRecord("example.com. 600 IN A 127.0.0.1") fmt.Println("name:", record.Record.GetName(), "disabled:", record.Disabled) record, _ = landns.NewDynamicRecord(";test.service 300 IN TXT \"hello world\"") fmt.Println("name:", record.Record.GetName(), "disabled:", record.Disabled)
Output: name: example.com. disabled: false name: test.service. disabled: true
func NewDynamicRecord ¶
func NewDynamicRecord(record string) (DynamicRecord, error)
NewDynamicRecord will parse record text and make new DynamicRecord.
func (DynamicRecord) MarshalText ¶
func (r DynamicRecord) MarshalText() ([]byte, error)
MarshalText is marshal DynamicRecord to text.
func (DynamicRecord) String ¶
func (r DynamicRecord) String() string
String is get printable string.
Example ¶
record, _ := landns.NewDynamicRecord("example.com. 600 IN A 127.0.0.1") fmt.Println(record) record.Disabled = true fmt.Println(record) id := 10 record.ID = &id fmt.Println(record)
Output: example.com. 600 IN A 127.0.0.1 ;example.com. 600 IN A 127.0.0.1 ;example.com. 600 IN A 127.0.0.1 ; ID:10
func (*DynamicRecord) UnmarshalText ¶
func (r *DynamicRecord) UnmarshalText(text []byte) error
UnmarshalText is unmarshal DynamicRecord from text.
func (DynamicRecord) VolatileRecord ¶
func (r DynamicRecord) VolatileRecord() (VolatileRecord, error)
VolatileRecord is make VolatileRecord from DynamicRecord.
type DynamicRecordSet ¶
type DynamicRecordSet []DynamicRecord
DynamicRecordSet is list of DynamicRecord
Example ¶
records, _ := landns.NewDynamicRecordSet(` a.example.com. 100 IN A 127.0.0.1 b.example.com. 200 IN A 127.0.1.2 `) for _, r := range records { fmt.Println(r.Record.GetName()) fmt.Println(r) }
Output: a.example.com. a.example.com. 100 IN A 127.0.0.1 b.example.com. b.example.com. 200 IN A 127.0.1.2
func NewDynamicRecordSet ¶
func NewDynamicRecordSet(records string) (DynamicRecordSet, error)
NewDynamicRecordSet will parse record text and make new DynamicRecordSet.
func (DynamicRecordSet) MarshalText ¶
func (rs DynamicRecordSet) MarshalText() ([]byte, error)
func (DynamicRecordSet) String ¶
func (rs DynamicRecordSet) String() string
func (*DynamicRecordSet) UnmarshalText ¶
func (rs *DynamicRecordSet) UnmarshalText(text []byte) error
type DynamicResolver ¶
type DynamicResolver interface { Resolver SetRecords(DynamicRecordSet) error Records() (DynamicRecordSet, error) SearchRecords(Domain) (DynamicRecordSet, error) GlobRecords(string) (DynamicRecordSet, error) GetRecord(int) (DynamicRecordSet, error) RemoveRecord(int) error }
type ErrorType ¶
type ErrorType uint8
ErrorType is type of Error.
const ( // TypeInternalError is a error for Landns internal error. TypeInternalError ErrorType = iota + 1 // TypeExternalError is a error for the error caused from external libraries. TypeExternalError // TypeArgumentError is a error for invalid argument error. TypeArgumentError // TypeExpirationError is error for record has expired. TypeExpirationError )
type EtcdResolver ¶
type EtcdResolver struct { Timeout time.Duration Prefix string // contains filtered or unexported fields }
EtcdResolver is one implements of DynamicResolver using etcd.
func NewEtcdResolver ¶
func NewEtcdResolver(endpoints []string, prefix string, timeout time.Duration, metrics *Metrics) (*EtcdResolver, error)
NewEtcdResolver is constructor of EtcdResolver.
func (*EtcdResolver) Close ¶
func (er *EtcdResolver) Close() error
Close is disconnector from etcd server.
func (*EtcdResolver) GetRecord ¶
func (er *EtcdResolver) GetRecord(id int) (DynamicRecordSet, error)
GetRecord is get record by id.
func (*EtcdResolver) GlobRecords ¶
func (er *EtcdResolver) GlobRecords(glob string) (DynamicRecordSet, error)
GlobRecords is search records by glob string.
func (*EtcdResolver) Records ¶
func (er *EtcdResolver) Records() (DynamicRecordSet, error)
Records is DynamicRecord getter.
func (*EtcdResolver) RecursionAvailable ¶
func (er *EtcdResolver) RecursionAvailable() bool
RecursionAvailable is always returns `false`.
func (*EtcdResolver) RemoveRecord ¶
func (er *EtcdResolver) RemoveRecord(id int) error
RemoveRecord is remove record by id.
func (*EtcdResolver) Resolve ¶
func (er *EtcdResolver) Resolve(w ResponseWriter, r Request) error
Resolve is resolver using etcd.
func (*EtcdResolver) SearchRecords ¶
func (er *EtcdResolver) SearchRecords(d Domain) (DynamicRecordSet, error)
SearchRecords is search records by domain prefix.
func (*EtcdResolver) SetRecords ¶
func (er *EtcdResolver) SetRecords(rs DynamicRecordSet) error
SetRecords is DynamicRecord setter.
func (*EtcdResolver) String ¶
func (er *EtcdResolver) String() string
String is description string getter.
type ForwardResolver ¶
type ForwardResolver struct { Upstreams []*net.UDPAddr Metrics *Metrics // contains filtered or unexported fields }
ForwardResolver is recursion resolver.
func NewForwardResolver ¶
func NewForwardResolver(upstreams []*net.UDPAddr, timeout time.Duration, metrics *Metrics) ForwardResolver
NewForwardResolver is make new ForwardResolver.
func (ForwardResolver) Close ¶
func (fr ForwardResolver) Close() error
Close is closer to ForwardResolver.
func (ForwardResolver) RecursionAvailable ¶
func (fr ForwardResolver) RecursionAvailable() bool
RecursionAvailable is always returns true.
func (ForwardResolver) Resolve ¶
func (fr ForwardResolver) Resolve(w ResponseWriter, r Request) error
Resolve is resolver using upstream DNS servers.
type HTTPError ¶
HTTPError is error message of HTTP method.
type Handler ¶
Handler is the implements of dns.Handler of package github.com/miekg/dns.
func NewHandler ¶
NewHandler is constructor of Handler.
type LocalCache ¶
type LocalCache struct {
// contains filtered or unexported fields
}
LocalCache is in-memory cache manager for Resolver.
func NewLocalCache ¶
func NewLocalCache(upstream Resolver, metrics *Metrics) *LocalCache
NewLocalCache is constructor of LocalCache.
LocalCache will start background goroutine. So you have to ensure to call LocalCache.Close.
func (*LocalCache) RecursionAvailable ¶
func (lc *LocalCache) RecursionAvailable() bool
RecursionAvailable is returns same as upstream.
func (*LocalCache) Resolve ¶
func (lc *LocalCache) Resolve(w ResponseWriter, r Request) error
Resolve is resolver using cache or the upstream resolver.
func (*LocalCache) String ¶
func (lc *LocalCache) String() string
String is getter to description string.
type MessageBuilder ¶
type MessageBuilder struct {
// contains filtered or unexported fields
}
MessageBuilder is one implements of ResponseWriter for make dns.Msg of package github.com/miekg/dns.
func NewMessageBuilder ¶
func NewMessageBuilder(request *dns.Msg, recursionAvailable bool) *MessageBuilder
func (*MessageBuilder) Add ¶
func (mb *MessageBuilder) Add(r Record) error
func (*MessageBuilder) Build ¶
func (mb *MessageBuilder) Build() *dns.Msg
Build is builder of dns.Msg.
func (*MessageBuilder) IsAuthoritative ¶
func (mb *MessageBuilder) IsAuthoritative() bool
func (*MessageBuilder) SetNoAuthoritative ¶
func (mb *MessageBuilder) SetNoAuthoritative()
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics is the metrics collector for the Prometheus.
func (*Metrics) Collect ¶
func (m *Metrics) Collect(ch chan<- prometheus.Metric)
Collect is collect metrics to the Prometheus.
func (*Metrics) Describe ¶
func (m *Metrics) Describe(ch chan<- *prometheus.Desc)
Describe is register descriptions to the Prometheus.
func (*Metrics) HTTPHandler ¶
HTTPHandler is make http.Handler.
func (*Metrics) UpstreamTime ¶
UpstreamTime is collector of recursion resolve.
type MxRecord ¶
MxRecord is the Record of CNAME.
func (MxRecord) GetQtype ¶
GetQtype is getter to query type number like dns.TypeA or dns.TypeTXT of package github.com/miekg/dns.
func (MxRecord) WithoutTTL ¶
WithoutTTL is make record string but mask TTL number.
type NsRecord ¶
NsRecord is the Record of NS.
func (NsRecord) GetQtype ¶
GetQtype is getter to query type number like dns.TypeA or dns.TypeTXT of package github.com/miekg/dns.
func (NsRecord) WithoutTTL ¶
WithoutTTL is make record string but mask TTL number.
type Proto ¶
type Proto string
Proto is type of protocol ("tcp" or "udp").
func (Proto) MarshalText ¶
MarshalText is make bytes text.
func (Proto) String ¶
String is getter to string.
String will returns "tcp" if proto is empty string.
func (*Proto) UnmarshalText ¶
UnmarshalText is parse text to Proto.
type PtrRecord ¶
PtrRecord is the Record of PTR.
func (PtrRecord) GetQtype ¶
GetQtype is getter to query type number like dns.TypeA or dns.TypeTXT of package github.com/miekg/dns.
func (PtrRecord) WithoutTTL ¶
WithoutTTL is make record string but mask TTL number.
type Record ¶
type Record interface { fmt.Stringer GetQtype() uint16 // Get query type like dns.TypeA of package github.com/miekg/dns. GetName() Domain // Get domain name of the Record. GetTTL() uint32 // Get TTL for the Record. ToRR() (dns.RR, error) // Get response record for dns.Msg of package github.com/miekg/dns. Validate() error // Validation Record and returns error if invalid. WithoutTTL() string // Get record string that replaced TTL number with "0". }
Record is the record entry of DNS.
func NewRecord ¶
NewRecord is make new Record from query string.
Example ¶
record, _ := landns.NewRecord("example.com. 600 IN A 127.0.0.1") fmt.Println(record.GetName()) fmt.Println(record.GetTTL()) fmt.Println(record.String())
Output: example.com. 600 example.com. 600 IN A 127.0.0.1
func NewRecordFromRR ¶
NewRecordFromRR is make new Record from dns.RR of package github.com/miekg/dns.
Example ¶
rr, _ := dns.NewRR("example.com. 600 IN A 127.0.0.1") record, _ := landns.NewRecordFromRR(rr) fmt.Println(record.GetName()) fmt.Println(record.GetTTL()) fmt.Println(record.String())
Output: example.com. 600 example.com. 600 IN A 127.0.0.1
func NewRecordWithExpire ¶
NewRecordWithExpire is make new Record from query string with expire time.
Example ¶
record, _ := landns.NewRecordWithExpire("example.com. 600 IN A 127.0.0.1", time.Now().Add(10*time.Second)) fmt.Println(record.GetName()) fmt.Println(record.GetTTL()) fmt.Println(record.String())
Output: example.com. 10 example.com. 10 IN A 127.0.0.1
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
RedisCache is redis cache manager for Resolver.
func NewRedisCache ¶
func NewRedisCache(addr net.Addr, database int, password string, upstream Resolver, metrics *Metrics) (RedisCache, error)
NewRedisCache is constructor of RedisCache.
RedisCache will make connection to the Redis server. So you have to ensure to call RedisCache.Close.
func (RedisCache) RecursionAvailable ¶
func (rc RedisCache) RecursionAvailable() bool
RecursionAvailable is returns same as upstream.
func (RedisCache) Resolve ¶
func (rc RedisCache) Resolve(w ResponseWriter, r Request) error
Resolve is resolver using cache or the upstream resolver.
func (RedisCache) String ¶
func (rc RedisCache) String() string
String is description string getter.
type Request ¶
Request is structure of DNS question.
func NewRequest ¶
NewRequest is constructor for Request.
func (Request) QtypeString ¶
QtypeString is getter to human readable record type.
type Resolver ¶
type Resolver interface { io.Closer Resolve(ResponseWriter, Request) error RecursionAvailable() bool // Checking that recursion resolve is available or not. }
Resolver is the interface of record resolver.
type ResolverConfig ¶
type ResolverConfig struct { TTL *uint32 `yaml:"ttl,omitempty"` Addresses map[Domain][]net.IP `yaml:"address,omitempty"` Cnames map[Domain][]Domain `yaml:"cname,omitempty"` Texts map[Domain][]string `yaml:"text,omitempty"` Services map[Domain][]SrvRecordConfig `yaml:"service,omitempty"` }
ResolverConfig is configuration for static zone.
type ResolverSet ¶
type ResolverSet []Resolver
ResolverSet is list of Resolver.
ResolverSet will merge all resolver's responses unlike AlternateResolver.
func (ResolverSet) Close ¶
func (rs ResolverSet) Close() error
Close is close all upstream resolvers.
func (ResolverSet) RecursionAvailable ¶
func (rs ResolverSet) RecursionAvailable() bool
RecursionAvailable is returns `true` if upstream resolvers at least one returns `true`.
func (ResolverSet) Resolve ¶
func (rs ResolverSet) Resolve(resp ResponseWriter, req Request) error
Resolve is resolver using all upstream resolvers.
func (ResolverSet) String ¶
func (rs ResolverSet) String() string
String is returns simple human readable string.
type ResponseCallback ¶
ResponseCallback is one implements of ResponseWriter for callback function.
func NewResponseCallback ¶
func NewResponseCallback(callback func(Record) error) *ResponseCallback
func (*ResponseCallback) Add ¶
func (rc *ResponseCallback) Add(r Record) error
func (*ResponseCallback) IsAuthoritative ¶
func (rc *ResponseCallback) IsAuthoritative() bool
func (*ResponseCallback) SetNoAuthoritative ¶
func (rc *ResponseCallback) SetNoAuthoritative()
type ResponseWriter ¶
type ResponseWriter interface { Add(Record) error // Add new record into response. IsAuthoritative() bool // Check current response is authoritative or not. SetNoAuthoritative() // Set no authoritative. }
ResponseWriter is interface for Resolver.
type ResponseWriterHook ¶
type ResponseWriterHook struct { Writer ResponseWriter OnAdd func(Record) error }
ResponseWriterHook is a wrapper of ResponseWriter for hook events.
func (ResponseWriterHook) Add ¶
func (rh ResponseWriterHook) Add(r Record) error
func (ResponseWriterHook) IsAuthoritative ¶
func (rh ResponseWriterHook) IsAuthoritative() bool
func (ResponseWriterHook) SetNoAuthoritative ¶
func (rh ResponseWriterHook) SetNoAuthoritative()
type Server ¶
type Server struct { Name string Metrics *Metrics DynamicResolver DynamicResolver Resolvers Resolver // Resolvers for this server. Must include DynamicResolver. DebugMode bool }
Server is the Landns server instance.
func (*Server) DNSHandler ¶
DNSHandler is getter of dns.Handler of package github.com/miekg/dns
func (*Server) HTTPHandler ¶
HTTPHandler is getter of http.Handler.
type SimpleResolver ¶
SimpleResolver is a simple static implements of Resolver.
func NewSimpleResolver ¶
func NewSimpleResolver(records []Record) SimpleResolver
NewSimpleResolver is constructor of SimpleResolver.
func NewSimpleResolverFromConfig ¶
func NewSimpleResolverFromConfig(config []byte) (SimpleResolver, error)
NewSimpleResolverFromConfig is make SimpleResolver from configuration text.
func (SimpleResolver) RecursionAvailable ¶
func (sr SimpleResolver) RecursionAvailable() bool
RecursionAvailable is always returns false.
func (SimpleResolver) Resolve ¶
func (sr SimpleResolver) Resolve(w ResponseWriter, r Request) error
Resolve is resolve matched records.
func (SimpleResolver) String ¶
func (sr SimpleResolver) String() string
String is returns simple human readable string.
func (SimpleResolver) Validate ¶
func (sr SimpleResolver) Validate() error
Validate is validation all records.
type SqliteResolver ¶
type SqliteResolver struct {
// contains filtered or unexported fields
}
SqliteResolver is one implements of DynamicResolver using Sqlite3.
func NewSqliteResolver ¶
func NewSqliteResolver(path string, metrics *Metrics) (*SqliteResolver, error)
func (*SqliteResolver) Close ¶
func (sr *SqliteResolver) Close() error
func (*SqliteResolver) GetRecord ¶
func (sr *SqliteResolver) GetRecord(id int) (DynamicRecordSet, error)
func (*SqliteResolver) GlobRecords ¶
func (sr *SqliteResolver) GlobRecords(pattern string) (DynamicRecordSet, error)
func (*SqliteResolver) Records ¶
func (sr *SqliteResolver) Records() (DynamicRecordSet, error)
func (*SqliteResolver) RecursionAvailable ¶
func (sr *SqliteResolver) RecursionAvailable() bool
func (*SqliteResolver) RemoveRecord ¶
func (sr *SqliteResolver) RemoveRecord(id int) error
func (*SqliteResolver) Resolve ¶
func (sr *SqliteResolver) Resolve(w ResponseWriter, r Request) error
func (*SqliteResolver) SearchRecords ¶
func (sr *SqliteResolver) SearchRecords(suffix Domain) (DynamicRecordSet, error)
func (*SqliteResolver) SetRecords ¶
func (sr *SqliteResolver) SetRecords(rs DynamicRecordSet) error
func (*SqliteResolver) String ¶
func (sr *SqliteResolver) String() string
type SrvRecord ¶
type SrvRecord struct { Name Domain TTL uint32 Priority uint16 Weight uint16 Port uint16 Target Domain }
SrvRecord is the Record of SRV.
func (SrvRecord) GetQtype ¶
GetQtype is getter to query type number like dns.TypeA or dns.TypeTXT of package github.com/miekg/dns.
func (SrvRecord) WithoutTTL ¶
WithoutTTL is make record string but mask TTL number.
type SrvRecordConfig ¶
type SrvRecordConfig struct { Service string `yaml:"service"` Proto Proto `yaml:"proto,omitempty"` Priority uint16 `yaml:"priority,omitempty"` Weight uint16 `yaml:"weight,omitempty"` Port uint16 `yaml:"port"` Target Domain `yaml:"target"` }
SrvRecordConfig is configuration for SRV record of static zone.
type TxtRecord ¶
TxtRecord is the Record of TXT.
func (TxtRecord) GetQtype ¶
GetQtype is getter to query type number like dns.TypeA or dns.TypeTXT of package github.com/miekg/dns.
func (TxtRecord) WithoutTTL ¶
WithoutTTL is make record string but mask TTL number.
type VolatileRecord ¶
VolatileRecord is record value that has expire datetime.
func NewVolatileRecord ¶
func NewVolatileRecord(record string) (VolatileRecord, error)
NewVolatileRecord will parse record text and make new VolatileRecord.
func (VolatileRecord) MarshalText ¶
func (r VolatileRecord) MarshalText() ([]byte, error)
MarshalText is marshal VolatileRecord to text.
func (VolatileRecord) Record ¶
func (r VolatileRecord) Record() (Record, error)
Record is Record getter.
func (VolatileRecord) String ¶
func (r VolatileRecord) String() string
String is get printable string.
func (*VolatileRecord) UnmarshalText ¶
func (r *VolatileRecord) UnmarshalText(text []byte) error
UnmarshalText is unmarshal VolatileRecord from text.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package logger is the simple logger library for Landns.
|
Package logger is the simple logger library for Landns. |
httplog
Package httplog is logging utilities for HTTP server.
|
Package httplog is logging utilities for HTTP server. |
logtest
Package logtest is the dummy logger for testing Landns.
|
Package logtest is the dummy logger for testing Landns. |
Package testutil is testing helpers for the Landns.
|
Package testutil is testing helpers for the Landns. |