]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/cmd/nncp-caller/main.go
ACK
[nncp.git] / src / cmd / nncp-caller / main.go
index 981e42e68d204e3faadf845d25036ac32a329d55..50d9bf4fc8b85aa8737cc48f2fd428b53bffa89d 100644 (file)
@@ -23,7 +23,9 @@ import (
        "flag"
        "fmt"
        "log"
+       "net"
        "os"
+       "regexp"
        "sync"
        "time"
 
@@ -57,6 +59,7 @@ func main() {
                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
@@ -125,9 +128,21 @@ func main() {
                }
        }
 
-       for _, ifiName := range ctx.MCDRxIfis {
-               if err = ctx.MCDRx(ifiName); err != nil {
-                       log.Printf("Can not run MCD reception on %s: %s", ifiName, 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)
+                               }
+                       }
                }
        }
 
@@ -205,6 +220,7 @@ func main() {
                                                                call.AutoTossNoExec || *autoTossNoExec,
                                                                call.AutoTossNoTrns || *autoTossNoTrns,
                                                                call.AutoTossNoArea || *autoTossNoArea,
+                                                               call.AutoTossNoACK || *autoTossNoACK,
                                                        )
                                                }