func usage() {
fmt.Fprintf(os.Stderr, nncp.UsageHeader())
fmt.Fprintln(os.Stderr, "nncp-toss -- process inbound packets\n")
- fmt.Fprintf(os.Stderr, "Usage: %s [options]\nOptions:", os.Args[0])
+ fmt.Fprintf(os.Stderr, "Usage: %s [options]\nOptions:\n", os.Args[0])
flag.PrintDefaults()
}
cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
nodeRaw = flag.String("node", "", "Process only that node")
niceRaw = flag.Int("nice", 255, "Minimal required niceness")
- debug = flag.Bool("debug", false, "Enable debugging information")
+ dryRun = flag.Bool("dryrun", false, "Do not actually write any tossed data")
+ quiet = flag.Bool("quiet", false, "Print only errors")
+ debug = flag.Bool("debug", false, "Print debug messages")
version = flag.Bool("version", false, "Print version information")
warranty = flag.Bool("warranty", false, "Print warranty information")
)
if err != nil {
log.Fatalln("Can not parse config:", err)
}
+ ctx.Quiet = *quiet
ctx.Debug = *debug
var nodeOnly *nncp.Node
}
}
+ isBad := false
for nodeId, node := range ctx.Neigh {
if nodeOnly != nil && nodeId != *nodeOnly.Id {
continue
}
- ctx.Toss(node.Id, nice)
+ isBad = ctx.Toss(node.Id, nice, *dryRun)
+ }
+ if isBad {
+ os.Exit(1)
}
}