From: Sergey Matveev Date: Thu, 8 Jul 2021 10:10:25 +0000 (+0300) Subject: Take via into account when transitioning X-Git-Tag: v7.2.0^2~3 X-Git-Url: http://www.git.cypherpunks.ru/?p=nncp.git;a=commitdiff_plain;h=28707662c105334706aa3979759b0e76da94fa97 Take via into account when transitioning --- diff --git a/doc/news.ru.texi b/doc/news.ru.texi index f4e801d..d2eae5b 100644 --- a/doc/news.ru.texi +++ b/doc/news.ru.texi @@ -8,6 +8,10 @@ @item Появилась @command{nncp-trns} команда для ручного создания транзитных пакетов. +@item +Если у целевой ноды транзитного пакета задан @option{via} маршрут, то +использовать его, а не игнорировать. + @end itemize @node Релиз 7.1.1 diff --git a/doc/news.texi b/doc/news.texi index e04631b..6f0a8c3 100644 --- a/doc/news.texi +++ b/doc/news.texi @@ -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 diff --git a/src/toss.go b/src/toss.go index 3fc4865..4a447ce 100644 --- a/src/toss.go +++ b/src/toss.go @@ -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 {