2016-02-05 03:45:37 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"bufio"
|
|
|
|
|
|
|
|
"src.agwa.name/ctwatch"
|
|
|
|
"src.agwa.name/ctwatch/cmd"
|
|
|
|
)
|
|
|
|
|
2016-02-05 05:16:25 +01:00
|
|
|
var stateDir = flag.String("state_dir", cmd.DefaultStateDir("ctwatch"), "Directory for storing state")
|
|
|
|
|
2016-02-05 03:45:37 +01:00
|
|
|
func main() {
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
var domains []string
|
2016-02-05 05:16:25 +01:00
|
|
|
if flag.NArg() == 1 && flag.Arg(0) == "-" {
|
2016-02-05 03:45:37 +01:00
|
|
|
scanner := bufio.NewScanner(os.Stdin)
|
|
|
|
for scanner.Scan() {
|
|
|
|
domains = append(domains, scanner.Text())
|
|
|
|
}
|
|
|
|
if err := scanner.Err(); err != nil {
|
2016-02-05 05:16:25 +01:00
|
|
|
fmt.Fprintf(os.Stderr, "%s: Error reading standard input: %s\n", os.Args[0], err)
|
|
|
|
os.Exit(3)
|
2016-02-05 03:45:37 +01:00
|
|
|
}
|
|
|
|
} else {
|
2016-02-05 05:16:25 +01:00
|
|
|
domains = flag.Args()
|
2016-02-05 03:45:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var matcher ctwatch.Matcher
|
|
|
|
if len(domains) == 0 {
|
|
|
|
matcher = ctwatch.MatchAll{}
|
|
|
|
} else {
|
|
|
|
matcher = ctwatch.NewDomainMatcher(domains)
|
|
|
|
}
|
|
|
|
|
2016-02-05 05:16:25 +01:00
|
|
|
cmd.Main(*stateDir, matcher)
|
2016-02-05 03:45:37 +01:00
|
|
|
}
|