]> Cypherpunks.ru repositories - nncp.git/commitdiff
Fix nncp-bundle invalid Rx packets placement
authorSergey Matveev <stargrave@stargrave.org>
Wed, 30 Dec 2020 13:59:59 +0000 (16:59 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 30 Dec 2020 14:00:00 +0000 (17:00 +0300)
Incoming packets must be placed on corresponding sender's directory, not
the self one. Thanks to John Goerzen for pointing this issue out.

src/cmd/nncp-bundle/main.go
src/nncp.go

index f577a1c602069817d25b0ea22adc2c6c9cacf4de..ae14e899cc89982a5b7de23b08d810e335de5550 100644 (file)
@@ -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)
                                        }
                                }
index 336cb68c215072d70c107571fd45918aeda61205..5fc64837c263f3545612260ee923e3029d3ea929 100644 (file)
@@ -38,7 +38,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.`
 )
 
 var (
-       Version string = "5.4.1"
+       Version string = "5.5.0"
 
        Base32Codec *base32.Encoding = base32.StdEncoding.WithPadding(base32.NoPadding)
 )