From: Sergey Matveev Date: Wed, 30 Dec 2020 13:59:59 +0000 (+0300) Subject: Fix nncp-bundle invalid Rx packets placement X-Git-Tag: v5.5.0^2~13 X-Git-Url: http://www.git.cypherpunks.ru/?a=commitdiff_plain;h=87245f236b40415c6e30fbaee18cdaf46b7f5c57;p=nncp.git Fix nncp-bundle invalid Rx packets placement Incoming packets must be placed on corresponding sender's directory, not the self one. Thanks to John Goerzen for pointing this issue out. --- diff --git a/src/cmd/nncp-bundle/main.go b/src/cmd/nncp-bundle/main.go index f577a1c..ae14e89 100644 --- a/src/cmd/nncp-bundle/main.go +++ b/src/cmd/nncp-bundle/main.go @@ -313,11 +313,12 @@ func main() { continue } } - sds["node"] = nncp.Base32Codec.EncodeToString(pktEnc.Recipient[:]) + sender := nncp.Base32Codec.EncodeToString(pktEnc.Sender[:]) + sds["node"] = sender sds["pkt"] = pktName sds["fullsize"] = entry.Size - selfPath := filepath.Join(ctx.Spool, ctx.SelfId.String(), string(nncp.TRx)) - dstPath := filepath.Join(selfPath, pktName) + dstDirPath := filepath.Join(ctx.Spool, sender, string(nncp.TRx)) + dstPath := filepath.Join(dstDirPath, pktName) if _, err = os.Stat(dstPath); err == nil || !os.IsNotExist(err) { ctx.LogD("nncp-bundle", sds, "Packet already exists") continue @@ -357,7 +358,7 @@ func main() { log.Fatalln("Error during flusing:", err) } if nncp.Base32Codec.EncodeToString(tmp.Hsh.Sum(nil)) == pktName { - if err = tmp.Commit(selfPath); err != nil { + if err = tmp.Commit(dstDirPath); err != nil { log.Fatalln("Error during commiting:", err) } } else { @@ -392,13 +393,13 @@ func main() { if err = tmp.Close(); err != nil { log.Fatalln("Error during closing:", err) } - if err = os.MkdirAll(selfPath, os.FileMode(0777)); err != nil { + if err = os.MkdirAll(dstDirPath, os.FileMode(0777)); err != nil { log.Fatalln("Error during mkdir:", err) } if err = os.Rename(tmp.Name(), dstPath); err != nil { log.Fatalln("Error during renaming:", err) } - if err = nncp.DirSync(selfPath); err != nil { + if err = nncp.DirSync(dstDirPath); err != nil { log.Fatalln("Error during syncing:", err) } } diff --git a/src/nncp.go b/src/nncp.go index 336cb68..5fc6483 100644 --- a/src/nncp.go +++ b/src/nncp.go @@ -38,7 +38,7 @@ along with this program. If not, see .` ) var ( - Version string = "5.4.1" + Version string = "5.5.0" Base32Codec *base32.Encoding = base32.StdEncoding.WithPadding(base32.NoPadding) )