]> Cypherpunks.ru repositories - nncp.git/commitdiff
Merge branch 'develop' v8.4.0
authorSergey Matveev <stargrave@stargrave.org>
Tue, 25 Jan 2022 18:27:51 +0000 (21:27 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 25 Jan 2022 18:27:51 +0000 (21:27 +0300)
13 files changed:
doc/cfg/general.texi
doc/cmd/nncp-call.texi
doc/cmd/nncp-file.texi
doc/contacts.texi
doc/download.texi
doc/news.ru.texi
doc/news.texi
src/cmd/nncp-call/main.go
src/cmd/nncp-caller/main.go
src/cmd/nncp-cfgnew/main.go
src/cmd/nncp-daemon/main.go
src/nncp.go
src/tx.go

index 69551a280e85521acb0a16979d14db16c2e5554a..2575779de6171bde4c9a803c3c34b79b7a61e10b 100644 (file)
@@ -13,8 +13,8 @@ noprogress: true
 nohdr: true
 
 # MultiCast Discovery
-mcd-listen: ["em0", "igb1"]
-mcd-send: {em0: 60, igb1: 5}
+mcd-listen: ["em[0-3]", "igb_.*"]
+mcd-send: {"em[0-3]": 60, igb_.*: 5}
 
 # Yggdrasil aliases
 yggdrasil-aliases: {
@@ -52,12 +52,12 @@ And optional @ref{MCD, MultiCast Discovery} options:
 @table @code
 @anchor{CfgMCDListen}
 @item mcd-listen
-Specifies list of network interfaces @ref{nncp-caller} will listen for
-incoming @ref{MCD} announcements.
+Specifies list of network interfaces regular expression
+@ref{nncp-caller} will listen for incoming @ref{MCD} announcements.
 @anchor{CfgMCDSend}
 @item mcd-send
-Specifies list of network interfaces, and intervals in seconds, where
-@ref{nncp-daemon} will send @ref{MCD} announcements.
+Specifies list of network interfaces regular expressions, and intervals
+in seconds, where @ref{nncp-daemon} will send @ref{MCD} announcements.
 @end table
 
 @anchor{CfgYggdrasilAliases}
index a4ea6d97969d383370a30d2576061b54874783b3..6c58b5c152f269e59c72b3d2fe6f3fee4fff5497 100644 (file)
@@ -13,6 +13,7 @@ $ nncp-call [options]
     [-autotoss*]
     [-nock]
     [-ucspi]
+    [-mcd-wait INT]
     NODE[:ADDR] [FORCEADDR]
 @end example
 
@@ -48,6 +49,10 @@ If you specify @option{-ucspi} option, then it is assumed that you run
 @command{nncp-call} command under some UCSPI-TCP compatible utility,
 that provides read/write channels through 6/7 file descriptors.
 
+@option{-mcd-wait} options tells to wait up to specified number of
+seconds for the @ref{MCD} packet from the specified @code{NODE}. When
+the packet is received, initiate a call.
+
 @option{-autotoss} option runs tosser on node's spool every second
 during the call. All @option{-autotoss-*} options is the same as in
 @ref{nncp-toss} command.
index 0a80a4c5996b20163e91257354f8d62d6082b2ba..802e817fb0010121bb03d5f80eaa37ef35d7553f 100644 (file)
@@ -18,13 +18,16 @@ encrypted packet.
 If @file{SRC} equals to @file{-}, to data is read from @code{stdin}.
 
 If @file{SRC} points to directory, then
-@url{https://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92_13_01, pax archive}
-will be created on the fly with directory contents and destination
-filename @file{.tar} appended. It @strong{won't} contain any entities
-metainformation, but modification time with the names. UID/GID are set
-to zero. Directories have 777 permissions, files have 666, for being
-friendly with @command{umask}. Also each entity will have comment like
-@verb{|Autogenerated by NNCP version X.Y.Z built with goXXX|}.
+@url{https://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92_13_01,
+pax archive} will be created on the fly with directory contents and
+destination filename @file{.tar} appended. It @strong{won't} contain any
+entities metainformation, except for modification time with the names.
+UID/GID are set to zero. Directories have 777 permissions, files have
+666, for being friendly with @command{umask}. Everything except
+directories and regulars files is skipped. Also each entity will have
+comment like @verb{|Autogenerated by NNCP version X.Y.Z built with goXXX|}.
+For more precise metainformation and various file objects storage use
+external @command{tar} command piped in.
 
 If @option{-chunked} is specified, then source file will be split
 @ref{Chunked, on chunks}. @option{INT} is the desired chunk size in
index 4223bf312e4d7b1c6496bd5d0cef2a8bab2f1252..63473b804444005990bfc386632e2af561d40486 100644 (file)
@@ -5,4 +5,7 @@ Please send questions regarding the use of NNCP, bug reports and patches to
 @url{http://lists.cypherpunks.ru/nncp_002ddevel.html, nncp-devel}
 mailing list. Announcements also go to this mailing list.
 
+There are also community-supported @code{#nncp:matrix.org} Matrix
+channel and @code{irc://irc.oftc.net/nncp} IRC channel bridged to it.
+
 Official website is @url{http://www.nncpgo.org/}.
index 4f146c60acf5119c244d0f9cced5088af4725f5c..dd72c061a27b3b472c90d4987c2529804d2abfc0 100644 (file)
@@ -45,6 +45,13 @@ And additional ones for Yggdrasil support:
 @multitable {XXXXX} {XXXX-XX-XX} {XXXX KiB} {meta4 link sig} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
 @headitem Version @tab Date @tab Size @tab Tarball @tab SHA256 checksum
 
+@item @ref{Release 8_3_0, 8.3.0} @tab 2022-01-23 @tab 1682 KiB
+@tab
+    @url{download/nncp-8.3.0.tar.xz.meta4, meta4}
+    @url{download/nncp-8.3.0.tar.xz, link}
+    @url{download/nncp-8.3.0.tar.xz.sig, sig}
+@tab @code{6C14887A 9EF686D6 112F2096 ED1DA56B AABE5FEB 4BA92573 89ACC6B2 6D0A23EA}
+
 @item @ref{Release 8_2_0, 8.2.0} @tab 2022-01-20 @tab 1669 KiB
 @tab
     @url{download/nncp-8.2.0.tar.xz.meta4, meta4}
index f271462591614ed9fdf0e0c56bd8ff634fd1ac6c..61db7628a9b46e264c1dd3e3236788e4cd7835c9 100644 (file)
@@ -1,6 +1,26 @@
 @node Новости
 @section Новости
 
+@node Релиз 8.4.0
+@subsection Релиз 8.4.0
+@itemize
+
+@item
+Имена интерфейсов относящихся к multicast (@code{mcd-listen} и
+@code{mcd-send} опции конфигурации) теперь являются регулярными
+выражениями. По умолчанию @command{nncp-cfgnew} не комментирует
+их теперь и прописывает @code{.*} имя интерфейса.
+
+@item
+У @command{nncp-call} команды появился @option{-mcd-wait} аргумент,
+позволяющий дожидаться multicast сообщения об адресе ноды.
+
+@item
+@command{nncp-file} команда пропускает всё что не является регулярным
+файлом или директорией во время создания pax-архива.
+
+@end itemize
+
 @node Релиз 8.3.0
 @subsection Релиз 8.3.0
 @itemize
index cf0e875adfd8d52daf6e4dadeafae3f63932c4aa..fbb1d463bace4ba89fd22b1867f3949395b4cd4e 100644 (file)
@@ -3,6 +3,25 @@
 
 See also this page @ref{Новости, on russian}.
 
+@node Release 8_4_0
+@section Release 8.4.0
+@itemize
+
+@item
+Multicast related interface names (@code{mcd-listen} and @code{mcd-send}
+configuration options) are now regular expressions. By default
+@command{nncp-cfgnew} uncomments them now with @code{.*} interface name.
+
+@item
+@command{nncp-call} command has @option{-mcd-wait} option to wait for
+multicast packet about node's address.
+
+@item
+@command{nncp-file} command skips everything that is neither regular
+file nor directory during pax-archive creation.
+
+@end itemize
+
 @node Release 8_3_0
 @section Release 8.3.0
 @itemize
index 077a907fdcd45761de28ac2bcf1629415bcb954f..8a5b8670de7a379d5e6f9afdff1e6f2f6f64fe1b 100644 (file)
@@ -22,7 +22,9 @@ import (
        "flag"
        "fmt"
        "log"
+       "net"
        "os"
+       "regexp"
        "strings"
        "time"
 
@@ -47,6 +49,7 @@ func main() {
                listOnly    = flag.Bool("list", false, "Only list remote packets")
                noCK        = flag.Bool("nock", false, "Do no checksum checking")
                onlyPktsRaw = flag.String("pkts", "", "Recieve only that packets, comma separated")
+               mcdWait     = flag.Uint("mcd-wait", 60, "Wait for MCD for specified number of seconds")
                rxRate      = flag.Int("rxrate", 0, "Maximal receive rate, pkts/sec")
                txRate      = flag.Int("txrate", 0, "Maximal transmit rate, pkts/sec")
                spoolPath   = flag.String("spool", "", "Override path to spool")
@@ -150,6 +153,41 @@ func main() {
                }
        }
 
+       if *mcdWait > 0 {
+               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)
+                                       }
+                               }
+                       }
+               }
+               addrs = nil
+               for i := int(*mcdWait); i > 0; i-- {
+                       nncp.MCDAddrsM.RLock()
+                       for _, mcdAddr := range nncp.MCDAddrs[*node.Id] {
+                               addrs = append(addrs, mcdAddr.Addr.String())
+                       }
+                       if len(addrs) > 0 {
+                               break
+                       }
+                       nncp.MCDAddrsM.RUnlock()
+                       time.Sleep(time.Second)
+               }
+               if len(addrs) == 0 {
+                       log.Fatalf("No MCD packets from the node during %d seconds", *mcdWait)
+               }
+       }
+
        var onlyPkts map[[32]byte]bool
        if len(*onlyPktsRaw) > 0 {
                splitted = strings.Split(*onlyPktsRaw, ",")
index 981e42e68d204e3faadf845d25036ac32a329d55..690244141eaf87e151112c3822b7c8ff9c637ff0 100644 (file)
@@ -23,7 +23,9 @@ import (
        "flag"
        "fmt"
        "log"
+       "net"
        "os"
+       "regexp"
        "sync"
        "time"
 
@@ -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)
+                               }
+                       }
                }
        }
 
index e049b444bdb87a61f9d59c0d57659a150bfee773..8e0fa9f819c48e2e4ad1801e6a106229c73a1f4a 100644 (file)
@@ -198,10 +198,11 @@ func main() {
   # nohdr: true
 
   # MultiCast Discovery:
-  # List of interfaces where to listen for MCD announcements
-  # mcd-listen: ["em0", "igb1"]
-  # Interfaces and intervals (in seconds) where to send MCD announcements
-  # mcd-send: {em0: 60, igb1: 5}
+  # List of interface regular expressions where to listen for MCD announcements
+  mcd-listen: [".*"]
+  # Interfaces regular expressions and intervals (in seconds) where to send
+  # MCD announcements
+  mcd-send: {.*: 10}
 
   # Yggdrasil related aliases:
   # yggdrasil-aliases: {
index 88f7e20fec9dfa1c5692dfb04235ccf1171f3ba4..5fd6f6d0353f5cc0e7e5e5212234e9bd4def05ea 100644 (file)
@@ -24,6 +24,7 @@ import (
        "log"
        "net"
        "os"
+       "regexp"
        "strconv"
        "strings"
        "time"
@@ -105,6 +106,31 @@ func performSP(
        close(nodeIdC)
 }
 
+func startMCDTx(ctx *nncp.Ctx, port int, zeroInterval bool) error {
+       ifis, err := net.Interfaces()
+       if err != nil {
+               return err
+       }
+       for ifiReString, secs := range ctx.MCDTxIfis {
+               ifiRe, err := regexp.CompilePOSIX(ifiReString)
+               if err != nil {
+                       return err
+               }
+               var interval time.Duration
+               if !zeroInterval {
+                       interval = time.Duration(secs) * time.Second
+               }
+               for _, ifi := range ifis {
+                       if ifiRe.MatchString(ifi.Name) {
+                               if err = ctx.MCDTx(ifi.Name, port, interval); err != nil {
+                                       return err
+                               }
+                       }
+               }
+       }
+       return nil
+}
+
 func main() {
        var (
                cfgPath   = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
@@ -211,10 +237,8 @@ func main() {
                }
 
                if *mcdOnce {
-                       for ifiName := range ctx.MCDTxIfis {
-                               if err = ctx.MCDTx(ifiName, port, 0); err != nil {
-                                       log.Fatalln("Can not do MCD transmission:", err)
-                               }
+                       if err = startMCDTx(ctx, port, true); err != nil {
+                               log.Fatalln("Can not do MCD transmission:", err)
                        }
                        return
                }
@@ -223,13 +247,9 @@ func main() {
                if err != nil {
                        log.Fatalln("Can not listen:", err)
                }
-
-               for ifiName, secs := range ctx.MCDTxIfis {
-                       if err = ctx.MCDTx(ifiName, port, time.Duration(secs)*time.Second); err != nil {
-                               log.Fatalln("Can not run MCD transmission:", err)
-                       }
+               if err = startMCDTx(ctx, port, false); err != nil {
+                       log.Fatalln("Can not do MCD transmission:", err)
                }
-
                ln = netutil.LimitListener(ln, *maxConn)
                go func() {
                        for {
index ce0c0d71fbc082bbf2768df5893306891606c32e..b9457d378b686e13dfbf7a47fbc95fcf0da711e5 100644 (file)
@@ -40,7 +40,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.`
 const Base32Encoded32Len = 52
 
 var (
-       Version string = "8.3.0"
+       Version string = "8.4.0"
 
        Base32Codec *base32.Encoding = base32.StdEncoding.WithPadding(base32.NoPadding)
 )
index 998be8926030e7baa2fe7a1f82d15161476a1015..77db5928d852daffe12e70b0414da3d2d336c8ec 100644 (file)
--- a/src/tx.go
+++ b/src/tx.go
@@ -211,7 +211,7 @@ func (ctx *Ctx) Tx(
                r := <-results
                if r.err != nil {
                        tmp.Fd.Close()
-                       return nil, 0, err
+                       return nil, 0, r.err
                }
                if r.pktEncRaw != nil {
                        pktEncRaw = r.pktEncRaw
@@ -330,11 +330,11 @@ func prepareTxFile(srcPath string) (
                if err != nil {
                        return err
                }
-               if info.IsDir() {
+               if info.Mode().IsDir() {
                        // directory header, PAX record header+contents
                        srcSize += TarBlockSize + 2*TarBlockSize
                        dirs = append(dirs, einfo{path: path, modTime: info.ModTime()})
-               } else {
+               } else if info.Mode().IsRegular() {
                        // file header, PAX record header+contents, file content
                        srcSize += TarBlockSize + 2*TarBlockSize + info.Size()
                        if n := info.Size() % TarBlockSize; n != 0 {