Documentation ¶
Overview ¶
Package archival is a haveily modified copy of probe-cli internal/archival.
Index ¶
- Variables
- func FlatFailureToStringOrOK(ff FlatFailure) string
- func MaybeGatherCNAME(rts []*FlatDNSRoundTripEvent) string
- func NewArchivalDNSLookupResultList(begin time.Time, in []*FlatDNSLookupEvent) (out []model.ArchivalDNSLookupResult)deprecated
- func NewArchivalDNSRoundTripEventList(begin time.Time, in []*FlatDNSRoundTripEvent) (out []model.ArchivalDNSLookupResult)
- func NewArchivalHTTPRequestResultList(begin time.Time, in []*FlatHTTPRoundTripEvent, bodyFlags int64) (out []model.ArchivalHTTPRequestResult)
- func NewArchivalNetworkEventList(begin time.Time, in []*FlatNetworkEvent) (out []model.ArchivalNetworkEvent)
- func NewArchivalTCPConnectResultList(begin time.Time, in []*FlatNetworkEvent) (out []model.ArchivalTCPConnectResult)
- func NewArchivalTLSOrQUICHandshakeResultList(begin time.Time, in []*FlatQUICTLSHandshakeEvent) (out []model.ArchivalTLSOrQUICHandshakeResult)
- func NewHTTPHeadersList(source http.Header) (out []model.ArchivalHTTPHeader)
- type DNSLookupType
- type FlatDNSLookupEvent
- type FlatDNSRoundTripEvent
- type FlatFailure
- type FlatHTTPRoundTripEvent
- type FlatNetworkEvent
- type FlatQUICTLSHandshakeEvent
- type NetworkType
- type Saver
- func (s *Saver) MoveOutTrace() *Trace
- func (s *Saver) WrapConn(conn net.Conn) net.Conn
- func (s *Saver) WrapDNSTransport(txp model.DNSTransport) model.DNSTransport
- func (s *Saver) WrapDialer(dialer model.Dialer) model.Dialer
- func (s *Saver) WrapHTTPTransport(txp model.HTTPTransport, maxBodySnapshotSize int64) model.HTTPTransport
- func (s *Saver) WrapQUICDialer(qd model.QUICDialer) model.QUICDialer
- func (s *Saver) WrapResolver(reso model.Resolver) model.Resolver
- func (s *Saver) WrapTLSHandshaker(thx model.TLSHandshaker) model.TLSHandshaker
- func (s *Saver) WrapUDPListener(ql model.UDPListener) model.UDPListener
- type Trace
- func (t *Trace) NewArchivalDNSLookupResultList(begin time.Time) []model.ArchivalDNSLookupResultdeprecated
- func (t *Trace) NewArchivalDNSRoundTripEventList(begin time.Time) []model.ArchivalDNSLookupResult
- func (t *Trace) NewArchivalHTTPRequestResultList(begin time.Time, bodyFlags int64) []model.ArchivalHTTPRequestResult
- func (t *Trace) NewArchivalNetworkEventList(begin time.Time) []model.ArchivalNetworkEvent
- func (t *Trace) NewArchivalTCPConnectResultList(begin time.Time) []model.ArchivalTCPConnectResult
- func (t *Trace) NewArchivalTLSOrQUICHandshakeResultList(begin time.Time) []model.ArchivalTLSOrQUICHandshakeResult
Constants ¶
This section is empty.
Variables ¶
var ( // NetworkTypeTCP indicates we're using TCP. NetworkTypeTCP = NetworkType("tcp") // NetworkTypeUDP indicates we're using UDP. NetworkTypeUDP = NetworkType("udp") // NetworkTypeQUIC indicates we're using QUIC. NetworkTypeQUIC = NetworkType("quic") // NetworkTypeDoT indicates we're using DNS-over-TLS. NetworkTypeDoT = NetworkType("dot") // NetworkTypeDoH indicates we're using DNS-over-HTTPS. NetworkTypeDoH = NetworkType("doh") // NetworkTypeDoH3 indicates we're using DNS-over-HTTP3. NetworkTypeDoH3 = NetworkType("doh3") // NetworkTypeSystem identifies the system resolver. NetworkTypeSystem = NetworkType("system") )
var ( // DNSLookupTypeGetaddrinfo indicates a getaddrinfo like lookup where we // issue a query for A and a query for AAAA. DNSLookupTypeGetaddrinfo = DNSLookupType("getaddrinfo") // DNSLookupTypeHTTPS indicates we're performing an HTTPS lookup. DNSLookupTypeHTTPS = DNSLookupType("https") // DNSLookupTypeNS indicates we're performing a NS lookup type. DNSLookupTypeNS = DNSLookupType("ns") // DNSLookupTypeReverse indicates we're performing a reverse lookup. DNSLookupTypeReverse = DNSLookupType("reverse") )
Functions ¶
func FlatFailureToStringOrOK ¶
func FlatFailureToStringOrOK(ff FlatFailure) string
FlatFailureToStringOrOK returns either a flat failure or ok.
func MaybeGatherCNAME ¶
func MaybeGatherCNAME(rts []*FlatDNSRoundTripEvent) string
MaybeGatherCNAME tries to read the CNAME from DNSRoundTripEvents. If there is zero or more than one CNAMEs in the reply, we return an empty string.
func NewArchivalDNSLookupResultList
deprecated
func NewArchivalDNSLookupResultList(begin time.Time, in []*FlatDNSLookupEvent) (out []model.ArchivalDNSLookupResult)
NewArchivalDNSLookupResultList builds a DNS lookups list in the OONI archival data format out of the results saved inside the trace.
Deprecated: new code should obtain the archival data format from the DNS round trip rather than from the DNS lookup result.
func NewArchivalDNSRoundTripEventList ¶
func NewArchivalDNSRoundTripEventList(begin time.Time, in []*FlatDNSRoundTripEvent) (out []model.ArchivalDNSLookupResult)
NewArchivalDNSRoundTripEventList converts the DNSRoundTripEvent list inside the trace to the corresponding archival format.
func NewArchivalHTTPRequestResultList ¶
func NewArchivalHTTPRequestResultList(begin time.Time, in []*FlatHTTPRoundTripEvent, bodyFlags int64) (out []model.ArchivalHTTPRequestResult)
NewArchivalHTTPRequestResultList builds an HTTP requests list in the OONI archival data format out of the results saved inside the trace.
This function will sort the emitted list of requests such that the last request that happened in time is the first one to be emitted. If the measurement code performs related requests sequentially (which is a kinda a given because you cannot follow a redirect before reading the previous request), then the result is sorted how the OONI pipeline expects it to be.
func NewArchivalNetworkEventList ¶
func NewArchivalNetworkEventList(begin time.Time, in []*FlatNetworkEvent) (out []model.ArchivalNetworkEvent)
NewArchivalNetworkEventList builds a network events list in the OONI archival data format out of the results saved inside the trace.
func NewArchivalTCPConnectResultList ¶
func NewArchivalTCPConnectResultList(begin time.Time, in []*FlatNetworkEvent) (out []model.ArchivalTCPConnectResult)
NewArchivalTCPConnectResultList builds a TCP connect list in the OONI archival data format out of the results saved inside the trace.
func NewArchivalTLSOrQUICHandshakeResultList ¶
func NewArchivalTLSOrQUICHandshakeResultList( begin time.Time, in []*FlatQUICTLSHandshakeEvent) (out []model.ArchivalTLSOrQUICHandshakeResult)
NewArchivalTLSOrQUICHandshakeResultList builds a TLS/QUIC handshakes list in the OONI archival data format out of the results saved inside the trace.
func NewHTTPHeadersList ¶
func NewHTTPHeadersList(source http.Header) (out []model.ArchivalHTTPHeader)
NewHTTPHeadersList converts a list HTTP headers to a list of archival HTTP headers.
Types ¶
type FlatDNSLookupEvent ¶
type FlatDNSLookupEvent struct { ALPNs []string `json:",omitempty"` Addresses []string `json:",omitempty"` CNAME string `json:",omitempty"` Domain string Failure FlatFailure `json:",omitempty"` Finished time.Time LookupType DNSLookupType NS []string `json:",omitempty"` PTRs []string `json:",omitempty"` ResolverAddress string `json:",omitempty"` ResolverNetwork NetworkType Started time.Time }
FlatDNSLookupEvent contains the results of a DNS lookup.
func NewFakeFlatDNSLookupEvent ¶
func NewFakeFlatDNSLookupEvent(resolverNetwork NetworkType, resolverAddress string, lookupType DNSLookupType, domain string, alpns, addresses []string) *FlatDNSLookupEvent
NewFakeFlatDNSLookupEvent creates a fake FlatDNSLookupEvent using the given values.
func (*FlatDNSLookupEvent) ToArchival
deprecated
func (ev *FlatDNSLookupEvent) ToArchival(begin time.Time) []model.ArchivalDNSLookupResult
ToArchival converts a FlatDNSLookupEvent to []ArchivalDNSLookupResult.
Deprecated: new code should obtain the archival data format from the DNS round trip rather than from the DNS lookup result.
type FlatDNSRoundTripEvent ¶
type FlatDNSRoundTripEvent struct { Failure FlatFailure `json:",omitempty"` Finished time.Time Query []byte `json:",omitempty"` Reply []byte `json:",omitempty"` ResolverAddress string `json:",omitempty"` ResolverNetwork NetworkType Started time.Time }
FlatDNSRoundTripEvent contains the result of a DNS round trip.
func (*FlatDNSRoundTripEvent) ToArchival ¶
func (ev *FlatDNSRoundTripEvent) ToArchival(begin time.Time) *model.ArchivalDNSLookupResult
ToArchival converts a FlatDNSRoundTripEvent into ArchivalDNSRoundTripEvent.
type FlatFailure ¶
type FlatFailure string
FlatFailure is the flat data format representation of failure.
func NewFlatFailure ¶
func NewFlatFailure(err error) FlatFailure
NewFlatFailure constructs a new FlatFailure from an error.
func (FlatFailure) IsSuccess ¶
func (ff FlatFailure) IsSuccess() bool
IsSuccess returns true if there is no failure, false otherwise.
func (FlatFailure) ToArchivalFailure ¶
func (ff FlatFailure) ToArchivalFailure() *string
ToArchivalFailure converts from FlatFailure to ArchivalFailure.
type FlatHTTPRoundTripEvent ¶
type FlatHTTPRoundTripEvent struct { Failure FlatFailure `json:",omitempty"` Finished time.Time Method string RequestHeaders http.Header ResponseBody []byte `json:",omitempty"` ResponseBodyIsTruncated bool `json:",omitempty"` ResponseBodyLength int64 `json:",omitempty"` ResponseBodyTLSH string `json:",omitempty"` ResponseHeaders http.Header `json:",omitempty"` Started time.Time StatusCode int64 `json:",omitempty"` Transport string URL string }
FlatHTTPRoundTripEvent contains an HTTP round trip.
func (*FlatHTTPRoundTripEvent) ToArchival ¶
func (ev *FlatHTTPRoundTripEvent) ToArchival(begin time.Time, bodyFlags int64) model.ArchivalHTTPRequestResult
ToArchival converts a FlatHTTPRoundTripEvent to ArchivalHTTPRequestResult.
type FlatNetworkEvent ¶
type FlatNetworkEvent struct { Count int64 `json:",omitempty"` Failure FlatFailure `json:",omitempty"` Finished time.Time Network NetworkType `json:",omitempty"` Operation string RemoteAddr string `json:",omitempty"` Started time.Time }
FlatNetworkEvent contains a network event. This kind of events are generated by Dialer, QUICDialer, Conn, QUICConn.
func (*FlatNetworkEvent) ToArchivalNetworkEvent ¶
func (ev *FlatNetworkEvent) ToArchivalNetworkEvent(begin time.Time) model.ArchivalNetworkEvent
ToArchivalNetworkEvent converts a FlatNetworkEvent to ArchivalNetworkEvent.
func (*FlatNetworkEvent) ToArchivalTCPConnectResult ¶
func (ev *FlatNetworkEvent) ToArchivalTCPConnectResult(begin time.Time) model.ArchivalTCPConnectResult
ToArchivalTCPConnectResult converts a FlatNetworkEvent to ArchivalTCPConnectResult.
type FlatQUICTLSHandshakeEvent ¶
type FlatQUICTLSHandshakeEvent struct { ALPN []string `json:",omitempty"` CipherSuite string `json:",omitempty"` Failure FlatFailure `json:",omitempty"` Finished time.Time NegotiatedProto string `json:",omitempty"` Network NetworkType PeerCerts [][]byte `json:",omitempty"` RemoteAddr string SNI string SkipVerify bool `json:",omitempty"` Started time.Time TLSVersion string `json:",omitempty"` }
FlatQUICTLSHandshakeEvent contains a QUIC or TLS handshake event.
func (*FlatQUICTLSHandshakeEvent) ToArchival ¶
func (ev *FlatQUICTLSHandshakeEvent) ToArchival(begin time.Time) model.ArchivalTLSOrQUICHandshakeResult
ToArchival converts FlatQUICTLSHandshakeEvent to ArchivalTLSOrQUICHandshakeResult.
type Saver ¶
type Saver struct {
// contains filtered or unexported fields
}
Saver allows to save network, DNS, QUIC, TLS, HTTP events.
You MUST use NewSaver to create a new instance.
func NewSaver ¶
func NewSaver() *Saver
NewSaver creates a new Saver instance.
You MUST use this function to create a Saver.
func (*Saver) MoveOutTrace ¶
MoveOutTrace moves the current trace out of the saver and creates a new empty trace inside it.
func (*Saver) WrapDNSTransport ¶
func (s *Saver) WrapDNSTransport(txp model.DNSTransport) model.DNSTransport
WrapDNSTransport wraps a DNS transport to use the saver.
func (*Saver) WrapDialer ¶
WrapDialer wraps a dialer to use the saver.
func (*Saver) WrapHTTPTransport ¶
func (s *Saver) WrapHTTPTransport(txp model.HTTPTransport, maxBodySnapshotSize int64) model.HTTPTransport
WrapHTTPTransport wraps an HTTP transport to use this saver. The maxBodySnapshotSize argument controls the maximum size of the body snapshot that we collect along with the HTTP round trip.
func (*Saver) WrapQUICDialer ¶
func (s *Saver) WrapQUICDialer(qd model.QUICDialer) model.QUICDialer
WrapQUICDialer wraps a QUICDialer to use the saver.
func (*Saver) WrapResolver ¶
WrapResolver wraps a resolver to use the saver.
func (*Saver) WrapTLSHandshaker ¶
func (s *Saver) WrapTLSHandshaker(thx model.TLSHandshaker) model.TLSHandshaker
WrapTLSHandshaker wraps a TLS handshaker to use the saver.
func (*Saver) WrapUDPListener ¶
func (s *Saver) WrapUDPListener(ql model.UDPListener) model.UDPListener
WrapUDPListener wraps a UDPListener to use the saver.
type Trace ¶
type Trace struct { // DNSLookup contains DNSLookup events. DNSLookup []*FlatDNSLookupEvent // DNSRoundTrip contains DNSRoundTrip events. DNSRoundTrip []*FlatDNSRoundTripEvent // HTTPRoundTrip contains HTTPRoundTrip round trip events. HTTPRoundTrip []*FlatHTTPRoundTripEvent // Network contains network events. Network []*FlatNetworkEvent // QUICTLSHandshake contains QUICTLSHandshake handshake events. QUICTLSHandshake []*FlatQUICTLSHandshakeEvent // TCPConnect contains TCP connect events. TCPConnect []*FlatNetworkEvent }
Trace contains the events.
func (*Trace) NewArchivalDNSLookupResultList
deprecated
func (t *Trace) NewArchivalDNSLookupResultList(begin time.Time) []model.ArchivalDNSLookupResult
NewArchivalDNSLookupResultList builds a DNS lookups list in the OONI archival data format out of the results saved inside the trace.
Deprecated: new code should obtain the archival data format from the DNS round trip rather than from the DNS lookup result.
func (*Trace) NewArchivalDNSRoundTripEventList ¶
func (t *Trace) NewArchivalDNSRoundTripEventList(begin time.Time) []model.ArchivalDNSLookupResult
NewArchivalDNSRoundTripEventList converts the DNSRoundTripEvent list inside the trace to the corresponding archival format.
func (*Trace) NewArchivalHTTPRequestResultList ¶
func (t *Trace) NewArchivalHTTPRequestResultList( begin time.Time, bodyFlags int64) []model.ArchivalHTTPRequestResult
NewArchivalHTTPRequestResultList builds an HTTP requests list in the OONI archival data format out of the results saved inside the trace.
This function will sort the emitted list of requests such that the last request that happened in time is the first one to be emitted. If the measurement code performs related requests sequentially (which is a kinda a given because you cannot follow a redirect before reading the previous request), then the result is sorted how the OONI pipeline expects it to be.
func (*Trace) NewArchivalNetworkEventList ¶
func (t *Trace) NewArchivalNetworkEventList(begin time.Time) []model.ArchivalNetworkEvent
NewArchivalNetworkEventList builds a network events list in the OONI archival data format out of the results saved inside the trace.
func (*Trace) NewArchivalTCPConnectResultList ¶
func (t *Trace) NewArchivalTCPConnectResultList(begin time.Time) []model.ArchivalTCPConnectResult
NewArchivalTCPConnectResultList builds a TCP connect list in the OONI archival data format out of the results saved inside the trace.
func (*Trace) NewArchivalTLSOrQUICHandshakeResultList ¶
func (t *Trace) NewArchivalTLSOrQUICHandshakeResultList(begin time.Time) []model.ArchivalTLSOrQUICHandshakeResult
NewArchivalTLSOrQUICHandshakeResultList builds a TLS/QUIC handshakes list in the OONI archival data format out of the results saved inside the trace.