Documentation ¶
Overview ¶
Package client contains types and logic dealing with AdGuard Home's DNS clients.
TODO(a.garipov): Expand.
Index ¶
Constants ¶
const ErrClosed errors.Error = "use of closed address processor"
ErrClosed is returned from [AddressProcessor.Close] if it's closed more than once.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddressProcessor ¶
AddressProcessor is the interface for types that can process clients.
type AddressUpdater ¶
type AddressUpdater interface { // UpdateAddress updates information about an IP address, setting host (if // not empty) and WHOIS information (if not nil). UpdateAddress(ip netip.Addr, host string, info *whois.Info) }
AddressUpdater is the interface for storages of DNS clients that can update information about them.
TODO(a.garipov): Consider using the actual client storage once it is moved into this package.
type DefaultAddrProc ¶
type DefaultAddrProc struct {
// contains filtered or unexported fields
}
DefaultAddrProc processes incoming client addresses with rDNS and WHOIS, if configured, and updates that information in a client storage.
func NewDefaultAddrProc ¶
func NewDefaultAddrProc(c *DefaultAddrProcConfig) (p *DefaultAddrProc)
NewDefaultAddrProc returns a new running client address processor. c must not be nil.
func (*DefaultAddrProc) Close ¶
func (p *DefaultAddrProc) Close() (err error)
Close implements the AddressProcessor interface for *DefaultAddrProc.
func (*DefaultAddrProc) Process ¶
func (p *DefaultAddrProc) Process(ip netip.Addr)
Process implements the AddressProcessor interface for *DefaultAddrProc.
type DefaultAddrProcConfig ¶
type DefaultAddrProcConfig struct { // DialContext is used to create TCP connections to WHOIS servers. // DialContext must not be nil if [DefaultAddrProcConfig.UseWHOIS] is true. DialContext aghnet.DialContextFunc // Exchanger is used to perform rDNS queries. Exchanger must not be nil if // [DefaultAddrProcConfig.UseRDNS] is true. Exchanger rdns.Exchanger // PrivateSubnets are used to determine if an incoming IP address is // private. It must not be nil. PrivateSubnets netutil.SubnetSet // AddressUpdater is used to update the information about a client's IP // address. It must not be nil. AddressUpdater AddressUpdater // InitialAddresses are the addresses that are queued for processing // immediately by [NewDefaultAddrProc]. InitialAddresses []netip.Addr // CatchPanics, if true, makes the address processor catch and log panics. // // TODO(a.garipov): Consider better ways to do this or apply this method to // other parts of the codebase. CatchPanics bool // UseRDNS, if true, enables resolving of client IP addresses using reverse // DNS. UseRDNS bool // UsePrivateRDNS, if true, enables resolving of private client IP addresses // using reverse DNS. See [DefaultAddrProcConfig.PrivateSubnets]. UsePrivateRDNS bool // UseWHOIS, if true, enables resolving of client IP addresses using WHOIS. UseWHOIS bool }
DefaultAddrProcConfig is the configuration structure for address processors.
type EmptyAddrProc ¶
type EmptyAddrProc struct{}
EmptyAddrProc is an AddressProcessor that does nothing.
func (EmptyAddrProc) Close ¶
func (EmptyAddrProc) Close() (_ error)
Close implements the AddressProcessor interface for EmptyAddrProc.
func (EmptyAddrProc) Process ¶
func (EmptyAddrProc) Process(_ netip.Addr)
Process implements the AddressProcessor interface for EmptyAddrProc.
type Runtime ¶ added in v0.107.44
type Runtime struct {
// contains filtered or unexported fields
}
Runtime is a client information from different sources.
func (*Runtime) Info ¶ added in v0.107.44
Info returns a client information from the highest-priority source.
func (*Runtime) IsEmpty ¶ added in v0.107.44
IsEmpty returns true if there is no information from any source.
func (*Runtime) SetInfo ¶ added in v0.107.44
SetInfo sets a host as a client information from the cs.
func (*Runtime) SetWHOIS ¶ added in v0.107.44
SetWHOIS sets a WHOIS client information. info must be non-nil.
type Source ¶ added in v0.107.37
type Source uint8
Source represents the source from which the information about the client has been obtained.
const ( SourceWHOIS Source = iota + 1 SourceARP SourceRDNS SourceDHCP SourceHostsFile SourcePersistent )
Clients information sources. The order determines the priority.
func (Source) MarshalText ¶ added in v0.107.37
MarshalText implements encoding.TextMarshaler for the Source.