Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
bassosimone committed Feb 6, 2024
1 parent d0bf708 commit 8ee91e7
Show file tree
Hide file tree
Showing 13 changed files with 123 additions and 157 deletions.
22 changes: 9 additions & 13 deletions internal/experiment/dash/measurer.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,27 +127,23 @@ func NewExperimentMeasurer(config Config) model.ExperimentMeasurer {
var _ model.MeasurementSummaryKeysProvider = &TestKeys{}

// SummaryKeys contains summary keys for this experiment.
//
// Note that this structure is part of the ABI contract with ooniprobe
// therefore we should be careful when changing it.
type SummaryKeys struct {
Latency float64 `json:"connect_latency"`
Bitrate float64 `json:"median_bitrate"`
Delay float64 `json:"min_playout_delay"`
IsAnomaly bool `json:"-"`
}

// MeasurementSummaryKeys implements model.MeasurementSummaryKeysProvider.
func (tk *TestKeys) MeasurementSummaryKeys() model.MeasurementSummaryKeys {
sk := &SummaryKeys{IsAnomaly: false}
sk.Latency = tk.Simple.ConnectLatency
sk.Bitrate = float64(tk.Simple.MedianBitrate)
sk.Delay = tk.Simple.MinPlayoutDelay
return sk
}

// Anomaly implements model.MeasurementSummary.
func (sk *SummaryKeys) Anomaly() bool {
return sk.IsAnomaly
}

// MeasurementSummaryKeys implements model.MeasurementSummaryKeysProvider.
func (tk *TestKeys) MeasurementSummaryKeys() model.MeasurementSummaryKeys {
return &SummaryKeys{
Latency: tk.Simple.ConnectLatency,
Bitrate: float64(tk.Simple.MedianBitrate),
Delay: tk.Simple.MinPlayoutDelay,
IsAnomaly: false,
}
}
23 changes: 10 additions & 13 deletions internal/experiment/fbmessenger/fbmessenger.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,27 +210,24 @@ func NewExperimentMeasurer(config Config) model.ExperimentMeasurer {
var _ model.MeasurementSummaryKeysProvider = &TestKeys{}

// SummaryKeys contains summary keys for this experiment.
//
// Note that this structure is part of the ABI contract with ooniprobe
// therefore we should be careful when changing it.
type SummaryKeys struct {
DNSBlocking bool `json:"facebook_dns_blocking"`
TCPBlocking bool `json:"facebook_tcp_blocking"`
IsAnomaly bool `json:"-"`
}

// Anomaly implements model.MeasurementSummary.
func (sk *SummaryKeys) Anomaly() bool {
return sk.IsAnomaly
}

// MeasurementSummaryKeys implements model.MeasurementSummaryKeysProvider.
func (tk *TestKeys) MeasurementSummaryKeys() model.MeasurementSummaryKeys {
sk := &SummaryKeys{IsAnomaly: false}
dnsBlocking := tk.FacebookDNSBlocking != nil && *tk.FacebookDNSBlocking
tcpBlocking := tk.FacebookTCPBlocking != nil && *tk.FacebookTCPBlocking
return &SummaryKeys{
DNSBlocking: dnsBlocking,
TCPBlocking: tcpBlocking,
IsAnomaly: dnsBlocking || tcpBlocking,
}
sk.DNSBlocking = dnsBlocking
sk.TCPBlocking = tcpBlocking
sk.IsAnomaly = dnsBlocking || tcpBlocking
return sk
}

// Anomaly implements model.MeasurementSummary.
func (sk *SummaryKeys) Anomaly() bool {
return sk.IsAnomaly
}
27 changes: 12 additions & 15 deletions internal/experiment/hhfm/hhfm.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,26 +343,23 @@ func (c Conn) Write(b []byte) (int, error) {
var _ model.MeasurementSummaryKeysProvider = &TestKeys{}

// SummaryKeys contains summary keys for this experiment.
//
// Note that this structure is part of the ABI contract with ooniprobe
// therefore we should be careful when changing it.
type SummaryKeys struct {
IsAnomaly bool `json:"-"`
}

// MeasurementSummaryKeys implements model.MeasurementSummaryKeysProvider.
func (tk *TestKeys) MeasurementSummaryKeys() model.MeasurementSummaryKeys {
sk := &SummaryKeys{IsAnomaly: false}
sk.IsAnomaly = (tk.Tampering.HeaderFieldName ||
tk.Tampering.HeaderFieldNumber ||
tk.Tampering.HeaderFieldValue ||
tk.Tampering.HeaderNameCapitalization ||
tk.Tampering.RequestLineCapitalization ||
tk.Tampering.Total)
return sk
}

// Anomaly implements model.MeasurementSummaryKeys.
func (sk *SummaryKeys) Anomaly() bool {
return sk.IsAnomaly
}

// MeasurementSummaryKeys implements model.MeasurementSummaryKeysProvider.
func (tk *TestKeys) MeasurementSummaryKeys() model.MeasurementSummaryKeys {
return &SummaryKeys{
IsAnomaly: (tk.Tampering.HeaderFieldName ||
tk.Tampering.HeaderFieldNumber ||
tk.Tampering.HeaderFieldValue ||
tk.Tampering.HeaderNameCapitalization ||
tk.Tampering.RequestLineCapitalization ||
tk.Tampering.Total),
}
}
15 changes: 7 additions & 8 deletions internal/experiment/hirl/hirl.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,19 +308,18 @@ func RunMethod(ctx context.Context, config RunMethodConfig) {
var _ model.MeasurementSummaryKeysProvider = &TestKeys{}

// SummaryKeys contains summary keys for this experiment.
//
// Note that this structure is part of the ABI contract with ooniprobe
// therefore we should be careful when changing it.
type SummaryKeys struct {
IsAnomaly bool `json:"-"`
}

// MeasurementSummaryKeys implements model.MeasurementSummaryKeysProvider.
func (tk *TestKeys) MeasurementSummaryKeys() model.MeasurementSummaryKeys {
sk := &SummaryKeys{IsAnomaly: false}
sk.IsAnomaly = tk.Tampering
return sk
}

// Anomaly implements model.MeasurementSummaryKeys.
func (sk *SummaryKeys) Anomaly() bool {
return sk.IsAnomaly
}

// MeasurementSummaryKeys implements model.MeasurementSummaryKeysProvider.
func (tk *TestKeys) MeasurementSummaryKeys() model.MeasurementSummaryKeys {
return &SummaryKeys{IsAnomaly: tk.Tampering}
}
33 changes: 15 additions & 18 deletions internal/experiment/ndt7/ndt7.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,6 @@ func failureFromError(err error) (failure *string) {
var _ model.MeasurementSummaryKeysProvider = &TestKeys{}

// SummaryKeys contains summary keys for this experiment.
//
// Note that this structure is part of the ABI contract with ooniprobe
// therefore we should be careful when changing it.
type SummaryKeys struct {
Upload float64 `json:"upload"`
Download float64 `json:"download"`
Expand All @@ -281,22 +278,22 @@ type SummaryKeys struct {
IsAnomaly bool `json:"-"`
}

// MeasurementSummaryKeys implements model.MeasurementSummaryKeysProvider.
func (tk *TestKeys) MeasurementSummaryKeys() model.MeasurementSummaryKeys {
sk := &SummaryKeys{IsAnomaly: false}
sk.Upload = tk.Summary.Upload
sk.Download = tk.Summary.Download
sk.Ping = tk.Summary.Ping
sk.MaxRTT = tk.Summary.MaxRTT
sk.AvgRTT = tk.Summary.AvgRTT
sk.MinRTT = tk.Summary.MinRTT
sk.MSS = float64(tk.Summary.MSS)
sk.RetransmitRate = tk.Summary.RetransmitRate
sk.IsAnomaly = false
return sk
}

// Anomaly implements model.MeasurementSummaryKeys.
func (sk *SummaryKeys) Anomaly() bool {
return sk.IsAnomaly
}

// MeasurementSummaryKeys implements model.MeasurementSummaryKeysProvider.
func (tk *TestKeys) MeasurementSummaryKeys() model.MeasurementSummaryKeys {
return &SummaryKeys{
Upload: tk.Summary.Upload,
Download: tk.Summary.Download,
Ping: tk.Summary.Ping,
MaxRTT: tk.Summary.MaxRTT,
AvgRTT: tk.Summary.AvgRTT,
MinRTT: tk.Summary.MinRTT,
MSS: float64(tk.Summary.MSS),
RetransmitRate: tk.Summary.RetransmitRate,
IsAnomaly: false,
}
}
25 changes: 10 additions & 15 deletions internal/experiment/psiphon/psiphon.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,29 +109,24 @@ func NewExperimentMeasurer(config Config) model.ExperimentMeasurer {
var _ model.MeasurementSummaryKeysProvider = &TestKeys{}

// SummaryKeys contains summary keys for this experiment.
//
// Note that this structure is part of the ABI contract with ooniprobe
// therefore we should be careful when changing it.
type SummaryKeys struct {
BootstrapTime float64 `json:"bootstrap_time"`
Failure string `json:"failure"`
IsAnomaly bool `json:"-"`
}

// Anomaly implements model.MeasurementSummaryKeys.
func (sk *SummaryKeys) Anomaly() bool {
return sk.IsAnomaly
}

// MeasurementSummaryKeys implements model.MeasurementSummaryKeysProvider.
func (tk *TestKeys) MeasurementSummaryKeys() model.MeasurementSummaryKeys {
var failure string
sk := &SummaryKeys{IsAnomaly: false}
if tk.Failure != nil {
failure = *tk.Failure
}
return &SummaryKeys{
BootstrapTime: tk.BootstrapTime,
Failure: failure,
IsAnomaly: tk.Failure != nil,
sk.Failure = *tk.Failure
sk.IsAnomaly = true
}
sk.BootstrapTime = tk.BootstrapTime
return sk
}

// Anomaly implements model.MeasurementSummaryKeys.
func (sk *SummaryKeys) Anomaly() bool {
return sk.IsAnomaly
}
21 changes: 9 additions & 12 deletions internal/experiment/signal/signal.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,25 +207,22 @@ func NewExperimentMeasurer(config Config) model.ExperimentMeasurer {
var _ model.MeasurementSummaryKeysProvider = &TestKeys{}

// SummaryKeys contains summary keys for this experiment.
//
// Note that this structure is part of the ABI contract with ooniprobe
// therefore we should be careful when changing it.
type SummaryKeys struct {
SignalBackendStatus string `json:"signal_backend_status"`
SignalBackendFailure *string `json:"signal_backend_failure"`
IsAnomaly bool `json:"-"`
}

// MeasurementSummaryKeys implements model.MeasurementSummaryKeysProvider.
func (tk *TestKeys) MeasurementSummaryKeys() model.MeasurementSummaryKeys {
sk := &SummaryKeys{IsAnomaly: false}
sk.SignalBackendStatus = tk.SignalBackendStatus
sk.SignalBackendFailure = tk.SignalBackendFailure
sk.IsAnomaly = tk.SignalBackendStatus == "blocked"
return sk
}

// Anomaly implements model.MeasurementSummaryKeys.
func (tk *SummaryKeys) Anomaly() bool {
return tk.IsAnomaly
}

// MeasurementSummaryKeys implements model.MeasurementSummaryKeysProvider.
func (tk *TestKeys) MeasurementSummaryKeys() model.MeasurementSummaryKeys {
return &SummaryKeys{
SignalBackendStatus: tk.SignalBackendStatus,
SignalBackendFailure: tk.SignalBackendFailure,
IsAnomaly: tk.SignalBackendStatus == "blocked",
}
}
25 changes: 11 additions & 14 deletions internal/experiment/telegram/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,30 +138,27 @@ func NewExperimentMeasurer(config Config) model.ExperimentMeasurer {
var _ model.MeasurementSummaryKeysProvider = &TestKeys{}

// SummaryKeys contains summary keys for this experiment.
//
// Note that this structure is part of the ABI contract with ooniprobe
// therefore we should be careful when changing it.
type SummaryKeys struct {
HTTPBlocking bool `json:"telegram_http_blocking"`
TCPBlocking bool `json:"telegram_tcp_blocking"`
WebBlocking bool `json:"telegram_web_blocking"`
IsAnomaly bool `json:"-"`
}

// Anomaly implements model.MeasurementSummaryKeys.
func (sk *SummaryKeys) Anomaly() bool {
return sk.IsAnomaly
}

// MeasurementSummaryKeys implements model.MeasurementSummaryKeysProvider.
func (tk *TestKeys) MeasurementSummaryKeys() model.MeasurementSummaryKeys {
sk := &SummaryKeys{IsAnomaly: false}
tcpBlocking := tk.TelegramTCPBlocking
httpBlocking := tk.TelegramHTTPBlocking
webBlocking := tk.TelegramWebFailure != nil
return &SummaryKeys{
HTTPBlocking: httpBlocking,
TCPBlocking: tcpBlocking,
WebBlocking: webBlocking,
IsAnomaly: webBlocking || httpBlocking || tcpBlocking,
}
sk.HTTPBlocking = httpBlocking
sk.TCPBlocking = tcpBlocking
sk.WebBlocking = webBlocking
sk.IsAnomaly = webBlocking || httpBlocking || tcpBlocking
return sk
}

// Anomaly implements model.MeasurementSummaryKeys.
func (sk *SummaryKeys) Anomaly() bool {
return sk.IsAnomaly
}
39 changes: 18 additions & 21 deletions internal/experiment/tor/tor.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,6 @@ func failureString(failure *string) (s string) {
var _ model.MeasurementSummaryKeysProvider = &TestKeys{}

// SummaryKeys contains summary keys for this experiment.
//
// Note that this structure is part of the ABI contract with ooniprobe
// therefore we should be careful when changing it.
type SummaryKeys struct {
DirPortTotal int64 `json:"dir_port_total"`
DirPortAccessible int64 `json:"dir_port_accessible"`
Expand All @@ -398,25 +395,25 @@ type SummaryKeys struct {
IsAnomaly bool `json:"-"`
}

// MeasurementSummaryKeys implements model.MeasurementSummaryKeysProvider.
func (tk *TestKeys) MeasurementSummaryKeys() model.MeasurementSummaryKeys {
sk := &SummaryKeys{IsAnomaly: false}
sk.DirPortTotal = tk.DirPortTotal
sk.DirPortAccessible = tk.DirPortAccessible
sk.OBFS4Total = tk.OBFS4Total
sk.OBFS4Accessible = tk.OBFS4Accessible
sk.ORPortDirauthTotal = tk.ORPortDirauthTotal
sk.ORPortDirauthAccessible = tk.ORPortDirauthAccessible
sk.ORPortTotal = tk.ORPortTotal
sk.ORPortAccessible = tk.ORPortAccessible
sk.IsAnomaly = ((sk.DirPortAccessible <= 0 && sk.DirPortTotal > 0) ||
(sk.OBFS4Accessible <= 0 && sk.OBFS4Total > 0) ||
(sk.ORPortDirauthAccessible <= 0 && sk.ORPortDirauthTotal > 0) ||
(sk.ORPortAccessible <= 0 && sk.ORPortTotal > 0))
return sk
}

// Anomaly implements model.MeasurementSummaryKeys.
func (sk *SummaryKeys) Anomaly() bool {
return sk.IsAnomaly
}

// MeasurementSummaryKeys implements model.MeasurementSummaryKeysProvider.
func (tk *TestKeys) MeasurementSummaryKeys() model.MeasurementSummaryKeys {
return &SummaryKeys{
DirPortTotal: tk.DirPortTotal,
DirPortAccessible: tk.DirPortAccessible,
OBFS4Total: tk.OBFS4Total,
OBFS4Accessible: tk.OBFS4Accessible,
ORPortDirauthTotal: tk.ORPortDirauthTotal,
ORPortDirauthAccessible: tk.ORPortDirauthAccessible,
ORPortTotal: tk.ORPortTotal,
ORPortAccessible: tk.ORPortAccessible,
IsAnomaly: ((tk.DirPortAccessible <= 0 && tk.DirPortTotal > 0) ||
(tk.OBFS4Accessible <= 0 && tk.OBFS4Total > 0) ||
(tk.ORPortDirauthAccessible <= 0 && tk.ORPortDirauthTotal > 0) ||
(tk.ORPortAccessible <= 0 && tk.ORPortTotal > 0)),
}
}
13 changes: 5 additions & 8 deletions internal/experiment/torsf/torsf.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,19 +306,16 @@ func NewExperimentMeasurer(config Config) model.ExperimentMeasurer {
var _ model.MeasurementSummaryKeysProvider = &TestKeys{}

// SummaryKeys contains summary keys for this experiment.
//
// Note that this structure is part of the ABI contract with ooniprobe
// therefore we should be careful when changing it.
type SummaryKeys struct {
IsAnomaly bool `json:"-"`
}

// Anomaly implements model.MeasurementSummaryKeys.
func (sk *SummaryKeys) Anomaly() bool {
return sk.IsAnomaly
}

// MeasurementSummaryKeys implements model.MeasurementSummaryKeysProvider.
func (tk *TestKeys) MeasurementSummaryKeys() model.MeasurementSummaryKeys {
return &SummaryKeys{IsAnomaly: tk.Failure != nil}
}

// Anomaly implements model.MeasurementSummaryKeys.
func (sk *SummaryKeys) Anomaly() bool {
return sk.IsAnomaly
}
Loading

0 comments on commit 8ee91e7

Please sign in to comment.