refactor(tracex): internally store just the raw certificate (#787)
By just storing the raw certificate we simplify the internal data structure we use. In turn, this enables us to write better unit tests using github.com/google/go-cmp where we can construct the expected result and compare with that. (Yeah, in principle we could also construct the full certificate but I'm not sure it's worth the effort since we basically only care about the raw certificate.) The general idea here is to make tracex more tested. Once it's more tested, I will create separate structs for each event, which is something that measurex also does. Once that is done, we can start ensuring that the code in measurex and the code in tracex do the same thing in terms of storing observations. When also this is done, we can then rewrite measurex to use tracex directly. The overall goal is https://github.com/ooni/probe/issues/2035.
This commit is contained in:
parent
83e3167ce2
commit
9354191b85
7 changed files with 59 additions and 56 deletions
|
|
@ -5,7 +5,6 @@ package tracex
|
|||
//
|
||||
|
||||
import (
|
||||
"crypto/x509"
|
||||
"errors"
|
||||
"net/http"
|
||||
"time"
|
||||
|
|
@ -275,30 +274,30 @@ func (ev *EventWriteOperation) Name() string {
|
|||
|
||||
// Event is one of the events within a trace
|
||||
type EventValue struct {
|
||||
Addresses []string `json:",omitempty"`
|
||||
Address string `json:",omitempty"`
|
||||
DNSQuery []byte `json:",omitempty"`
|
||||
DNSResponse []byte `json:",omitempty"`
|
||||
Data []byte `json:",omitempty"`
|
||||
Duration time.Duration `json:",omitempty"`
|
||||
Err FailureStr `json:",omitempty"`
|
||||
HTTPMethod string `json:",omitempty"`
|
||||
HTTPRequestHeaders http.Header `json:",omitempty"`
|
||||
HTTPResponseHeaders http.Header `json:",omitempty"`
|
||||
HTTPResponseBody []byte `json:",omitempty"`
|
||||
HTTPResponseBodyIsTruncated bool `json:",omitempty"`
|
||||
HTTPStatusCode int `json:",omitempty"`
|
||||
HTTPURL string `json:",omitempty"`
|
||||
Hostname string `json:",omitempty"`
|
||||
NoTLSVerify bool `json:",omitempty"`
|
||||
NumBytes int `json:",omitempty"`
|
||||
Proto string `json:",omitempty"`
|
||||
TLSServerName string `json:",omitempty"`
|
||||
TLSCipherSuite string `json:",omitempty"`
|
||||
TLSNegotiatedProto string `json:",omitempty"`
|
||||
TLSNextProtos []string `json:",omitempty"`
|
||||
TLSPeerCerts []*x509.Certificate `json:",omitempty"`
|
||||
TLSVersion string `json:",omitempty"`
|
||||
Time time.Time `json:",omitempty"`
|
||||
Transport string `json:",omitempty"`
|
||||
Addresses []string `json:",omitempty"`
|
||||
Address string `json:",omitempty"`
|
||||
DNSQuery []byte `json:",omitempty"`
|
||||
DNSResponse []byte `json:",omitempty"`
|
||||
Data []byte `json:",omitempty"`
|
||||
Duration time.Duration `json:",omitempty"`
|
||||
Err FailureStr `json:",omitempty"`
|
||||
HTTPMethod string `json:",omitempty"`
|
||||
HTTPRequestHeaders http.Header `json:",omitempty"`
|
||||
HTTPResponseHeaders http.Header `json:",omitempty"`
|
||||
HTTPResponseBody []byte `json:",omitempty"`
|
||||
HTTPResponseBodyIsTruncated bool `json:",omitempty"`
|
||||
HTTPStatusCode int `json:",omitempty"`
|
||||
HTTPURL string `json:",omitempty"`
|
||||
Hostname string `json:",omitempty"`
|
||||
NoTLSVerify bool `json:",omitempty"`
|
||||
NumBytes int `json:",omitempty"`
|
||||
Proto string `json:",omitempty"`
|
||||
TLSServerName string `json:",omitempty"`
|
||||
TLSCipherSuite string `json:",omitempty"`
|
||||
TLSNegotiatedProto string `json:",omitempty"`
|
||||
TLSNextProtos []string `json:",omitempty"`
|
||||
TLSPeerCerts [][]byte `json:",omitempty"`
|
||||
TLSVersion string `json:",omitempty"`
|
||||
Time time.Time `json:",omitempty"`
|
||||
Transport string `json:",omitempty"`
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue