]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/cmd/nncp-check/main.go
Raise copyright years
[nncp.git] / src / cmd / nncp-check / main.go
index e985b79ce729fbc8e76bada4f7b70842927ead6d..2c9eafb4b6a5469b6b77516bf439b9542663ec9b 100644 (file)
@@ -1,6 +1,6 @@
 /*
 NNCP -- Node to Node copy, utilities for store-and-forward data exchange
-Copyright (C) 2016-2021 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2016-2022 Sergey Matveev <stargrave@stargrave.org>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -24,8 +24,9 @@ import (
        "log"
        "os"
        "path/filepath"
+       "time"
 
-       "go.cypherpunks.ru/nncp/v5"
+       "go.cypherpunks.ru/nncp/v8"
 )
 
 func usage() {
@@ -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")
@@ -49,6 +51,7 @@ func main() {
                version   = flag.Bool("version", false, "Print version information")
                warranty  = flag.Bool("warranty", false, "Print warranty information")
        )
+       log.SetFlags(log.Lshortfile)
        flag.Usage = usage
        flag.Parse()
        if *warranty {
@@ -82,6 +85,7 @@ func main() {
                }
        }
 
+Cycle:
        isBad := false
        for nodeId, node := range ctx.Neigh {
                if nodeOnly != nil && nodeId != *nodeOnly.Id {
@@ -89,7 +93,7 @@ func main() {
                }
                if *nock {
                        for job := range ctx.JobsNoCK(node.Id) {
-                               if _, err = ctx.CheckNoCK(node.Id, job.HshValue); err != nil {
+                               if _, err = ctx.CheckNoCK(node.Id, job.HshValue, nil); err != nil {
                                        pktName := nncp.Base32Codec.EncodeToString(job.HshValue[:])
                                        log.Println(filepath.Join(
                                                ctx.Spool,
@@ -104,6 +108,10 @@ func main() {
                        isBad = true
                }
        }
+       if *cycle > 0 {
+               time.Sleep(time.Duration(*cycle) * time.Second)
+               goto Cycle
+       }
        if isBad {
                os.Exit(1)
        }