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