fix(tracex): generate archival from single transaction-done event (#780)

Tracex contained some fragile code that assembled HTTP measurements
from scattered events, which worked because we were sure we were
performing a single measurement at any given time.

This diff restructures the code to emit a transaction-start and a
transaction-done events only. We have basically removed all the other
events (which we were not using). We kept the transaction-start
though, because it may be useful to see it when reading events. In
any case, what matters here is that we're now using the transaction-done
event aline to generate the archival HTTP measurement.

Hence, the original issue has been addressed. We will possibly
do more refactoring in the future, but for now this seems sufficient.

Part of https://github.com/ooni/probe/issues/2121
This commit is contained in:
Simone Basso
2022-06-01 19:27:47 +02:00
committed by GitHub
parent 153bfe1c57
commit 6212daa54a
9 changed files with 357 additions and 700 deletions
+3 -2
View File
@@ -51,7 +51,8 @@ func (p *HTTPProxy) Start(address string) (net.Listener, error) {
return listener, nil
}
var httpBlockpage451 = []byte(`<html><head>
// HTTPBlockPage451 is the block page returned along with status 451
var HTTPBlockpage451 = []byte(`<html><head>
<title>451 Unavailable For Legal Reasons</title>
</head><body>
<center><h1>451 Unavailable For Legal Reasons</h1></center>
@@ -80,7 +81,7 @@ func (p *HTTPProxy) handle(w http.ResponseWriter, r *http.Request) {
p.hijack(w, r, policy)
case HTTPAction451:
w.WriteHeader(http.StatusUnavailableForLegalReasons)
w.Write(httpBlockpage451)
w.Write(HTTPBlockpage451)
default:
w.WriteHeader(http.StatusInternalServerError)
}