result

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2023 License: BSD-2-Clause-Views Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AlertLevelWarning = iota
	AlertLevelFatal
)
View Source
const (
	// this is not a full list!
	DnsTypeNONE   = 0 // if not filled in
	DnsTypeA      = 1
	DnsTypeNS     = 2
	DnsTypeCNAME  = 5
	DnsTypeSOA    = 6
	DnsTypePTR    = 12
	DnsTypeMX     = 15
	DnsTypeTXT    = 16
	DnsTypeSIG    = 24
	DnsTypeKEY    = 25
	DnsTypeAAAA   = 28
	DnsTypeLOC    = 29
	DnsTypeNAPTR  = 35
	DnsTypeOPT    = 41
	DnsTypeDS     = 43
	DnsTypeRRSIG  = 46
	DnsTypeNSEC   = 47
	DnsTypeDNSKEY = 48
	DnsTypeNSEC3  = 50
	DnsTypeTLSA   = 52
	DnsTypeHTTPS  = 65
	DnsTypeSPF    = 99

	// this is not a full list!
	DnsClassNONE  = 0 // if not filled in
	DnsClassINET  = 1
	DnsClassCHAOS = 3
	DnsClassANY   = 255

	// this is not a full list!
	DnsRcodeNOERR     = 0
	DnsRcodeFORMERR   = 1
	DnsRcodeSERVFAIL  = 2
	DnsRcodeNXDOMAIN  = 3
	DnsRcodeNOTIMP    = 4
	DnsRcodeREFUSED   = 5
	DnsRcodeNOTAUTH   = 9
	DnsRcodeBADVERS   = 16
	DnsRcodeBADCOOKIE = 23
)

Variables

View Source
var DnsClassNames = map[int]string{
	DnsClassNONE:  "N/A",
	DnsClassINET:  "IN",
	DnsClassCHAOS: "CH",
	DnsClassANY:   "ANY",
}

DnsClassNames translates record classes to their names

View Source
var DnsRcodeNames = map[int]string{
	DnsRcodeNOERR:     "NOERR",
	DnsRcodeFORMERR:   "FORMERR",
	DnsRcodeSERVFAIL:  "SERVFAIL",
	DnsRcodeNXDOMAIN:  "NXDOMAIN",
	DnsRcodeNOTIMP:    "NOTIMP",
	DnsRcodeREFUSED:   "REFUSED",
	DnsRcodeNOTAUTH:   "NOAUTH",
	DnsRcodeBADVERS:   "BADVERS",
	DnsRcodeBADCOOKIE: "BADCOOKIE",
}
View Source
var DnsTypeNames = map[int]string{
	DnsTypeNONE:   "N/A",
	DnsTypeA:      "A",
	DnsTypeNS:     "NS",
	DnsTypeCNAME:  "CNAME",
	DnsTypeSOA:    "SOA",
	DnsTypePTR:    "PTR",
	DnsTypeMX:     "MX",
	DnsTypeTXT:    "TXT",
	DnsTypeSIG:    "SIG",
	DnsTypeKEY:    "KEY",
	DnsTypeAAAA:   "AAAA",
	DnsTypeLOC:    "LOC",
	DnsTypeNAPTR:  "NAPTR",
	DnsTypeOPT:    "OPT",
	DnsTypeDS:     "DS",
	DnsTypeRRSIG:  "RRSIG",
	DnsTypeNSEC:   "NSEC",
	DnsTypeDNSKEY: "DNSKEY",
	DnsTypeNSEC3:  "NSEC3",
	DnsTypeTLSA:   "TLSA",
	DnsTypeHTTPS:  "HTTPS",
	DnsTypeSPF:    "SPF",
}

DnsTypeNames translates record types to their names

Functions

This section is empty.

Types

type AsyncResult

type AsyncResult struct {
	Result *Result
	Error  error
}

type BaseResult

type BaseResult struct {
	FirmwareVersion firmwareVersion `json:"fw"`               //
	CodeVersion     string          `json:"mver"`             //
	MeasurementID   uint            `json:"msm_id"`           //
	GroupID         uint            `json:"group_id"`         //
	ProbeID         uint            `json:"prb_id"`           //
	MeasurementName string          `json:"msm_name"`         // measurement name (better use type)
	Type            string          `json:"type"`             // measurement type
	TimeStamp       uniTime         `json:"timestamp"`        // when was this result collected
	StoreTimeStamp  uniTime         `json:"stored_timestamp"` // when was this result stored
	Bundle          uint            `json:"bundle"`           // ID for a collection of related measurement results
	LastTimeSync    int             `json:"lts"`              // how long ago was the probe's clock synced
	DestinationName string          `json:"dst_name"`         //
	DestinationAddr *netip.Addr     `json:"dst_addr"`         //
	SourceAddr      netip.Addr      `json:"src_addr"`         // source address used by probe
	FromAddr        netip.Addr      `json:"from"`             // IP address of the probe as known by the infra
	AddressFamily   uint            `json:"af"`               // 4 or 6
	ResolveTime     *float64        `json:"ttr"`              // only if resolve-on-probe was used
}

