mirror of
https://github.com/maride/afl-prom.git
synced 2024-11-21 11:34:24 +00:00
Switch to flag library
This commit is contained in:
parent
b58017d4f7
commit
3a738edc23
5
main.go
5
main.go
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
@ -9,6 +10,10 @@ import (
|
||||
|
||||
// Main function
|
||||
func main() {
|
||||
// Register flags
|
||||
registerWatcherFlags()
|
||||
flag.Parse()
|
||||
|
||||
// Check args
|
||||
targetFuzzers, targetErr := getFuzzersToWatch()
|
||||
if targetErr != nil {
|
||||
|
17
watch.go
17
watch.go
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
@ -9,15 +10,19 @@ import (
|
||||
|
||||
var (
|
||||
registeredFuzzers []Fuzzer
|
||||
sleepSecs *int
|
||||
)
|
||||
|
||||
func registerWatcherFlags() {
|
||||
sleepSecs = flag.Int("scan-delay", 30, "Seconds to sleep between scans of the fuzzer directories")
|
||||
}
|
||||
|
||||
// Returns the path to every fuzzer to watch
|
||||
func getFuzzersToWatch() ([]string, error) {
|
||||
for i, a := range os.Args {
|
||||
if a == "--" {
|
||||
// Choose arguments after that one as the target fuzzer directories
|
||||
return os.Args[i+1:], nil
|
||||
}
|
||||
// flag.Args() returns all arguments after --
|
||||
fuzzers := flag.Args()
|
||||
if len(fuzzers) > 0 {
|
||||
return fuzzers, nil
|
||||
}
|
||||
|
||||
// Wrong usage - construct a helpful error message
|
||||
@ -50,6 +55,6 @@ func watchFuzzers() {
|
||||
}
|
||||
|
||||
// and sleep
|
||||
time.Sleep(30 * time.Second)
|
||||
time.Sleep(time.Duration(*sleepSecs) * time.Second)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user