Documentation ¶
Index ¶
Constants ¶
const ReplyTypeUnknown = "UNKNOWN"
Variables ¶
var DnsSecStatuses = map[uint]DnsSecStatus{ 0: DnsSecStatusUnknown, 1: "SECURE", 2: "INSECURE", 3: "BOGUS", 4: "ABANDONED", }
var QueryStatuses = map[uint]status{ 0: {DecisionUnknown, ReasonUnknown}, 1: {DecisionBlocked, ReasonGravity}, 2: {DecisionAllowed, ReasonForwarded}, 3: {DecisionAllowed, ReasonCached}, 4: {DecisionBlocked, ReasonRegexMatch}, 5: {DecisionBlocked, ReasonExactMatch}, 6: {DecisionBlocked, ReasonByUpstream}, 7: {DecisionBlocked, ReasonZeroIP}, 8: {DecisionBlocked, ReasonNxDomain}, 9: {DecisionBlocked, ReasonCnameGravity}, 10: {DecisionBlocked, ReasonCnameRegexMatch}, 11: {DecisionBlocked, ReasonCnameExactMatch}, 12: {DecisionAllowed, ReasonRetried}, 13: {DecisionAllowed, ReasonRetriedIgnored}, 14: {DecisionAllowed, ReasonAlreadyForwarded}, 15: {DecisionBlocked, ReasonDatabaseBusy}, 16: {DecisionBlocked, ReasonSpecialDomain}, 17: {DecisionAllowed, ReasonCachedStale}, }
var QueryTypes = map[uint]QueryType{
1: "A",
2: "AAAA",
3: "ANY",
4: "SRV",
5: "SOA",
6: "PTR",
7: "TXT",
8: "NAPTR",
9: "MX",
10: "DS",
11: "RRSIG",
12: "DNSKEY",
13: "NS",
14: "OTHER",
15: "SVCB",
16: "HTTPS",
}
QueryTypes see https://docs.pi-hole.net/database/ftl/#supported-query-types
var ReplyTypes = map[uint]ReplyType{ 0: ReplyTypeUnknown, 1: "NODATA", 2: "NXDOMAIN", 3: "CNAME", 4: "IP", 5: "DOMAIN", 6: "RRNAME", 7: "SERVFAIL", 8: "REFUSED", 9: "NOTIMP", 10: "OTHER", 11: "DNSSEC", 12: "NONE", 13: "BLOB", }
Functions ¶
func DecodeQueryRecord ¶
func DecodeQueryRecord(row scan.RowsScanner, record *QueryRecord) error
func QueryStatusFromOrdinal ¶
Types ¶
type DnsSecStatus ¶
type DnsSecStatus = string
const DnsSecStatusUnknown DnsSecStatus = "UNKNOWN"
func DnsSecStatusFromOrdinal ¶
func DnsSecStatusFromOrdinal(ordinal uint) DnsSecStatus
type FtlDb ¶
type FtlDb struct {
// contains filtered or unexported fields
}
FtlDb represents a time-bounded slice of Pihole FTL database. It exposes methods to query the underlying data without the need to mess with raw SQL
func Open ¶
Open a Pihole FTL long-term database and create an FtlDb instance. The underlying sqlite database is opened in readonly mode.
func (*FtlDb) RecordCount ¶
RecordCount returns the expected number of records in the TimeBounds
func (*FtlDb) Records ¶
func (db *FtlDb) Records(ctx context.Context) <-chan QueryRecord
Records returns a channel of FTL query records that can be read by further processing logic
func (*FtlDb) Start ¶
Start and End return the actual time bounds for the query log slice. These may differ from requested time bounds due to how Pihole caches logs in memory before committing to the database. This behavior is governed by DBINTERVAL configuration. For more details on this behavior, see https://docs.pi-hole.net/ftldns/configfile/#dbinterval
Start time for this interval is the requested start time, but the end time is set to the timestamp of the last entry in the requested interval at the time of FtlDb instance creation. A special case is when there are zero records within the requested interval, in which case Timestamps here are precise to the second.
type QueryRecord ¶
type QueryRecord struct { Timestamp time.Time `json:"timestamp"` Type QueryType `json:"type"` Decision Decision `json:"decision"` Reason Reason `json:"reason"` Domain string `json:"domain"` Client string `json:"client"` Forward string `json:"forward"` ReplyType ReplyType `json:"reply_type"` ReplyTime time.Duration `json:"reply_time"` DnsSecStatus DnsSecStatus `json:"dnssec"` }
QueryRecord /* QueryRecord record logged by FTL
type QueryType ¶
type QueryType = string
const QueryTypeUNKNOWN QueryType = "UNKNOWN"
QueryTypeUNKNOWN is a special default query type to capture unexpected data
func QueryTypeFromOrdinal ¶
QueryTypeFromOrdinal converts the ordinal value read from FTL database into a QueryType value that is more readily consumed by metrics and log aggregation systems
type RawQueryRecord ¶
type RawQueryRecord struct { Id int `db:"id"` Timestamp int `db:"timestamp"` Type uint `db:"type"` Status uint `db:"status"` Domain string `db:"domain"` Client string `db:"client"` Forward sql.NullString `db:"forward"` ReplyType uint `db:"reply_type"` ReplyTime sql.NullFloat64 `db:"reply_time"` DnsSec uint `db:"dnssec"` }
type Reason ¶
type Reason = string
const ( ReasonUnknown Reason = "UNKNOWN" ReasonGravity Reason = "GRAVITY" ReasonForwarded Reason = "FORWARDED" ReasonCached Reason = "CACHED" ReasonRegexMatch Reason = "REGEX_MATCH" ReasonExactMatch Reason = "EXACT_MATCH" ReasonByUpstream Reason = "BY_UPSTREAM" ReasonZeroIP Reason = "ZERO_IP" ReasonNxDomain Reason = "NXDOMAIN" ReasonCnameGravity Reason = "CNAME_GRAVITY" ReasonCnameRegexMatch Reason = "CNAME_REGEX_MATCH" ReasonCnameExactMatch Reason = "CNAME_EXACT_MATCH" ReasonRetried Reason = "RETRIED" ReasonRetriedIgnored Reason = "RETRIED_IGNORED" ReasonAlreadyForwarded Reason = "ALREADY_FORWARDED" ReasonDatabaseBusy Reason = "DATABASE_BUSY" ReasonSpecialDomain Reason = "SPECIAL_DOMAIN" ReasonCachedStale Reason = "CACHED_STALE" )