]> Cypherpunks.ru repositories - nncp.git/commitdiff
nncp-check -cycle
authorSergey Matveev <stargrave@stargrave.org>
Sat, 3 Jul 2021 18:44:44 +0000 (21:44 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 4 Jul 2021 17:11:24 +0000 (20:11 +0300)
doc/news.ru.texi
doc/news.texi
src/cmd/nncp-check/main.go

index 7257bafd55080fb992b05dcef036ded5a057f432..1675458604ae5870ff57d2b038c569ac6185d3d1 100644 (file)
 У @command{nncp-rm} команды появилась @option{-all} опция, применяемая
 ко всем нодам сразу.
 
+@item
+У @command{nncp-check} команды появилась @option{-cycle} опция, вводящая
+проверку в бесконечный цикл.
+
 @item
 @command{nncp-pkt} может парсить @file{.hdr} файлы.
 
index b4dd9b1d642dda2dae4dc0f70e6cdfbce52ab7a6..b99a29d7c5157a9c131ddee308a0b6a9d6d089a3 100644 (file)
@@ -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.
 
index 6575ded385ef07b06ef5d78aa634b5b9482c6f02..b2a931c977f665bdb8a5d90ab2901cdca6b98f98 100644 (file)
@@ -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)
        }