]> Cypherpunks.ru repositories - nncp.git/commitdiff
Merge branch 'develop' v6.5.0
authorSergey Matveev <stargrave@stargrave.org>
Sun, 30 May 2021 16:38:33 +0000 (19:38 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 30 May 2021 16:38:33 +0000 (19:38 +0300)
27 files changed:
doc/download.texi
doc/news.ru.texi
doc/news.texi
ports/nncp/Makefile
src/cmd/nncp-bundle/main.go
src/cmd/nncp-call/main.go
src/cmd/nncp-caller/main.go
src/cmd/nncp-cfgenc/main.go
src/cmd/nncp-cfgmin/main.go
src/cmd/nncp-cfgnew/main.go
src/cmd/nncp-check/main.go
src/cmd/nncp-cronexpr/main.go
src/cmd/nncp-daemon/main.go
src/cmd/nncp-exec/main.go
src/cmd/nncp-file/main.go
src/cmd/nncp-freq/main.go
src/cmd/nncp-log/main.go
src/cmd/nncp-pkt/main.go
src/cmd/nncp-reass/main.go
src/cmd/nncp-rm/main.go
src/cmd/nncp-stat/main.go
src/cmd/nncp-toss/main.go
src/cmd/nncp-xfer/main.go
src/nncp.go
src/progress.go
src/sp.go
src/toss.go

index 4d6f19606c22420fdd224a4de6235fe349dcb222..ed1a3ade19305d81d88eae1ab563d87e22550afe 100644 (file)
@@ -25,6 +25,10 @@ Tarballs include all necessary required libraries:
 @multitable {XXXXX} {XXXX-XX-XX} {XXXX KiB} {link sign} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
 @headitem Version @tab Date @tab Size @tab Tarball @tab SHA256 checksum
 
+@item @ref{Release 6.4.0, 6.4.0} @tab 2021-04-22 @tab 1042 KiB
+@tab @url{download/nncp-6.4.0.tar.xz, link} @url{download/nncp-6.4.0.tar.xz.sig, sign}
+@tab @code{3D0D1156 D69AF698 D402663C F84E51CC 3D40A50D 300E34D1 105A6F75 32E4B99B}
+
 @item @ref{Release 6.3.0, 6.3.0} @tab 2021-04-14 @tab 1042 KiB
 @tab @url{download/nncp-6.3.0.tar.xz, link} @url{download/nncp-6.3.0.tar.xz.sig, sign}
 @tab @code{76C26A11 E3423540 BB7B8470 820176A3 5FCD0493 B21A872E C223EB94 43BA466B}
index aa4f62ff76387a603924cd28342fcd39b94d85cd..69e3201022834fb13d0ed0bd99199ffce390d1fb 100644 (file)
@@ -1,6 +1,27 @@
 @node Новости
 @section Новости
 
+@node Релиз 6.5.0
+@subsection Релиз 6.5.0
+@itemize
+
+@item
+Исправлено падение в @command{nncp-daemon} когда SP рукопожатие не было успешно.
+
+@item
+Исправлено возможное игнорирование плохого кода возврата автоматического tosser.
+
+@item
+Исправлена гонка при закрытии файловых дескрипторов во время завершения
+работы online протокола, которая могла привести к ошибке записи
+принятого фрагмента пакета.
+
+@item
+Убирать показ прогресса передачи пакетов когда вызов уже завершён в
+@command{nncp-daemon}, @command{nncp-call} and @command{nncp-caller}.
+
+@end itemize
+
 @node Релиз 6.4.0
 @subsection Релиз 6.4.0
 @itemize
index 67340e2ebb66abfe81239334ad790162e6b9fb0c..6fcf7337054ea605b8d988e6d70732a06d68e9fd 100644 (file)
@@ -3,6 +3,26 @@
 
 See also this page @ref{Новости, on russian}.
 
+@node Release 6.5.0
+@section Release 6.5.0
+@itemize
+
+@item
+Fixed segfault in @command{nncp-daemon} when SP handshake did not succeed.
+
+@item
+Fixed possible bad return code ignoring in automatic tosser.
+
+@item
+Fixed race during file descriptors closing when online protocol call is
+finished, that could lead to write error of received packet fragment.
+
+@item
+Kill all packet transmission progress bars in @command{nncp-daemon},
+@command{nncp-call} and @command{nncp-caller} when call is finished.
+
+@end itemize
+
 @node Release 6.4.0
 @section Release 6.4.0
 @itemize
index c398830cbb65c6a315e27e4719bfe652eac4a8ff..4fd2908c87ecd47b174af322d6fbb393b14bd98a 100644 (file)
@@ -1,5 +1,5 @@
 PORTNAME=      nncp
-DISTVERSION=   6.4.0
+DISTVERSION=   6.5.0
 CATEGORIES=    net
 MASTER_SITES=  http://www.nncpgo.org/download/
 
index 365d8b5a0eaa7967ed15fdeeedec10a232af6bbd..c808a66657cded797ff0f296b3ee11f7945c9de4 100644 (file)
@@ -70,6 +70,7 @@ func main() {
                version   = flag.Bool("version", false, "Print version information")
                warranty  = flag.Bool("warranty", false, "Print warranty information")
        )
+       log.SetFlags(log.Lshortfile)
        flag.Usage = usage
        flag.Parse()
        if *warranty {
index a92c5c87bdf0e12c4ee2baa7b19daa4c31002c0b..3b84e70df4acf00ffc08ac0a4955a5686e087765 100644 (file)
@@ -67,6 +67,7 @@ func main() {
                autoTossNoExec = flag.Bool("autotoss-noexec", false, "Do not process \"exec\" packets during tossing")
                autoTossNoTrns = flag.Bool("autotoss-notrns", false, "Do not process \"trns\" packets during tossing")
        )
+       log.SetFlags(log.Lshortfile)
        flag.Usage = usage
        flag.Parse()
        if *warranty {
index d4fff0ca93e792c469332e8c1e5f5122cd1e8ed9..66b441ef2269845b35814bb6d98ae0859d3899fa 100644 (file)
@@ -57,6 +57,7 @@ func main() {
                autoTossNoExec = flag.Bool("autotoss-noexec", false, "Do not process \"exec\" packets during tossing")
                autoTossNoTrns = flag.Bool("autotoss-notrns", false, "Do not process \"trns\" packets during tossing")
        )
+       log.SetFlags(log.Lshortfile)
        flag.Usage = usage
        flag.Parse()
        if *warranty {
index 3db61849cc43cf429a65c43c1982b3789d472cad..95272ad4715f669dbf9994a8075354ad22497999 100644 (file)
@@ -53,6 +53,7 @@ func main() {
                version  = flag.Bool("version", false, "Print version information")
                warranty = flag.Bool("warranty", false, "Print warranty information")
        )
+       log.SetFlags(log.Lshortfile)
        flag.Usage = usage
        flag.Parse()
        if *warranty {
index b75bbe0e3bafcf424435b3829028c0458ed0f190..765175539934b4808787c1f60a978f5bdde6d681 100644 (file)
@@ -41,6 +41,7 @@ func main() {
                version  = flag.Bool("version", false, "Print version information")
                warranty = flag.Bool("warranty", false, "Print warranty information")
        )
+       log.SetFlags(log.Lshortfile)
        flag.Usage = usage
        flag.Parse()
        if *warranty {
index ebe603d1bd65b20cb598e8c968baf4f8937e3e6b..f823601084ca7bdd30664b805807483b02036a04 100644 (file)
@@ -21,6 +21,7 @@ package main
 import (
        "flag"
        "fmt"
+       "log"
        "os"
 
        "go.cypherpunks.ru/nncp/v6"
@@ -38,6 +39,7 @@ func main() {
                version    = flag.Bool("version", false, "Print version information")
                warranty   = flag.Bool("warranty", false, "Print warranty information")
        )
+       log.SetFlags(log.Lshortfile)
        flag.Usage = usage
        flag.Parse()
        if *warranty {
index 70ee2792c14f4e5913ff5759eb604e1803d554d6..ddb2949c6a5e9d9b9a55e5e57ea566dfc957bf1b 100644 (file)
@@ -49,6 +49,7 @@ func main() {
                version   = flag.Bool("version", false, "Print version information")
                warranty  = flag.Bool("warranty", false, "Print warranty information")
        )
+       log.SetFlags(log.Lshortfile)
        flag.Usage = usage
        flag.Parse()
        if *warranty {
index 910d9690e57dadcea5b3f79878925d79849a4bb4..569b9002bf509749938d57e9e72563538e20af24 100644 (file)
@@ -43,6 +43,7 @@ func main() {
                version  = flag.Bool("version", false, "Print version information")
                warranty = flag.Bool("warranty", false, "Print warranty information")
        )
+       log.SetFlags(log.Lshortfile)
        flag.Usage = usage
        flag.Parse()
        if *warranty {
index a69175a299f417794e465758e8df3176f2eb95a6..c5f8a10cddd2489917061aed9e41db5844a53c63 100644 (file)
@@ -108,17 +108,21 @@ func performSP(
                        )
                })
        } else {
-               nodeId := "unknown"
+               var nodeId string
+               var nodeName string
                if state.Node == nil {
+                       nodeId = "unknown"
+                       nodeName = "unknown"
                        nodeIdC <- nil
                } else {
-                       nodeIdC <- state.Node.Id
                        nodeId = state.Node.Id.String()
+                       nodeName = state.Node.Name
+                       nodeIdC <- state.Node.Id
                }
                ctx.LogI(
                        "call-started",
                        nncp.LEs{{K: "Node", V: nodeId}},
-                       func(les nncp.LEs) string { return "Connected to " + state.Node.Name },
+                       func(les nncp.LEs) string { return "Connected to " + nodeName },
                )
        }
        close(nodeIdC)
@@ -148,6 +152,7 @@ func main() {
                autoTossNoExec = flag.Bool("autotoss-noexec", false, "Do not process \"exec\" packets during tossing")
                autoTossNoTrns = flag.Bool("autotoss-notrns", false, "Do not process \"trns\" packets during tossing")
        )
+       log.SetFlags(log.Lshortfile)
        flag.Usage = usage
        flag.Parse()
        if *warranty {
index 640682a4699dcb4c472931f1109dd1d0dda8cde2..0aa4444254de3add2b45f22760a6afef72ae4ab2 100644 (file)
@@ -53,6 +53,7 @@ func main() {
                version      = flag.Bool("version", false, "Print version information")
                warranty     = flag.Bool("warranty", false, "Print warranty information")
        )
+       log.SetFlags(log.Lshortfile)
        flag.Usage = usage
        flag.Parse()
        if *warranty {
index 6757e4af2f3f5030a3862ebac73119de74138ffb..793a6ef22c3741fa950e39ff2224a3cee4962d8a 100644 (file)
@@ -57,6 +57,7 @@ func main() {
                version      = flag.Bool("version", false, "Print version information")
                warranty     = flag.Bool("warranty", false, "Print warranty information")
        )
+       log.SetFlags(log.Lshortfile)
        flag.Usage = usage
        flag.Parse()
        if *warranty {
index 8738b8479fe64c57ef592fa31b30ae34fe93ce71..8fe7e5fc33ba4c4e551d4e1554771eb7ee0dab90 100644 (file)
@@ -52,6 +52,7 @@ func main() {
                version      = flag.Bool("version", false, "Print version information")
                warranty     = flag.Bool("warranty", false, "Print warranty information")
        )
+       log.SetFlags(log.Lshortfile)
        flag.Usage = usage
        flag.Parse()
        if *warranty {
index e98f0b8228ea895a5475803a7383ae4c48dca666..6fc0ae78759416db4beee691a01409e2a5e6a965 100644 (file)
@@ -44,6 +44,7 @@ func main() {
                version  = flag.Bool("version", false, "Print version information")
                warranty = flag.Bool("warranty", false, "Print warranty information")
        )
+       log.SetFlags(log.Lshortfile)
        flag.Usage = usage
        flag.Parse()
        if *warranty {
index 3245970266713ae810ce9c852194cb28e4d57d05..9d8ba2ce137fd312eeba09e710df5d7b2afbdea9 100644 (file)
@@ -49,6 +49,7 @@ func main() {
                version    = flag.Bool("version", false, "Print version information")
                warranty   = flag.Bool("warranty", false, "Print warranty information")
        )
+       log.SetFlags(log.Lshortfile)
        flag.Usage = usage
        flag.Parse()
        if *warranty {
index 4ed30a57af7f29e50080777092d1bd00b48cde2a..ec9bdd20fa499ab0e6fe738c135fc496dd98c1a7 100644 (file)
@@ -330,6 +330,7 @@ func main() {
                version   = flag.Bool("version", false, "Print version information")
                warranty  = flag.Bool("warranty", false, "Print warranty information")
        )
+       log.SetFlags(log.Lshortfile)
        flag.Usage = usage
        flag.Parse()
        if *warranty {
index d8add6ed97ebc88dc99f91c33193a3e89a970426..1fc1fc2cd5d6b3d3b2f416d4ed6ac794e854c3d8 100644 (file)
@@ -69,6 +69,7 @@ func main() {
                version   = flag.Bool("version", false, "Print version information")
                warranty  = flag.Bool("warranty", false, "Print warranty information")
        )
+       log.SetFlags(log.Lshortfile)
        flag.Usage = usage
        flag.Parse()
        if *warranty {
index 2079d040a49603bcd8499449e0193aa3d63f1b13..edeed8b4688dd620e171c61c87591d8cbe0a8d2f 100644 (file)
@@ -56,6 +56,7 @@ func main() {
                version   = flag.Bool("version", false, "Print version information")
                warranty  = flag.Bool("warranty", false, "Print warranty information")
        )
+       log.SetFlags(log.Lshortfile)
        flag.Usage = usage
        flag.Parse()
        if *warranty {
index 2bf337380a2ee2c4aa5df780468cda5d8c4013df..b8a0d3ca81bf44d07f79be5f74a5ec6e7bcfe8cc 100644 (file)
@@ -56,6 +56,7 @@ func main() {
                version   = flag.Bool("version", false, "Print version information")
                warranty  = flag.Bool("warranty", false, "Print warranty information")
        )
+       log.SetFlags(log.Lshortfile)
        flag.Usage = usage
        flag.Parse()
        if *warranty {
index 05b3909a2199f31884e727d0347ca439b388c173..ae47ec6a842687e9cfb20d733d77a27427acdb56 100644 (file)
@@ -57,6 +57,7 @@ func main() {
                version   = flag.Bool("version", false, "Print version information")
                warranty  = flag.Bool("warranty", false, "Print warranty information")
        )
+       log.SetFlags(log.Lshortfile)
        flag.Usage = usage
        flag.Parse()
        if *warranty {
index 7c1b7c576dd04da62f3e61662f21760ba01fe0e9..a9af93cacba68392ca0e7d1a426da10eaf2fa73d 100644 (file)
@@ -40,7 +40,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.`
 const Base32Encoded32Len = 52
 
 var (
-       Version string = "6.4.0"
+       Version string = "6.5.0"
 
        Base32Codec *base32.Encoding = base32.StdEncoding.WithPadding(base32.NoPadding)
 )
index dc55a000e01c4e12528dd682d15a44f093d82abc..945c57526419a2166cb20d3ea27057eff844da8b 100644 (file)
@@ -153,3 +153,13 @@ func Progress(prefix string, les LEs) {
                progressBarsLock.Unlock()
        }
 }
+
+func ProgressKill(pkt string) {
+       progressBarsLock.Lock()
+       pb, exists := progressBars[pkt]
+       if exists {
+               pb.Kill()
+               delete(progressBars, pkt)
+       }
+       progressBarsLock.Unlock()
+}
index 6d31375e137ff3a044d0bb5c1ad8ea4c481b4dd0..0b039e6bffb9f80f6eecff80b36d8ce985552215 100644 (file)
--- a/src/sp.go
+++ b/src/sp.go
@@ -236,6 +236,7 @@ type SPState struct {
        fdsLock        sync.RWMutex
        fileHashers    map[string]*HasherAndOffset
        checkerQueues  SPCheckerQueues
+       progressBars   map[string]struct{}
        sync.RWMutex
 }
 
@@ -257,11 +258,6 @@ func (state *SPState) SetDead() {
                for range state.pings {
                }
        }()
-       go func() {
-               for _, s := range state.fds {
-                       s.fd.Close()
-               }
-       }()
 }
 
 func (state *SPState) NotAlive() bool {
@@ -441,6 +437,7 @@ func (state *SPState) StartI(conn ConnDeadlined) error {
        state.pings = make(chan struct{})
        state.infosTheir = make(map[[32]byte]*SPInfo)
        state.infosOurSeen = make(map[[32]byte]uint8)
+       state.progressBars = make(map[string]struct{})
        state.started = started
        state.rxLock = rxLock
        state.txLock = txLock
@@ -558,6 +555,7 @@ func (state *SPState) StartR(conn ConnDeadlined) error {
        state.pings = make(chan struct{})
        state.infosOurSeen = make(map[[32]byte]uint8)
        state.infosTheir = make(map[[32]byte]*SPInfo)
+       state.progressBars = make(map[string]struct{})
        state.started = started
        state.xxOnly = xxOnly
 
@@ -792,13 +790,20 @@ func (state *SPState) StartWorkers(
                                pingTicker.Stop()
                                return
                        case now := <-deadlineTicker.C:
-                               if (now.Sub(state.RxLastNonPing) >= state.onlineDeadline &&
-                                       now.Sub(state.TxLastNonPing) >= state.onlineDeadline) ||
-                                       (state.maxOnlineTime > 0 && state.mustFinishAt.Before(now)) ||
-                                       (now.Sub(state.RxLastSeen) >= 2*PingTimeout) {
-                                       state.SetDead()
-                                       conn.Close() // #nosec G104
+                               if now.Sub(state.RxLastNonPing) >= state.onlineDeadline &&
+                                       now.Sub(state.TxLastNonPing) >= state.onlineDeadline {
+                                       goto Deadlined
                                }
+                               if state.maxOnlineTime > 0 && state.mustFinishAt.Before(now) {
+                                       goto Deadlined
+                               }
+                               if now.Sub(state.RxLastSeen) >= 2*PingTimeout {
+                                       goto Deadlined
+                               }
+                               break
+                       Deadlined:
+                               state.SetDead()
+                               conn.Close() // #nosec G104
                        case now := <-pingTicker.C:
                                if now.After(state.TxLastSeen.Add(PingTimeout)) {
                                        state.wg.Add(1)
@@ -989,6 +994,7 @@ func (state *SPState) StartWorkers(
                                        LE{"FullSize", fullSize},
                                )
                                if state.Ctx.ShowPrgrs {
+                                       state.progressBars[pktName] = struct{}{}
                                        Progress("Tx", lesp)
                                }
                                state.Lock()
@@ -1002,6 +1008,9 @@ func (state *SPState) StartWorkers(
                                                } else {
                                                        state.queueTheir = state.queueTheir[:0]
                                                }
+                                               if state.Ctx.ShowPrgrs {
+                                                       delete(state.progressBars, pktName)
+                                               }
                                        } else {
                                                state.queueTheir[0].freq.Offset += uint64(len(buf))
                                        }
@@ -1138,6 +1147,12 @@ func (state *SPState) Wait() {
        if txDuration > 0 {
                state.TxSpeed = state.TxBytes / txDuration
        }
+       for _, s := range state.fds {
+               s.fd.Close()
+       }
+       for pktName := range state.progressBars {
+               ProgressKill(pktName)
+       }
 }
 
 func (state *SPState) ProcessSP(payload []byte) ([][]byte, error) {
@@ -1439,11 +1454,15 @@ func (state *SPState) ProcessSP(payload []byte) ([][]byte, error) {
                        }
                        lesp = append(lesp, LE{"FullSize", fullsize})
                        if state.Ctx.ShowPrgrs {
+                               state.progressBars[pktName] = struct{}{}
                                Progress("Rx", lesp)
                        }
                        if fullsize != ourSize {
                                continue
                        }
+                       if state.Ctx.ShowPrgrs {
+                               delete(state.progressBars, pktName)
+                       }
                        logMsg = func(les LEs) string {
                                return fmt.Sprintf(
                                        "Got packet %s %d%% (%s / %s)",
index 37acf542d1345b51c6403af06a4b97a215e58762..1752fd2a4f1c34af444176573f35547df8c022b2 100644 (file)
@@ -689,7 +689,7 @@ func (ctx *Ctx) AutoToss(
                        default:
                        }
                        time.Sleep(time.Second)
-                       bad = !ctx.Toss(nodeId, nice, false, doSeen, noFile, noFreq, noExec, noTrns)
+                       bad = !ctx.Toss(nodeId, nice, false, doSeen, noFile, noFreq, noExec, noTrns) || bad
                }
        }()
        return finish, badCode