Documentation ¶
Overview ¶
Package dnsping contains code for sending DNS pings.
Index ¶
- type AbstractEngine
- type ArchivalResult
- type ArchivalSinglePingReply
- type ArchivalSinglePingResult
- type Cache
- type CachingEngine
- type Engine
- type IDGenerator
- type Result
- type SinglePingPlan
- type SinglePingReply
- type SinglePingResult
- func (spr *SinglePingResult) DNSLookupMeasurementList(urlMeasurementID int64, domain string) (out []*measurex.DNSLookupMeasurement)
- func (spr *SinglePingResult) Describe() string
- func (spr *SinglePingResult) QueryTypeAsString() string
- func (spr *SinglePingResult) ToArchival(begin time.Time) *ArchivalSinglePingResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AbstractEngine ¶
type AbstractEngine interface { // RunAsync behaves like Engine.RunAsync RunAsync(plans []*SinglePingPlan) <-chan *Result // NextID returns the next ID. NextID() int64 }
AbstractEngine is an abstract version of the Engine type.
type ArchivalResult ¶
type ArchivalResult struct {
Pings []*ArchivalSinglePingResult `json:"pings"`
}
ArchivalResult is the archival format of Result
type ArchivalSinglePingReply ¶
type ArchivalSinglePingReply struct { Addresses []string `json:"addresses"` ALPNs []string `json:"alpns"` Failure *string `json:"failure"` ID int64 `json:"id"` Rcode string `json:"rcode"` Reply *model.ArchivalBinaryData `json:"reply"` SourceAddress string `json:"source_address"` T float64 `json:"t"` }
ArchivalSinglePingReply is the archival format of SinglePingReply.
type ArchivalSinglePingResult ¶
type ArchivalSinglePingResult struct { Delay float64 `json:"delay"` Hostname string `json:"hostname"` ID int64 `json:"id"` Query *model.ArchivalBinaryData `json:"query"` QueryID int64 `json:"query_id"` QueryType string `json:"query_type"` ResolverAddress string `json:"resolver_address"` T float64 `json:"t"` Replies []*ArchivalSinglePingReply `json:"replies"` }
ArchivalSinglePingResult is the archival format of SinglePingResult.
type Cache ¶
type Cache struct { // DisableNetwork allows to disable network operations. DisableNetwork bool // DNSPing is a reference to the underlying cache. DNSPing *caching.FSCache }
Cache is a cache for dnsping measurements.
func (*Cache) FindSinglePingResult ¶
func (c *Cache) FindSinglePingResult(plan *SinglePingPlan) (*SinglePingResult, bool)
FindSinglePingResult searches for a SinglePingResult compatible with the plan.
func (*Cache) StoreSinglePingResult ¶
func (c *Cache) StoreSinglePingResult(spr *SinglePingResult) error
StoreSinglePingResult stores the given result into the cache.
type CachingEngine ¶
type CachingEngine struct {
// contains filtered or unexported fields
}
CachingEngine is an Engine with caching.
func NewCachingMeasurer ¶
func NewCachingMeasurer(ae AbstractEngine, cache *Cache) *CachingEngine
NewCachingEngine takes in input an existing engine and the cache and returns a new instance of CachingEngine.
func (*CachingEngine) NextID ¶
func (cae *CachingEngine) NextID() int64
NextID implements AbstractEngine.NextID.
func (*CachingEngine) RunAsync ¶
func (cae *CachingEngine) RunAsync(plans []*SinglePingPlan) <-chan *Result
RunAsync implements AbstractEngine.RunAsync.
type Engine ¶
type Engine struct { // Decoder is the MANDATORY specific DNSDecoder to use. Decoder model.DNSDecoder // Encoder is the specific MANDATORY DNSEncoder to use. Encoder model.DNSEncoder // IDGenerator is the MANDATORY IDGenerator to use. IDGenerator IDGenerator // Listener is the specific MANDATORY UDPListener to use. Listener model.UDPListener // QueryTimeout is the MANDATORY query timeout to use. QueryTimeout time.Duration }
Engine is the engine performing a DNS ping session. To initialize, fill all the fields marked as MANDATORY, or just use the NewEngine constructor.
func NewEngine ¶
func NewEngine(idgen IDGenerator, queryTimeout time.Duration) *Engine
NewEngine creates a new engine instance using the given generator, and typical values for other fields.
func (*Engine) RunAsync ¶
func (e *Engine) RunAsync(plans []*SinglePingPlan) <-chan *Result
RunAsync runs the Engine asynchronously and returns the channel on which we'll post the overall result when done. The channel we return is buffered, so you're not going to leak goroutines if you just decide to stop waiting on the channel earlier.
type IDGenerator ¶
type IDGenerator interface {
NextID() int64
}
IDGenerator is a generic unique-IDs generator.
type Result ¶
type Result struct { // Pings contains a list of ping results. If this list is empty, // it means the input plan was empty or wrong. Pings []*SinglePingResult `json:",omitempty"` }
Result is the result of a DNS ping session.
func (*Result) ToArchival ¶
func (ar *Result) ToArchival(begin time.Time) *ArchivalResult
ToArchival returns the archival representation
func (*Result) URLAddressList ¶
func (r *Result) URLAddressList( urlMeasurementID int64, domain string) ([]*measurex.URLAddress, bool)
URLAddressList converts Result to []*URLAddress.
Arguments:
- urlMeasurementID is the URLMeasurement in which context we're working
- domain is the domain to filter dnsping results for
Because dnsping may test several domains in parallel, we need to be sure we only include the one we care about.
type SinglePingPlan ¶
type SinglePingPlan struct { // ResolverAddress is the resolver's address (e.g., 8.8.8.8:53). ResolverAddress string // Delay is the delay since the beginning of the ping // session after which we should send this ping. // // The maximum timeout of the ping session is equal to the // maximum delay plus the engine's DNSTimeout. Delay time.Duration // Domain is the domain to query. If the domain is not a // FQDN, we'll convert it to FQDN form. For example, this // means that we'll convert `x.org` to `x.org.`. Domain string // QueryType is the type of query to send. We accept the // following query types: `dns.Type{A,AAAA,HTTPS}`. QueryType uint16 // contains filtered or unexported fields }
SinglePingPlan is the plan to perform a single DNS ping.
func NewDefaultPlans ¶
func NewDefaultPlans(domain string, queryType uint16, resolver string, repetitions int) (out []*SinglePingPlan)
NewDefaultPlans creates plans with the given number of repetitions.
type SinglePingReply ¶
type SinglePingReply struct { // ID is the unique ID of this reply. ID int64 // SourceAddress is the address from which we received the reply. SourceAddress string // Reply contains the bytes of the DNS reply. Reply []byte // Error is the (netxlite-wrapped) error that occurred. We can // see two kinds of errors here: // // 1. errors that depend on the Rcode (e.g., dns_nxdomain_error); // // 2. errors that depend on the response not containing any // valid IP address (e.g., dns_no_answers). Error archival.FlatFailure // Finished is when we received this ping reply. Finished time.Time // Rcode contains the response rcode. Rcode string // Addresses contains the resolved addresses. Addresses []string // ALPNs contains the resolved ALPNs. ALPNs []string }
SinglePingReply is one of the replies to a single DNS ping. In principle, there should only be one, but there may be more than one with censorship or packet duplication.
func (*SinglePingReply) ToArchival ¶
func (spr *SinglePingReply) ToArchival(begin time.Time) *ArchivalSinglePingReply
ToArchival returns the archival representation
type SinglePingResult ¶
type SinglePingResult struct { // ID is the unique ID of this result. ID int64 // ResolverAddress is the resolver's address (e.g., 8.8.8.8:53). ResolverAddress string // Delay is the original delay. Delay time.Duration // Domain is the domain we queried. If the domain is not // a FQDN, we'll convert it to FQDN form. For example, this // means that we'll convert `x.org` to `x.org.`. Domain string // QueryType is the type of query we sent. We accept the // following query types: `dns.Type{A,AAAA,HTTPS}`. QueryType uint16 // QueryID is the query ID. QueryID uint16 // Query contains the bytes of the query we have sent. Query []byte // Started is when we sent the query. Started time.Time // Replies contains the replies for this query. This field will // be empty if we've got no replies. In the common case, it // will contain just one entry. It may contain more than one // entry in case of censorship or packet duplication. Replies []*SinglePingReply }
SinglePingResult is the result of a single DNS ping. In most cases, each query will receive a single reply, but with censorship and packet duplication we may receive more than one (or none).
func (*SinglePingResult) DNSLookupMeasurementList ¶
func (spr *SinglePingResult) DNSLookupMeasurementList( urlMeasurementID int64, domain string) (out []*measurex.DNSLookupMeasurement)
DNSLookupMeasurementList converts a SinglePingResult into a list containing DNSLookupMeasurement instances.
func (*SinglePingResult) Describe ¶
func (spr *SinglePingResult) Describe() string
Describe returns a human readable description.
func (*SinglePingResult) QueryTypeAsString ¶
func (spr *SinglePingResult) QueryTypeAsString() string
QueryTypeAsString returns the QueryType as string.
func (*SinglePingResult) ToArchival ¶
func (spr *SinglePingResult) ToArchival(begin time.Time) *ArchivalSinglePingResult
ToArchival returns the archival representation