func (*BaseResult) BaseDetailString

func (result *BaseResult) BaseDetailString() string

func (*BaseResult) BaseString

func (result *BaseResult) BaseString() string

func (*BaseResult) Destination

func (result *BaseResult) Destination() string

Destination yields the destination name Or if that's not defined then the destination address

func (*BaseResult) GetFirmwareVersion added in v0.6.0

func (result *BaseResult) GetFirmwareVersion() uint

func (*BaseResult) GetProbeID

func (result *BaseResult) GetProbeID() uint

func (*BaseResult) GetTimeStamp

func (result *BaseResult) GetTimeStamp() time.Time

func (*BaseResult) Parse

func (result *BaseResult) Parse(from string) (err error)

func (*BaseResult) StoreDelay

func (res *BaseResult) StoreDelay() int

StoreDelay calculates the difference (in seconds) between taking the measurement and storing it, i.e. how long it took for the result to be available. Be aware that The probe's clock may be inaccurate, so this value is indicative only and may even be negative

func (*BaseResult) TypeName

func (result *BaseResult) TypeName() string

type CertAlert

type CertAlert struct {
	Level       uint //
	Description uint //
}

CertAlert is an error that could be sent by the server see RFC 5246 section 7.2

type CertResult

type CertResult struct {
	BaseResult
	Error           *string            //
	Alert           *CertAlert         //
	Method          string             //
	ConnectTime     float64            //
	ReplyTime       float64            //
	ServerCipher    string             //
	ProtocolVersion string             //
	Certificates    []x509.Certificate //
	DnsError        string             //
}

func (*CertResult) Parse

func (cert *CertResult) Parse(from string) (err error)

func (*CertResult) TypeName

func (result *CertResult) TypeName() string

type ConnectionResult

type ConnectionResult struct {
	BaseResult
	Event      string
	Controller string
	Asn        uint
	Prefix     netip.Prefix
}

func (*ConnectionResult) Parse

func (conn *ConnectionResult) Parse(from string) (err error)

func (*ConnectionResult) TypeName

func (result *ConnectionResult) TypeName() string

type DnsAnswer

type DnsAnswer struct {
	Class int
	Type  int
	Name  string
	Ttl   int
	Data  string
}

DnsAnswer is a (simplified) answer "simplified" means it only contains the full answer encoded in a string

type DnsError

type DnsError struct {
	Timeout  uint
	AddrInfo string
}

DnsError is an error that may have been reported

type DnsQuestion

type DnsQuestion struct {
	Class int
	Type  int
	Name  string
}

DnsQuestion is the question that was asked - as parsed from abuf

type DnsResponse

type DnsResponse struct {
	TimeStamp     time.Time      //
	SourceAddr    netip.Addr     //
	Destination   netip.AddrPort //
	Error         []DnsError     // ?
	AddressFamily uint           //
	Protocol      string         //
	RetryCount    uint           //
	QueryBuf      []byte         //
	ResponseTime  float64        //
	ResponseSize  uint           //

	// overview
	QueryID         uint   //
	QueriesCount    uint   //
	AnswerCount     uint   //
	NameServerCount uint   //
	AdditionalCount uint   //
	Edsn0Nsid       []byte //

	// various bits
	Response           bool //
	Opcode             int  //
	Authoritative      bool //
	Truncated          bool //
	RecursionDesired   bool //
	RecursionAvailable bool //
	Zero               bool //
	AuthenticatedData  bool //
	CheckingDisabled   bool //
	Rcode              int  //

	// details
	AnswerBuf []byte      //
	Question  DnsQuestion //
	Answer    []DnsAnswer //
	Ns        []DnsAnswer //
	Extra     []DnsAnswer //

	Ttl6 uint //
}

DnsResponse holds one response from one server/resolver, with all associated data Various bits like counts and answers are stored here in a simple format which is likely a good fit for many use cases; one could look at all the gory details in the AnswerBuf (abuf) if more details are needed

func (*DnsResponse) AllAnswers

func (resp *DnsResponse) AllAnswers() []DnsAnswer

AllAnswers aggregates all answers from a responses into an array

func (*DnsResponse) Filter

func (resp *DnsResponse) Filter(class int, typ int) []DnsAnswer

Filter filters out the desired class/type answers from all answers in a specific response

type DnsResult

type DnsResult struct {
	BaseResult               //
	Error      []DnsError    // ?
	Responses  []DnsResponse //
}

DnsResult holds a DNS result structure

func (*DnsResult) AllAnswers

func (result *DnsResult) AllAnswers() []DnsAnswer

AllAnswers aggregates all answers from all responses into an array

func (*DnsResult) Filter

func (result *DnsResult) Filter(class int, typ int) []DnsAnswer

Filter filters out the desired class/type answers from all answers

func (*DnsResult) Parse

