mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-22 04:55:33 +03:00
905f9615a8
Squashed commit of the following: commit 5cf83aafc8ddfea15b4f8e9b4061af021727f68c Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Sep 1 14:58:03 2023 +0300 client: imp code commit 4325c8f610d1329ad38c800e20275668f1690f51 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Sep 1 14:38:33 2023 +0300 all: add client source
54 lines
1 KiB
Go
54 lines
1 KiB
Go
// Package client contains types and logic dealing with AdGuard Home's DNS
|
|
// clients.
|
|
//
|
|
// TODO(a.garipov): Expand.
|
|
package client
|
|
|
|
import (
|
|
"encoding"
|
|
"fmt"
|
|
)
|
|
|
|
// Source represents the source from which the information about the client has
|
|
// been obtained.
|
|
type Source uint8
|
|
|
|
// Clients information sources. The order determines the priority.
|
|
const (
|
|
SourceNone Source = iota
|
|
SourceWHOIS
|
|
SourceARP
|
|
SourceRDNS
|
|
SourceDHCP
|
|
SourceHostsFile
|
|
SourcePersistent
|
|
)
|
|
|
|
// type check
|
|
var _ fmt.Stringer = Source(0)
|
|
|
|
// String returns a human-readable name of cs.
|
|
func (cs Source) String() (s string) {
|
|
switch cs {
|
|
case SourceWHOIS:
|
|
return "WHOIS"
|
|
case SourceARP:
|
|
return "ARP"
|
|
case SourceRDNS:
|
|
return "rDNS"
|
|
case SourceDHCP:
|
|
return "DHCP"
|
|
case SourceHostsFile:
|
|
return "etc/hosts"
|
|
default:
|
|
return ""
|
|
}
|
|
}
|
|
|
|
// type check
|
|
var _ encoding.TextMarshaler = Source(0)
|
|
|
|
// MarshalText implements encoding.TextMarshaler for the Source.
|
|
func (cs Source) MarshalText() (text []byte, err error) {
|
|
return []byte(cs.String()), nil
|
|
}
|