]> Cypherpunks.ru repositories - nncp.git/commitdiff
nncp-rm command
authorSergey Matveev <stargrave@stargrave.org>
Sun, 2 Apr 2017 14:21:19 +0000 (17:21 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 2 Apr 2017 14:24:22 +0000 (17:24 +0300)
VERSION
common.mk
doc/cmds.texi
doc/news.texi
ports/nncp/Makefile
src/cypherpunks.ru/nncp/cmd/nncp-rm/main.go [new file with mode: 0644]

diff --git a/VERSION b/VERSION
index 2eb3c4fe4eebcdea3da0790cc0ba74cb286ec4f4..5a2a5806df6e909afe3609b5706cb1012913ca0e 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.5
+0.6
index c13ba525be999b6f2026a9ba0e57fd180667f3e2..e949d1283c2b482f89b1612a2a07352438fc068f 100644 (file)
--- a/common.mk
+++ b/common.mk
@@ -17,7 +17,6 @@ LDFLAGS = \
        -X cypherpunks.ru/nncp.DefaultLogPath=$(LOGPATH)
 
 ALL = \
-       nncp-mail \
        nncp-call \
        nncp-caller \
        nncp-check \
@@ -25,9 +24,11 @@ ALL = \
        nncp-file \
        nncp-freq \
        nncp-log \
+       nncp-mail \
        nncp-mincfg \
        nncp-newcfg \
        nncp-pkt \
+       nncp-rm \
        nncp-stat \
        nncp-toss \
        nncp-xfer
@@ -67,6 +68,9 @@ nncp-newcfg:
 nncp-pkt:
        GOPATH=$(GOPATH) go build -ldflags "$(LDFLAGS)" cypherpunks.ru/nncp/cmd/nncp-pkt
 
+nncp-rm:
+       GOPATH=$(GOPATH) go build -ldflags "$(LDFLAGS)" cypherpunks.ru/nncp/cmd/nncp-rm
+
 nncp-stat:
        GOPATH=$(GOPATH) go build -ldflags "$(LDFLAGS)" cypherpunks.ru/nncp/cmd/nncp-stat
 
index 42197da77401e95616e094f0da28d9539d434e8d..4fa10456e5430e39b0b7b42a0434bdee076c40c5 100644 (file)
@@ -289,3 +289,14 @@ configuration file version without any private keys.
 @file{DIR} directory has the following structure:
 @file{RECIPIENT/SENDER/PACKET}, where @file{RECIPIENT} is Base32 encoded
 destination node, @file{SENDER} is Base32 encoded sender node.
+
+@node nncp-rm
+@section nncp-rm
+
+@verbatim
+% nncp-rm [options] NODE PKT
+@end verbatim
+
+Remove specified packet (Base32 name) in @option{NODE}'s queues. This
+command is useful when you want to remove the packet that is failing to
+be processed.
index 0105b90be168aec5d610d79f800c902b8aa42d23..ec43ffcd3e09c2ea4737d48efa095d3d8d55fdb7 100644 (file)
@@ -1,6 +1,13 @@
 @node News
 @unnumbered News
 
+@node Release 0.6
+@section Release 0.6
+@itemize
+@item Small @command{nncp-rm} command appeared.
+@item Cryptographic libraries (dependecies) are updated.
+@end itemize
+
 @node Release 0.5
 @section Release 0.5
 @itemize
index 309cff8401c0c6a6a2c7d7606db843303a44b1b5..00d8d558b92e431a9fc6c80ad13290b8ad70e09c 100644 (file)
@@ -1,7 +1,7 @@
 # $FreeBSD$
 
 PORTNAME=      nncp
-PORTVERSION=   0.5
+PORTVERSION=   0.6
 CATEGORIES=    net
 MASTER_SITES=  http://www.nncpgo.org/download/ \
                http://sourceforge.net/projects/nncp/files/
@@ -37,6 +37,7 @@ PLIST_FILES=  bin/nncp-call \
                bin/nncp-mincfg \
                bin/nncp-newcfg \
                bin/nncp-pkt \
+               bin/nncp-rm \
                bin/nncp-stat \
                bin/nncp-toss \
                bin/nncp-xfer \
diff --git a/src/cypherpunks.ru/nncp/cmd/nncp-rm/main.go b/src/cypherpunks.ru/nncp/cmd/nncp-rm/main.go
new file mode 100644 (file)
index 0000000..00a13a4
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+NNCP -- Node to Node copy, utilities for store-and-forward data exchange
+Copyright (C) 2016-2017 Sergey Matveev <stargrave@stargrave.org>
+
+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
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+// Remove packet from the queue
+package main
+
+import (
+       "flag"
+       "fmt"
+       "io/ioutil"
+       "log"
+       "os"
+       "path/filepath"
+
+       "cypherpunks.ru/nncp"
+)
+
+func usage() {
+       fmt.Fprintf(os.Stderr, nncp.UsageHeader())
+       fmt.Fprintln(os.Stderr, "nncp-rm -- remove packet\n")
+       fmt.Fprintf(os.Stderr, "Usage: %s [options] NODE PKT\nOptions:\n", os.Args[0])
+       flag.PrintDefaults()
+}
+
+func main() {
+       var (
+               cfgPath  = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
+               quiet    = flag.Bool("quiet", false, "Print only errors")
+               debug    = flag.Bool("debug", false, "Print debug messages")
+               version  = flag.Bool("version", false, "Print version information")
+               warranty = flag.Bool("warranty", false, "Print warranty information")
+       )
+       flag.Usage = usage
+       flag.Parse()
+       if *warranty {
+               fmt.Println(nncp.Warranty)
+               return
+       }
+       if *version {
+               fmt.Println(nncp.VersionGet())
+               return
+       }
+       if flag.NArg() != 2 {
+               usage()
+               os.Exit(1)
+       }
+
+       cfgRaw, err := ioutil.ReadFile(nncp.CfgPathFromEnv(cfgPath))
+       if err != nil {
+               log.Fatalln("Can not read config:", err)
+       }
+       ctx, err := nncp.CfgParse(cfgRaw)
+       if err != nil {
+               log.Fatalln("Can not parse config:", err)
+       }
+       ctx.Quiet = *quiet
+       ctx.Debug = *debug
+
+       node, err := ctx.FindNode(flag.Arg(0))
+       if err != nil {
+               log.Fatalln("Invalid NODE specified:", err)
+       }
+
+       pktName := flag.Arg(1)
+       remove := func(xx nncp.TRxTx) bool {
+               for job := range ctx.Jobs(node.Id, xx) {
+                       job.Fd.Close()
+                       if filepath.Base(job.Fd.Name()) == pktName {
+                               if err = os.Remove(job.Fd.Name()); err != nil {
+                                       log.Fatalln("Can not remove packet:", err)
+                               }
+                               return true
+                       }
+               }
+               return false
+       }
+
+       if !(remove(nncp.TRx) || remove(nncp.TTx)) {
+               log.Fatalln("Have not found specified packet")
+       }
+}