X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcmd%2Fnncp-ack%2Fmain.go;h=2fda750b5064302fbb8d50c1b0d3f4d87a3d498e;hb=cf9363f956cb2d93a581c11ed65c5b02910d10d5;hp=950295a7d81029f7b8b4dfc11815b454d0ea4d42;hpb=6dc8ef3b800aa15476f1c745339d4445e622efbe;p=nncp.git diff --git a/src/cmd/nncp-ack/main.go b/src/cmd/nncp-ack/main.go index 950295a..2fda750 100644 --- a/src/cmd/nncp-ack/main.go +++ b/src/cmd/nncp-ack/main.go @@ -1,6 +1,6 @@ /* NNCP -- Node to Node copy, utilities for store-and-forward data exchange -Copyright (C) 2016-2022 Sergey Matveev +Copyright (C) 2016-2023 Sergey Matveev This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,8 +37,8 @@ func usage() { fmt.Fprintf(os.Stderr, nncp.UsageHeader()) fmt.Fprintf(os.Stderr, "nncp-ack -- send packet receipt acknowledgement\n\n") fmt.Fprintf(os.Stderr, "Usage: %s [options] -all\n", os.Args[0]) - fmt.Fprintf(os.Stderr, "Usage: %s -node NODE[,...]\n", os.Args[0]) - fmt.Fprintf(os.Stderr, "Usage: %s -node NODE -pkt PKT\n", os.Args[0]) + fmt.Fprintf(os.Stderr, "Usage: %s [options] -node NODE[,...]\n", os.Args[0]) + fmt.Fprintf(os.Stderr, "Usage: %s [options] -node NODE -pkt PKT\n", os.Args[0]) fmt.Fprintln(os.Stderr, "Options:") flag.PrintDefaults() } @@ -119,15 +119,22 @@ func main() { os.Exit(1) } + acksCreated := os.NewFile(uintptr(4), "ACKsCreated") + if acksCreated == nil { + log.Fatalln("can not open FD:4") + } + if *pktRaw != "" { if len(nodes) != 1 { usage() os.Exit(1) } nncp.ViaOverride(*viaOverride, ctx, nodes[0]) - if err = ctx.TxACK(nodes[0], nice, *pktRaw, minSize); err != nil { + pktName, err := ctx.TxACK(nodes[0], nice, *pktRaw, minSize) + if err != nil { log.Fatalln(err) } + acksCreated.WriteString(nodes[0].Id.String() + "/" + pktName + "\n") return } @@ -199,7 +206,12 @@ func main() { continue } pipeR, pipeW := io.Pipe() - go nncp.PktEncRead(ctx.Self, ctx.Neigh, bufio.NewReader(fd), pipeW, true, nil) + go nncp.PktEncRead( + ctx.Self, + ctx.Neigh, + bufio.NewReaderSize(fd, nncp.MTHBlockSize), + pipeW, true, nil, + ) var pkt nncp.Pkt _, err = xdr.Unmarshal(pipeR, &pkt) fd.Close() @@ -217,9 +229,11 @@ func main() { }) continue } - if err = ctx.TxACK(node, nice, pktName, minSize); err != nil { + newPktName, err := ctx.TxACK(node, nice, pktName, minSize) + if err != nil { log.Fatalln(err) } + acksCreated.WriteString(node.Id.String() + "/" + newPktName + "\n") } } if isBad {