]> Cypherpunks.ru repositories - nncp.git/commitdiff
Do not process job if sender is clearly unknown
authorSergey Matveev <stargrave@stargrave.org>
Thu, 8 Jul 2021 10:07:58 +0000 (13:07 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Thu, 8 Jul 2021 10:07:58 +0000 (13:07 +0300)
src/toss.go

index e5e3487c8bba60aceabad445ea2b913fccb460c1..3fc4865538e7133c0a39300539dd285d847e6c3e 100644 (file)
@@ -917,6 +917,18 @@ func (ctx *Ctx) Toss(
                        isBad = true
                        continue
                }
+               sender := ctx.Neigh[*job.PktEnc.Sender]
+               if sender == nil {
+                       err := errors.New("unknown node")
+                       ctx.LogE("rx-open", les, err, func(les LEs) string {
+                               return fmt.Sprintf(
+                                       "Tossing %s/%s",
+                                       ctx.NodeName(job.PktEnc.Sender), pktName,
+                               )
+                       })
+                       isBad = true
+                       continue
+               }
                errs := make(chan error, 1)
                var sharedKey []byte
        Retry:
@@ -927,7 +939,7 @@ func (ctx *Ctx) Toss(
                                pipeR,
                                pktName,
                                les,
-                               ctx.Neigh[*job.PktEnc.Sender],
+                               sender,
                                job.PktEnc.Nice,
                                uint64(pktSizeWithoutEnc(job.Size)),
                                job.Path,