]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/cmd/nncp-caller/main.go
ACK
[nncp.git] / src / cmd / nncp-caller / main.go
index d1a5b34be2a392dccbcb9a6724bb3e63362bf603..50d9bf4fc8b85aa8737cc48f2fd428b53bffa89d 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
@@ -23,11 +23,13 @@ import (
        "flag"
        "fmt"
        "log"
+       "net"
        "os"
+       "regexp"
        "sync"
        "time"
 
-       "go.cypherpunks.ru/nncp/v7"
+       "go.cypherpunks.ru/nncp/v8"
 )
 
 func usage() {
@@ -51,12 +53,13 @@ func main() {
                warranty  = flag.Bool("warranty", false, "Print warranty information")
 
                autoToss       = flag.Bool("autotoss", false, "Toss after call is finished")
-               autoTossDoSeen = flag.Bool("autotoss-seen", false, "Create .seen files during tossing")
+               autoTossDoSeen = flag.Bool("autotoss-seen", false, "Create seen/ files during tossing")
                autoTossNoFile = flag.Bool("autotoss-nofile", false, "Do not process \"file\" packets during tossing")
                autoTossNoFreq = flag.Bool("autotoss-nofreq", false, "Do not process \"freq\" packets during tossing")
                autoTossNoExec = flag.Bool("autotoss-noexec", false, "Do not process \"exec\" packets during tossing")
                autoTossNoTrns = flag.Bool("autotoss-notrns", false, "Do not process \"trns\" packets during tossing")
                autoTossNoArea = flag.Bool("autotoss-noarea", false, "Do not process \"area\" packets during tossing")
+               autoTossNoACK  = flag.Bool("autotoss-noack", false, "Do not process \"ack\" packets during tossing")
        )
        log.SetFlags(log.Lshortfile)
        flag.Usage = usage
@@ -94,6 +97,9 @@ func main() {
                        if err != nil {
                                log.Fatalln("Invalid NODE specified:", err)
                        }
+                       if node.NoisePub == nil {
+                               log.Fatalln("Node", nodeId, "does not have online communication capability")
+                       }
                        if len(node.Calls) == 0 {
                                ctx.LogD(
                                        "caller-no-calls",
@@ -122,9 +128,21 @@ func main() {
                }
        }
 
-       for _, ifiName := range ctx.MCDRxIfis {
-               if err = ctx.MCDRx(ifiName); err != nil {
-                       log.Fatalln("Can not run MCD reception:", err)
+       ifis, err := net.Interfaces()
+       if err != nil {
+               log.Fatalln("Can not get network interfaces list:", err)
+       }
+       for _, ifiReString := range ctx.MCDRxIfis {
+               ifiRe, err := regexp.CompilePOSIX(ifiReString)
+               if err != nil {
+                       log.Fatalf("Can not compile POSIX regexp \"%s\": %s", ifiReString, err)
+               }
+               for _, ifi := range ifis {
+                       if ifiRe.MatchString(ifi.Name) {
+                               if err = ctx.MCDRx(ifi.Name); err != nil {
+                                       log.Printf("Can not run MCD reception on %s: %s", ifi.Name, err)
+                               }
+                       }
                }
        }
 
@@ -202,6 +220,7 @@ func main() {
                                                                call.AutoTossNoExec || *autoTossNoExec,
                                                                call.AutoTossNoTrns || *autoTossNoTrns,
                                                                call.AutoTossNoArea || *autoTossNoArea,
+                                                               call.AutoTossNoACK || *autoTossNoACK,
                                                        )
                                                }