]> Cypherpunks.ru repositories - nncp.git/commitdiff
Take via into account when transitioning
authorSergey Matveev <stargrave@stargrave.org>
Thu, 8 Jul 2021 10:10:25 +0000 (13:10 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Thu, 8 Jul 2021 17:14:41 +0000 (20:14 +0300)
doc/news.ru.texi
doc/news.texi
src/toss.go

index f4e801d45c8139849e70ece5ad25296c5d70d3f2..d2eae5bba8d3828cf2719e72491d6db466d6eacf 100644 (file)
@@ -8,6 +8,10 @@
 @item
 Появилась @command{nncp-trns} команда для ручного создания транзитных пакетов.
 
+@item
+Если у целевой ноды транзитного пакета задан @option{via} маршрут, то
+использовать его, а не игнорировать.
+
 @end itemize
 
 @node Релиз 7.1.1
index e04631b07aa573c069c993bdd02e3a139313dfed..6f0a8c3299a291a8a0db9d5bffe490d3067ceb88 100644 (file)
@@ -9,6 +9,11 @@ See also this page @ref{Новости, on russian}.
 
 @item
 @command{nncp-trns} command appeared for manual transition packets creation.
+
+@item
+If destination node of transitional packet has non empty @option{via}
+route, then do not ignore, but use it.
+
 @end itemize
 
 @node Release 7_1_1
index 3fc4865538e7133c0a39300539dd285d847e6c3e..4a447cecadae479e81a15b39ef3d0c350cfed83a 100644 (file)
@@ -588,11 +588,35 @@ func jobProcess(
                }
                ctx.LogD("rx-tx", les, logMsg)
                if !dryRun {
-                       if err = ctx.TxTrns(node, nice, int64(pktSize), pipeR); err != nil {
-                               ctx.LogE("rx", les, err, func(les LEs) string {
-                                       return logMsg(les) + ": txing"
-                               })
-                               return err
+                       if len(node.Via) == 0 {
+                               if err = ctx.TxTrns(node, nice, int64(pktSize), pipeR); err != nil {
+                                       ctx.LogE("rx", les, err, func(les LEs) string {
+                                               return logMsg(les) + ": txing"
+                                       })
+                                       return err
+                               }
+                       } else {
+                               via := node.Via[:len(node.Via)-1]
+                               node = ctx.Neigh[*node.Via[len(node.Via)-1]]
+                               node = &Node{Id: node.Id, Via: via, ExchPub: node.ExchPub}
+                               pktTrns, err := NewPkt(PktTypeTrns, 0, nodeId[:])
+                               if err != nil {
+                                       panic(err)
+                               }
+                               if _, err = ctx.Tx(
+                                       node,
+                                       pktTrns,
+                                       nice,
+                                       int64(pktSize), 0,
+                                       pipeR,
+                                       pktName,
+                                       nil,
+                               ); err != nil {
+                                       ctx.LogE("rx", les, err, func(les LEs) string {
+                                               return logMsg(les) + ": txing"
+                                       })
+                                       return err
+                               }
                        }
                }
                ctx.LogI("rx", les, func(les LEs) string {