Skip to content

Commit

Permalink
replace -s flag with -i
Browse files Browse the repository at this point in the history
  • Loading branch information
Jozef Reisinger committed Oct 15, 2021
1 parent a61a5d5 commit fa3769f
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions cmd/checkip.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/jreisinger/checkip"
)

var s = flag.Bool("s", false, "only print how many checkers consider the ipaddr suspicious")
var i = flag.Bool("i", false, "run only information checkers")

func main() {
flag.Parse()
Expand Down Expand Up @@ -47,19 +47,12 @@ func main() {
"net.IP": &checkip.IP{},
}

if *s {
var checkerSlice []checkip.Checker
for _, v := range checkers {
checkerSlice = append(checkerSlice, v)
}
n := checkip.Run(checkerSlice, ipaddr)
perc := float64(n) / float64(len(checkers)) * 100.0
fmt.Printf("%02.0f%% (%d/%d)\n", perc, n, len(checkers))
if *i {
checkers = infoCheckers
} else {
for k, v := range infoCheckers {
checkers[k] = v
}
checkip.RunAndPrint(checkers, ipaddr, "%-25s %s")
}

checkip.RunAndPrint(checkers, ipaddr, "%-25s %s")
}

0 comments on commit fa3769f

Please sign in to comment.