func (dns *DnsResult) Parse(from string) (err error)

Parse takes a DNS result JSON blob and turns it into a DnsResult object

func (*DnsResult) TypeName

func (result *DnsResult) TypeName() string

TypeName returns the codename for this result type

type HttpResult

type HttpResult struct {
	BaseResult
	Uri             string   //
	HeaderSize      uint     //
	Headers         []string //
	BodySize        uint     //
	Method          string   //
	Version         string   //
	ResultCode      uint     //
	ReplyTime       float64  //
	TimeToConnect   float64  //
	TimeToFirstByte float64  //
	DnsError        string   //
	Error           string   //

}

func (*HttpResult) Parse

func (http *HttpResult) Parse(from string) (err error)

func (*HttpResult) TypeName

func (result *HttpResult) TypeName() string

type IcmpExtension

type IcmpExtension struct {
	Version uint                  //
	Rfc4884 uint                  //
	Objects []IcmpExtensionObject //
}

type IcmpExtensionObject

type IcmpExtensionObject struct {
	Class      uint         //
	Type       uint         //
	MplsObject []MplsObject //
}

type MplsObject

type MplsObject struct {
	Experimental  uint //
	Label         uint //
	BottomOfStack uint //
	Ttl           uint //
}

type NtpReply

type NtpReply struct {
	OriginTimestamp   float64 //
	TransmitTimestamp float64 //
	ReceiveTimestamp  float64 //
	FinalTimestamp    float64 //
	Offset            float64 //
	Rtt               float64 //
}

one successful ntp reply

type NtpResult

type NtpResult struct {
	BaseResult
	Protocol           string     //
	Version            uint       //
	LeapIndicator      string     // "no", "59", "61" or "unknown"
	Mode               string     //
	Stratum            uint       //
	PollInterval       uint       //
	Precision          float64    //
	RootDelay          float64    //
	RootDispersion     float64    //
	ReferenceID        string     //
	ReferenceTimestamp float64    //
	Replies            []NtpReply //
	Errors             []string   //
}

func (*NtpResult) Parse

func (ntp *NtpResult) Parse(from string) (err error)

func (*NtpResult) TypeName

func (result *NtpResult) TypeName() string

type PingReply

type PingReply struct {
	Rtt       float64
	Source    netip.Addr
	Ttl       uint
	Duplicate bool
}

one successful ping reply

type PingResult

type PingResult struct {
	BaseResult
	Sent, Received, Duplicates        uint        //
	Minimum, Average, Median, Maximum float64     // -1 if N/A
	PacketSize                        uint        //
	Protocol                          string      //
	Step                              *uint       //
	Ttl                               uint        //
	Replies                           []PingReply //
	Errors                            []string    //
	Timeouts                          uint        //
}

func (*PingResult) Parse

func (ping *PingResult) Parse(from string) (err error)

func (*PingResult) ReplyRtts

func (result *PingResult) ReplyRtts() []float64

func (*PingResult) TypeName

func (result *PingResult) TypeName() string

type Result

type Result interface {
	Parse(from string) (err error)
	TypeName() string
	GetTimeStamp() time.Time
	GetProbeID() uint
	GetFirmwareVersion() uint
}

func Parse

func Parse(from string) (Result, error)

func ParseWithTypeHint

func ParseWithTypeHint(from string, typehint string) (Result, error)

type TraceRouteHopData

type TraceRouteHopData struct {
	Error            *string         //
	Timeout          bool            //
	ErrorCode        string          // N/H/A/P/p/h/(int)
	From             netip.Addr      //
	ITypeOfService   *uint           //
	ITtl             *uint           //
	ErrorDestination *netip.Addr     //
	Late             *uint           //
	Mtu              *uint           //
	Rtt              float64         //
	Size             uint            //
	Ttl              int             //
	Flags            *string         //
	DestOptSize      *uint           //
	HopByHopOptSize  *uint           //
	IcmpExtensions   []IcmpExtension //
}

type TracerouteHop

type TracerouteHop struct {
	HopNumber uint                //
	SendError *string             //
	Responses []TraceRouteHopData //
}

one hop - error or data

type TracerouteResult

type TracerouteResult struct {
	BaseResult
	EndTime       uniTime         //
	ParisID       uint            //
	Protocol      string          //
	PacketSize    uint            //
	TypeOfService uint            //
	Hops          []TracerouteHop //
}

func (*TracerouteResult) DestinationReached

func (trace *TracerouteResult) DestinationReached() bool

func (*TracerouteResult) Parse

func (trace *TracerouteResult) Parse(from string) (err error)

func (*TracerouteResult) TypeName

func (result *TracerouteResult) TypeName() string

type UptimeResult

type UptimeResult struct {
	BaseResult
	Uptime uint //
}

func (*UptimeResult) Parse

func (uptime *UptimeResult) Parse(from string) (err error)

func (*UptimeResult) TypeName

func (result *UptimeResult) TypeName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL