Documentation ¶
Index ¶
- Variables
- func DeleteIfContains(keywords []string, src []dns.RR) []dns.RR
- type DNSModifier
- type DnsServer
- func (s *DnsServer) AddEntry(name string, rr dns.RR)
- func (s *DnsServer) ControllerForName(origin string) *RecordController
- func (s *DnsServer) DnsFlags() *Flags
- func (s *DnsServer) HandleControllers()
- func (s *DnsServer) HandleIncoming(writer dns.ResponseWriter, incoming *dns.Msg)
- func (s *DnsServer) NewControllerForName(origin string) *RecordController
- func (s *DnsServer) ParseDNS(m *dns.Msg)
- func (s *DnsServer) RemoveFromEntry(name string, keywords []string, rType uint16)
- func (s *DnsServer) Run() error
- func (s *DnsServer) SetEntry(name string, records []dns.RR)
- func (s *DnsServer) Stop() error
- type Flags
- type IFlags
- type RecordController
- func (rc *RecordController) AddRecords(rr []dns.RR)
- func (rc RecordController) Close()
- func (rc *RecordController) DeleteRecords(keywords []string, recordType uint16)
- func (rc *RecordController) EditRecords(rrs []dns.RR, keywords []string)
- func (rc *RecordController) FetchRecords(t uint16) []dns.RR
- func (rc *RecordController) SetRecords(rr []dns.RR)
- type RecordControllerErr
- type RecordOp
Constants ¶
This section is empty.
Variables ¶
var (
UnSupportedTypeErr = errors.New("type of record not supported")
)
Functions ¶
Types ¶
type DNSModifier ¶
func WithDomains ¶
func WithDomains(domains []string) DNSModifier
func WithHost ¶
func WithHost(ip string) DNSModifier
func WithLogger ¶
func WithLogger(l logger.Logger) DNSModifier
func WithPort ¶
func WithPort(p int) DNSModifier
func WithTCPListener ¶
func WithTCPListener(l net.Listener) DNSModifier
func WithUDPListener ¶
func WithUDPListener(l net.PacketConn) DNSModifier
type DnsServer ¶
type DnsServer struct { Flags *Flags Logger logger.Logger Port int Domains []string // contains filtered or unexported fields }
func NewDNS ¶
func NewDNS(mods ...DNSModifier) (*DnsServer, error)
func (*DnsServer) ControllerForName ¶
func (s *DnsServer) ControllerForName(origin string) *RecordController
ControllerForName will return the controller specified for a specific domain or subdomain. If it does not exist, it will return nil.
func (*DnsServer) HandleControllers ¶
func (s *DnsServer) HandleControllers()
func (*DnsServer) HandleIncoming ¶
func (s *DnsServer) HandleIncoming(writer dns.ResponseWriter, incoming *dns.Msg)
HandleIncoming is the entry point to the dns server, no request logic lives here, only dns.Server specific configs.
func (*DnsServer) NewControllerForName ¶
func (s *DnsServer) NewControllerForName(origin string) *RecordController
NewControllerForName will return the controller specified for a specific domain or subdomain. If it does not exist, it will create a new one.
func (*DnsServer) ParseDNS ¶
ParseDNS will only handle dns requests from Domains that it is specified to handle. It will modify the *dns.Msg in place.
func (*DnsServer) RemoveFromEntry ¶
RemoveFromEntry will delete any entries that container the keywords in the record type.
func (*DnsServer) Run ¶
Run starts the server and is blocking. It will return an error on close if it did not exit gracefully. To close the DnsServer gracefully, call Stop.
type RecordController ¶
RecordController is a controller that specifically controls a single domain. It handles adding, removing and editing dns records in place and should never error out. All methods write errors to the controllers error channel, and operate on a fire and forget methodology. I works like a running server, and to prevent leaks you must call Close.
func NewRecordController ¶
func NewRecordController(l logger.Logger) *RecordController
NewRecordController create a new controller for a specified origin, or basename;
func (*RecordController) AddRecords ¶
func (rc *RecordController) AddRecords(rr []dns.RR)
AddRecords will arbitrarily add records to the controller if they match the origin of the controller as well as if they are of the currently support record type. If any errors occur, it will write to the general error channel
func (RecordController) Close ¶
func (rc RecordController) Close()
func (*RecordController) DeleteRecords ¶
func (rc *RecordController) DeleteRecords(keywords []string, recordType uint16)
DeleteRecords will delete records that match the keywords provided. Case sensitive/no processing is done TODO(adam): support regex?
func (*RecordController) EditRecords ¶
func (rc *RecordController) EditRecords(rrs []dns.RR, keywords []string)
EditRecords will replace records that match the keywords. if the supplied records also match are of the currently support record type. If any errors occur, it will write to the general error channel
func (*RecordController) FetchRecords ¶
func (rc *RecordController) FetchRecords(t uint16) []dns.RR
FetchRecords will return the []dns.RR of whatever records type is inputted. If the controller does not recognize the record type, or if no records of that type exists, it will return an empty list. It takes in a dns.Type.
func (*RecordController) SetRecords ¶
func (rc *RecordController) SetRecords(rr []dns.RR)
SetRecords will hard replace records of type recordType in controller. are of the currently support record type. If any errors occur, it will write to the general error channel
type RecordControllerErr ¶
type RecordControllerErr error