2018-03-21 12:18:45 +01:00
|
|
|
package im
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/measurement-kit/go-measurement-kit"
|
2018-05-03 14:59:55 +02:00
|
|
|
"github.com/ooni/probe-cli/nettests"
|
2018-03-21 12:18:45 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// Telegram test implementation
|
|
|
|
type Telegram struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
// Run starts the test
|
|
|
|
func (h Telegram) Run(ctl *nettests.Controller) error {
|
|
|
|
mknt := mk.NewNettest("Telegram")
|
|
|
|
ctl.Init(mknt)
|
|
|
|
return mknt.Run()
|
|
|
|
}
|
|
|
|
|
2018-09-10 12:41:28 +02:00
|
|
|
// TelegramTestKeys for the test
|
|
|
|
type TelegramTestKeys struct {
|
|
|
|
HTTPBlocking bool `json:"telegram_http_blocking"`
|
|
|
|
TCPBlocking bool `json:"telegram_tcp_blocking"`
|
|
|
|
WebBlocking bool `json:"telegram_web_blocking"`
|
|
|
|
IsAnomaly bool `json:"-"`
|
2018-03-21 12:18:45 +01:00
|
|
|
}
|
|
|
|
|
2018-09-10 12:41:28 +02:00
|
|
|
// GetTestKeys generates a summary for a test run
|
|
|
|
func (h Telegram) GetTestKeys(tk map[string]interface{}) interface{} {
|
2018-03-23 15:22:58 +01:00
|
|
|
var (
|
|
|
|
tcpBlocking bool
|
|
|
|
httpBlocking bool
|
|
|
|
webBlocking bool
|
|
|
|
)
|
|
|
|
|
|
|
|
if tk["telegram_tcp_blocking"] == nil {
|
|
|
|
tcpBlocking = false
|
|
|
|
} else {
|
|
|
|
tcpBlocking = tk["telegram_tcp_blocking"].(bool)
|
|
|
|
}
|
|
|
|
if tk["telegram_http_blocking"] == nil {
|
|
|
|
httpBlocking = false
|
|
|
|
} else {
|
|
|
|
httpBlocking = tk["telegram_http_blocking"].(bool)
|
|
|
|
}
|
|
|
|
if tk["telegram_web_status"] == nil {
|
|
|
|
webBlocking = false
|
|
|
|
} else {
|
|
|
|
webBlocking = tk["telegram_web_status"].(string) == "blocked"
|
|
|
|
}
|
|
|
|
|
2018-09-10 12:41:28 +02:00
|
|
|
return TelegramTestKeys{
|
2018-03-23 15:22:58 +01:00
|
|
|
TCPBlocking: tcpBlocking,
|
|
|
|
HTTPBlocking: httpBlocking,
|
|
|
|
WebBlocking: webBlocking,
|
2018-09-10 12:41:28 +02:00
|
|
|
IsAnomaly: webBlocking || httpBlocking || tcpBlocking,
|
2018-03-21 12:18:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// LogSummary writes the summary to the standard output
|
|
|
|
func (h Telegram) LogSummary(s string) error {
|
|
|
|
return nil
|
|
|
|
}
|