Add support for more tests
- Implement middlebox tests & summary generator - Implement IM tests (summary generator missing)
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package im
|
||||
|
||||
import (
|
||||
"github.com/measurement-kit/go-measurement-kit"
|
||||
"github.com/openobservatory/gooni/nettests"
|
||||
)
|
||||
|
||||
// FacebookMessenger test implementation
|
||||
type FacebookMessenger struct {
|
||||
}
|
||||
|
||||
// Run starts the test
|
||||
func (h FacebookMessenger) Run(ctl *nettests.Controller) error {
|
||||
mknt := mk.NewNettest("FacebookMessenger")
|
||||
ctl.Init(mknt)
|
||||
return mknt.Run()
|
||||
}
|
||||
|
||||
// FacebookMessengerSummary for the test
|
||||
type FacebookMessengerSummary struct {
|
||||
DNSBlocking bool
|
||||
TCPBlocking bool
|
||||
}
|
||||
|
||||
// Summary generates a summary for a test run
|
||||
func (h FacebookMessenger) Summary(tk map[string]interface{}) interface{} {
|
||||
return FacebookMessengerSummary{
|
||||
DNSBlocking: tk["facebook_dns_blocking"].(bool),
|
||||
TCPBlocking: tk["facebook_tcp_blocking"].(bool),
|
||||
}
|
||||
}
|
||||
|
||||
// LogSummary writes the summary to the standard output
|
||||
func (h FacebookMessenger) LogSummary(s string) error {
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package im
|
||||
|
||||
import (
|
||||
"github.com/measurement-kit/go-measurement-kit"
|
||||
"github.com/openobservatory/gooni/nettests"
|
||||
)
|
||||
|
||||
// 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()
|
||||
}
|
||||
|
||||
// TelegramSummary for the test
|
||||
type TelegramSummary struct {
|
||||
HTTPBlocking bool
|
||||
TCPBlocking bool
|
||||
WebBlocking bool
|
||||
}
|
||||
|
||||
// Summary generates a summary for a test run
|
||||
func (h Telegram) Summary(tk map[string]interface{}) interface{} {
|
||||
return TelegramSummary{
|
||||
TCPBlocking: tk["telegram_tcp_blocking"].(bool) == true,
|
||||
HTTPBlocking: tk["telegram_http_blocking"].(bool) == true,
|
||||
WebBlocking: tk["telegram_web_status"].(string) == "blocked",
|
||||
}
|
||||
}
|
||||
|
||||
// LogSummary writes the summary to the standard output
|
||||
func (h Telegram) LogSummary(s string) error {
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package im
|
||||
|
||||
import (
|
||||
"github.com/measurement-kit/go-measurement-kit"
|
||||
"github.com/openobservatory/gooni/nettests"
|
||||
)
|
||||
|
||||
// WhatsApp test implementation
|
||||
type WhatsApp struct {
|
||||
}
|
||||
|
||||
// Run starts the test
|
||||
func (h WhatsApp) Run(ctl *nettests.Controller) error {
|
||||
mknt := mk.NewNettest("Whatsapp")
|
||||
ctl.Init(mknt)
|
||||
return mknt.Run()
|
||||
}
|
||||
|
||||
// WhatsAppSummary for the test
|
||||
type WhatsAppSummary struct {
|
||||
RegistrationServerBlocking bool
|
||||
WebBlocking bool
|
||||
EndpointsBlocking bool
|
||||
}
|
||||
|
||||
// Summary generates a summary for a test run
|
||||
func (h WhatsApp) Summary(tk map[string]interface{}) interface{} {
|
||||
const blk = "blocked"
|
||||
|
||||
return WhatsAppSummary{
|
||||
RegistrationServerBlocking: tk["registration_server_status"].(string) == blk,
|
||||
WebBlocking: tk["whatsapp_web_status"].(string) == blk,
|
||||
EndpointsBlocking: tk["whatsapp_endpoints_status"].(string) == blk,
|
||||
}
|
||||
}
|
||||
|
||||
// LogSummary writes the summary to the standard output
|
||||
func (h WhatsApp) LogSummary(s string) error {
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user