From: Sergey Matveev Date: Sat, 3 Jul 2021 18:44:44 +0000 (+0300) Subject: nncp-check -cycle X-Git-Tag: v7.1.0^2~2 X-Git-Url: http://www.git.cypherpunks.ru/?p=nncp.git;a=commitdiff_plain;h=aedcfb28a36dd95e47ec093e2c3048146baf163e nncp-check -cycle --- diff --git a/doc/news.ru.texi b/doc/news.ru.texi index 7257baf..1675458 100644 --- a/doc/news.ru.texi +++ b/doc/news.ru.texi @@ -20,6 +20,10 @@ У @command{nncp-rm} команды появилась @option{-all} опция, применяемая ко всем нодам сразу. +@item +У @command{nncp-check} команды появилась @option{-cycle} опция, вводящая +проверку в бесконечный цикл. + @item @command{nncp-pkt} может парсить @file{.hdr} файлы. diff --git a/doc/news.texi b/doc/news.texi index b4dd9b1..b99a29d 100644 --- a/doc/news.texi +++ b/doc/news.texi @@ -21,6 +21,10 @@ Fixed invalid @file{.hdr} generation when transitional packets are used. @option{-all} option appeared in @command{nncp-rm} command, applying to all the nodes at once. +@item +@option{-cycle} option appeared in @command{nncp-check} command, looping +the check in infinite cycle. + @item @command{nncp-pkt} can parse @file{.hdr} files. diff --git a/src/cmd/nncp-check/main.go b/src/cmd/nncp-check/main.go index 6575ded..b2a931c 100644 --- a/src/cmd/nncp-check/main.go +++ b/src/cmd/nncp-check/main.go @@ -24,6 +24,7 @@ import ( "log" "os" "path/filepath" + "time" "go.cypherpunks.ru/nncp/v7" ) @@ -38,6 +39,7 @@ func usage() { func main() { var ( nock = flag.Bool("nock", false, "Process .nock files") + cycle = flag.Uint("cycle", 0, "Repeat check after N seconds in infinite loop") cfgPath = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file") nodeRaw = flag.String("node", "", "Process only that node") spoolPath = flag.String("spool", "", "Override path to spool") @@ -83,6 +85,7 @@ func main() { } } +Cycle: isBad := false for nodeId, node := range ctx.Neigh { if nodeOnly != nil && nodeId != *nodeOnly.Id { @@ -105,6 +108,10 @@ func main() { isBad = true } } + if *cycle > 0 { + time.Sleep(time.Duration(*cycle) * time.Second) + goto Cycle + } if isBad { os.Exit(1) }