-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (37 loc) · 809 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"flag"
"fmt"
"log"
"os"
"os/signal"
"github.com/PumpkinSeed/netrel/netreler"
)
var (
flagPrintMeta bool
)
func init() {
flag.BoolVar(&flagPrintMeta, "print-meta", false, "Printing meta results")
flag.Parse()
}
func main() {
// listen for ctrl-C signal
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
result := netreler.Test(c)
if flagPrintMeta {
meta, err := result.PrettyPrintMeta()
if err != nil {
log.Fatal(err)
}
fmt.Println(string(meta))
}
fmt.Printf("\n\n")
fmt.Printf("Tested hosts:\n")
for _, host := range result.TestedHosts {
fmt.Printf("\t%s\n", host)
}
fmt.Printf("Final score of internet reliability: %f%% \n", result.Score)
fmt.Printf("Test spent: %s\n", result.Spent)
fmt.Printf("Condition: %s\n", result.Condition)
}