X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcmd%2Fnncp-caller%2Fmain.go;h=e1e10f78729babb23f3b2023ea527b6947c299e9;hb=7c507e7ddba9fe5557df06c860fe9fa6197ba2e1;hp=981e42e68d204e3faadf845d25036ac32a329d55;hpb=128618d02d84d08164060f14e7fdd3b87e491fcb;p=nncp.git diff --git a/src/cmd/nncp-caller/main.go b/src/cmd/nncp-caller/main.go index 981e42e..e1e10f7 100644 --- a/src/cmd/nncp-caller/main.go +++ b/src/cmd/nncp-caller/main.go @@ -1,6 +1,6 @@ /* NNCP -- Node to Node copy, utilities for store-and-forward data exchange -Copyright (C) 2016-2022 Sergey Matveev +Copyright (C) 2016-2023 Sergey Matveev 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,7 +23,9 @@ import ( "flag" "fmt" "log" + "net" "os" + "regexp" "sync" "time" @@ -31,8 +33,7 @@ import ( ) func usage() { - fmt.Fprintf(os.Stderr, nncp.UsageHeader()) - fmt.Fprintf(os.Stderr, "nncp-caller -- croned NNCP TCP daemon caller\n\n") + fmt.Fprint(os.Stderr, "nncp-caller -- croned NNCP TCP daemon caller\n\n") fmt.Fprintf(os.Stderr, "Usage: %s [options] [NODE ...]\n", os.Args[0]) fmt.Fprintln(os.Stderr, "Options:") flag.PrintDefaults() @@ -57,6 +58,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 +127,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) + } + } } } @@ -198,13 +212,16 @@ func main() { if call.AutoToss || *autoToss { autoTossFinish, autoTossBadCode = ctx.AutoToss( node.Id, - call.Nice, - call.AutoTossDoSeen || *autoTossDoSeen, - call.AutoTossNoFile || *autoTossNoFile, - call.AutoTossNoFreq || *autoTossNoFreq, - call.AutoTossNoExec || *autoTossNoExec, - call.AutoTossNoTrns || *autoTossNoTrns, - call.AutoTossNoArea || *autoTossNoArea, + &nncp.TossOpts{ + Nice: call.Nice, + DoSeen: call.AutoTossDoSeen || *autoTossDoSeen, + NoFile: call.AutoTossNoFile || *autoTossNoFile, + NoFreq: call.AutoTossNoFreq || *autoTossNoFreq, + NoExec: call.AutoTossNoExec || *autoTossNoExec, + NoTrns: call.AutoTossNoTrns || *autoTossNoTrns, + NoArea: call.AutoTossNoArea || *autoTossNoArea, + NoACK: call.AutoTossNoACK || *autoTossNoACK, + }, ) }