refactor: nettests is now an internal package (#165)
I'm moving everything into internal packages since this ain't a library. While there, remove typo that was causing a build breakage.
This commit is contained in:
parent
fb2ca32004
commit
a58dff3050
15 changed files with 2 additions and 3 deletions
61
internal/nettests/telegram.go
Normal file
61
internal/nettests/telegram.go
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
package nettests
|
||||
|
||||
// Telegram test implementation
|
||||
type Telegram struct {
|
||||
}
|
||||
|
||||
// Run starts the test
|
||||
func (h Telegram) Run(ctl *Controller) error {
|
||||
builder, err := ctl.Session.NewExperimentBuilder(
|
||||
"telegram",
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ctl.Run(builder, []string{""})
|
||||
}
|
||||
|
||||
// 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:"-"`
|
||||
}
|
||||
|
||||
// GetTestKeys generates a summary for a test run
|
||||
func (h Telegram) GetTestKeys(tk map[string]interface{}) (interface{}, error) {
|
||||
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"
|
||||
}
|
||||
|
||||
return TelegramTestKeys{
|
||||
TCPBlocking: tcpBlocking,
|
||||
HTTPBlocking: httpBlocking,
|
||||
WebBlocking: webBlocking,
|
||||
IsAnomaly: webBlocking || httpBlocking || tcpBlocking,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// LogSummary writes the summary to the standard output
|
||||
func (h Telegram) LogSummary(s string) error {
|
||||
return nil
|
||||
}
|
||||
Loading…
Reference in a new issue