]> Cypherpunks.ru repositories - nncp.git/commitdiff
Merge branch 'develop' 3.4
authorSergey Matveev <stargrave@stargrave.org>
Sun, 8 Jul 2018 13:30:15 +0000 (16:30 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 8 Jul 2018 13:30:15 +0000 (16:30 +0300)
15 files changed:
README.RU
VERSION
doc/about.ru.texi
doc/about.texi
doc/cmds.texi
doc/download.texi
doc/install.texi
doc/news.ru.texi
doc/news.texi
makedist.sh
src/cypherpunks.ru/nncp/cmd/nncp-daemon/main.go
src/cypherpunks.ru/nncp/sp.go
src/golang.org/x/crypto
src/golang.org/x/net
src/golang.org/x/sys

index 21bb25a259effc626d2db4b03933eeae8df43fac..30e40c321bfc29e8c28ab35f060babfbcec28300 100644 (file)
--- a/README.RU
+++ b/README.RU
@@ -1,5 +1,5 @@
 NNCP (Node to Node copy) это набор утилит упрощающий безопасный обмен
-файлами и почтой в режиме сохранить-и-переслать.
+файлами, почтой и командами в режиме сохранить-и-переслать.
 
 Эти утилиты предназначены помочь с построением одноранговых устойчивых к
 разрывам сетей небольшого размера (дюжины узлов), в режиме друг-к-другу
diff --git a/VERSION b/VERSION
index eb39e5382f4f035e4d71c7f67712cdbfa6c0c335..2f4b60750dc3500b0e4cf08f316a960a7ca42b40 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.3
+3.4
index baf97094cebe986de7d38fe4888282182d5edbdb..3b2664c863661fc799f2a900003317f9d3437157 100644 (file)
@@ -2,7 +2,7 @@
 @section Подробнее об утилитах NNCP
 
 @strong{NNCP} (Node to Node copy) это набор утилит упрощающий безопасный
-обмен файлами и почтой в режиме сохранить-и-переслать.
+обмен файлами, почтой и командами в режиме сохранить-и-переслать.
 
 Эти утилиты предназначены помочь с построением однораговых
 @url{https://ru.wikipedia.org/wiki/DTN, устойчивых к разрывам} сетей
index 01bfc5ee6bf1d049dc19102465d30a7bc40fb2d3..f8070f15a0e766338880e015891d4d84471a5450 100644 (file)
@@ -1,5 +1,5 @@
 @strong{NNCP} (Node to Node copy) is a collection of utilities
-simplifying secure store-and-forward files and mail exchanging.
+simplifying secure store-and-forward files, mail and command exchanging.
 
 See also this page @ref{Об утилитах, on russian}.
 
index c5f4607b826e726800a1895633c223ddca634cad..2f6f386f66a558a058749551799af09e409dd540 100644 (file)
@@ -230,7 +230,7 @@ not used often in practice, if ever.
 @section nncp-daemon
 
 @verbatim
-% nncp-daemon [options] [-maxconn INT] [-bind ADDR]
+% nncp-daemon [options] [-maxconn INT] [-bind ADDR] [-inetd]
 @end verbatim
 
 Start listening TCP daemon, wait for incoming connections and run
@@ -242,6 +242,13 @@ time to time.
 can handle. @option{-bind} option specifies @option{addr:port} it must
 bind to and listen.
 
+It could be run as @command{inetd} service, by specifying
+@option{-inetd} option. Example inetd-entry:
+
+@verbatim
+uucp   stream  tcp6    nowait  nncpuser        /usr/local/bin/nncp-daemon      nncp-daemon -inetd
+@end verbatim
+
 @node nncp-exec
 @section nncp-exec
 
@@ -503,9 +510,10 @@ tells what it will do.
 running this command as a daemon.
 
 @option{-seen} option creates empty @file{XXX.seen} file after
-successful tossing of @file{XXX} packet. @ref{nncp-xfer} and
-@ref{nncp-bundle} commands skip inbound packets that has been already
-seen, processed and tossed. This is helpful to defeat duplicates.
+successful tossing of @file{XXX} packet. @ref{nncp-xfer},
+@ref{nncp-bundle}, @ref{nncp-daemon} and @ref{nncp-call} commands skip
+inbound packets that has been already seen, processed and tossed. This
+is helpful to prevent duplicates.
 
 @option{-nofile}, @option{-nofreq}, @option{-nomail}, @option{-notrns}
 options allow to disable any kind of packet types processing.
index 92b05c94393a7ca133d9b1b8d64e67abb6859a02..65bc9f933fb485b7faf9087a7dd7898a6338d1fb 100644 (file)
@@ -23,6 +23,10 @@ Tarballs include all necessary required libraries:
 @multitable {XXXXX} {XXXX KiB} {link sign} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
 @headitem Version @tab Size @tab Tarball @tab SHA256 checksum
 
+@item @ref{Release 3.3, 3.3} @tab 1152 KiB
+@tab @url{download/nncp-3.3.tar.xz, link} @url{download/nncp-3.3.tar.xz.sig, sign}
+@tab @code{1F8FA9B4 6125D8A9 0608298B A1ED87E1 12DB2D8B 81C766DE F4DFE191 C7B1BFC2}
+
 @item @ref{Release 3.2, 3.2} @tab 1147 KiB
 @tab @url{download/nncp-3.2.tar.xz, link} @url{download/nncp-3.2.tar.xz.sig, sign}
 @tab @code{BE76802F 1E273D1D E91F0648 A7CB23C5 989F5390 A36F2D0C FD873046 51B9141E}
index ebcc530d74d3eea89089276b4ed54ccf67a3864f..b4df48425ff61ab3b826b1c673ca9d1d5e72b5d0 100644 (file)
@@ -5,7 +5,7 @@ Possibly NNCP package already exists for your distribution:
 
 @itemize
 @item @url{https://www.freshports.org/net/nncp/, FreeBSD ports}
-@item @url{https://github.com/voidlinux/void-packages/blob/master/srcpkgs/nncp/template, Void Linux}
+@item @url{https://github.com/void-linux/void-packages/blob/master/srcpkgs/nncp/template, Void Linux}
 @end itemize
 
 NNCP should run on any POSIX-compatible operating system.
index b26a6330418bee0daf85766545f0af783eab9c27..46e635732d303246423e68198c843d445a918054 100644 (file)
@@ -1,6 +1,13 @@
 @node Новости
 @section Новости
 
+@node Релиз 3.4
+@subsection Релиз 3.4
+@itemize
+@item
+@command{nncp-daemon} может быть запущен как @command{inetd}-служба.
+@end itemize
+
 @node Релиз 3.3
 @subsection Релиз 3.3
 @itemize
@@ -144,7 +151,7 @@ HKDF-BLAKE2b-256 KDF алгоритм заменён на BLAKE2Xb XOF. Ещё 
 @subsection Релиз 0.11
 @itemize
 @item
-Вывод команды @command{nncp-stat} отсортирован по имены ноды.
+Вывод команды @command{nncp-stat} отсортирован по имени ноды.
 @end itemize
 
 @node Релиз 0.10
index af44898b4882294350c6df5a0baae99e4c141282..16f1d6f3e3cfe3ab53d05051f57b1fdde00efae9 100644 (file)
@@ -3,6 +3,13 @@
 
 See also this page @ref{Новости, on russian}.
 
+@node Release 3.4
+@section Release 3.4
+@itemize
+@item
+@command{nncp-daemon} can be run as @command{inetd}-service.
+@end itemize
+
 @node Release 3.3
 @section Release 3.3
 @itemize
@@ -19,7 +26,7 @@ Simple packet rate limiter added to online-related tools
 (@command{nncp-daemon}, @command{nncp-call}, @command{nncp-caller}).
 @item
 Ability to specify niceness with symbolic notation:
-@verb{|NORMAL|}, @verb{|BULK+10|}, @verb{|PRIORITY-5|}, итд.
+@verb{|NORMAL|}, @verb{|BULK+10|}, @verb{|PRIORITY-5|}, etc.
 @item
 Changed default niceness levels:
 for @command{nncp-exec} from 64 to 96,
@@ -85,7 +92,7 @@ processing: @option{-nofile}, @option{-nofreq}, @option{-noexec},
 @option{-notrns}.
 @item
 @command{nncp-file} command uses
-@option{FreqMinSize}/@option{FreqChunked} conifiguration file options
+@option{FreqMinSize}/@option{FreqChunked} configuration file options
 for @option{-minsize}/@option{-chunked} by default. You can turn this
 off by specifying zero value.
 @end itemize
index f6e6ad920be1349044558a815de7a2dcad9820b8..8e487d815fb3bfce278c94aa259aa8cc26bc5e68 100755 (executable)
@@ -35,6 +35,7 @@ golang.org/x/crypto/chacha20poly1305
 golang.org/x/crypto/curve25519
 golang.org/x/crypto/ed25519
 golang.org/x/crypto/internal/chacha20
+golang.org/x/crypto/internal/subtle
 golang.org/x/crypto/nacl
 golang.org/x/crypto/poly1305
 golang.org/x/crypto/salsa20
index ba2d602c005f0ebf9bc46fb6774f01afa2db37ef..770556815e21790c7b827d6fd04b2494051f5991 100644 (file)
@@ -26,6 +26,7 @@ import (
        "net"
        "os"
        "strconv"
+       "time"
 
        "cypherpunks.ru/nncp"
        "golang.org/x/net/netutil"
@@ -38,11 +39,55 @@ func usage() {
        flag.PrintDefaults()
 }
 
+type InetdConn struct {
+       r *os.File
+       w *os.File
+}
+
+func (ic *InetdConn) Read(p []byte) (n int, err error) {
+       return ic.r.Read(p)
+}
+
+func (ic *InetdConn) Write(p []byte) (n int, err error) {
+       return ic.w.Write(p)
+}
+
+func (ic *InetdConn) SetReadDeadline(t time.Time) error {
+       return ic.r.SetReadDeadline(t)
+}
+
+func (ic *InetdConn) SetWriteDeadline(t time.Time) error {
+       return ic.w.SetWriteDeadline(t)
+}
+
+func performSP(ctx *nncp.Ctx, conn nncp.ConnDeadlined, nice uint8) {
+       state, err := ctx.StartR(conn, nice, "")
+       if err == nil {
+               ctx.LogI("call-start", nncp.SDS{"node": state.Node.Id}, "connected")
+               state.Wait()
+               ctx.LogI("call-finish", nncp.SDS{
+                       "node":     state.Node.Id,
+                       "duration": strconv.FormatInt(int64(state.Duration.Seconds()), 10),
+                       "rxbytes":  strconv.FormatInt(state.RxBytes, 10),
+                       "txbytes":  strconv.FormatInt(state.TxBytes, 10),
+                       "rxspeed":  strconv.FormatInt(state.RxSpeed, 10),
+                       "txspeed":  strconv.FormatInt(state.TxSpeed, 10),
+               }, "")
+       } else {
+               nodeId := "unknown"
+               if state != nil && state.Node != nil {
+                       nodeId = state.Node.Id.String()
+               }
+               ctx.LogE("call-start", nncp.SDS{"node": nodeId, "err": err}, "")
+       }
+}
+
 func main() {
        var (
                cfgPath   = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
                niceRaw   = flag.String("nice", nncp.NicenessFmt(255), "Minimal required niceness")
                bind      = flag.String("bind", "[::]:5400", "Address to bind to")
+               inetd     = flag.Bool("inetd", false, "Is it started as inetd service")
                maxConn   = flag.Int("maxconn", 128, "Maximal number of simultaneous connections")
                spoolPath = flag.String("spool", "", "Override path to spool")
                logPath   = flag.String("log", "", "Override path to logfile")
@@ -74,6 +119,13 @@ func main() {
                log.Fatalln("Config lacks private keys")
        }
 
+       if *inetd {
+               os.Stderr.Close()
+               conn := &InetdConn{os.Stdin, os.Stdout}
+               performSP(ctx, conn, nice)
+               return
+       }
+
        ln, err := net.Listen("tcp", *bind)
        if err != nil {
                log.Fatalln("Can not listen:", err)
@@ -86,25 +138,7 @@ func main() {
                }
                ctx.LogD("daemon", nncp.SDS{"addr": conn.RemoteAddr()}, "accepted")
                go func(conn net.Conn) {
-                       state, err := ctx.StartR(conn, nice, "")
-                       if err == nil {
-                               ctx.LogI("call-start", nncp.SDS{"node": state.Node.Id}, "connected")
-                               state.Wait()
-                               ctx.LogI("call-finish", nncp.SDS{
-                                       "node":     state.Node.Id,
-                                       "duration": strconv.FormatInt(int64(state.Duration.Seconds()), 10),
-                                       "rxbytes":  strconv.FormatInt(state.RxBytes, 10),
-                                       "txbytes":  strconv.FormatInt(state.TxBytes, 10),
-                                       "rxspeed":  strconv.FormatInt(state.RxSpeed, 10),
-                                       "txspeed":  strconv.FormatInt(state.TxSpeed, 10),
-                               }, "")
-                       } else {
-                               nodeId := "unknown"
-                               if state != nil && state.Node != nil {
-                                       nodeId = state.Node.Id.String()
-                               }
-                               ctx.LogE("call-start", nncp.SDS{"node": nodeId, "err": err}, "")
-                       }
+                       performSP(ctx, conn, nice)
                        conn.Close()
                }(conn)
        }
index 957dec9793eef5d1c57f65c6a17fd50d855196da..d3ffb9f142a08e4d1bae7a2d88a963650267ee4f 100644 (file)
@@ -104,6 +104,12 @@ type FreqWithNice struct {
        nice uint8
 }
 
+type ConnDeadlined interface {
+       io.ReadWriter
+       SetReadDeadline(t time.Time) error
+       SetWriteDeadline(t time.Time) error
+}
+
 func init() {
        var buf bytes.Buffer
        spHead := SPHead{Type: SPTypeHalt}
@@ -275,7 +281,7 @@ func (ctx *Ctx) infosOur(nodeId *NodeId, nice uint8, seen *map[[32]byte]uint8) [
 }
 
 func (ctx *Ctx) StartI(
-       conn net.Conn,
+       conn ConnDeadlined,
        nodeId *NodeId,
        nice uint8,
        xxOnly TRxTx,
@@ -384,7 +390,7 @@ func (ctx *Ctx) StartI(
        return &state, err
 }
 
-func (ctx *Ctx) StartR(conn net.Conn, nice uint8, xxOnly TRxTx) (*SPState, error) {
+func (ctx *Ctx) StartR(conn ConnDeadlined, nice uint8, xxOnly TRxTx) (*SPState, error) {
        started := time.Now()
        conf := noise.Config{
                CipherSuite: NoiseCipherSuite,
@@ -499,7 +505,7 @@ func (ctx *Ctx) StartR(conn net.Conn, nice uint8, xxOnly TRxTx) (*SPState, error
 }
 
 func (state *SPState) StartWorkers(
-       conn net.Conn,
+       conn ConnDeadlined,
        infosPayloads [][]byte,
        payload []byte) error {
        sds := SDS{"node": state.Node.Id, "nice": strconv.Itoa(int(state.nice))}
index 8ac0e0d97ce45cd83d1d7243c060cb8461dda5e9..a49355c7e3f8fe157a85be2f77e6e269a0f89602 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 8ac0e0d97ce45cd83d1d7243c060cb8461dda5e9
+Subproject commit a49355c7e3f8fe157a85be2f77e6e269a0f89602
index 1e491301e022f8f977054da4c2d852decd59571f..32a936f46389aa10549d60bd7833e54b01685d09 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 1e491301e022f8f977054da4c2d852decd59571f
+Subproject commit 32a936f46389aa10549d60bd7833e54b01685d09
index 9527bec2660bd847c050fda93a0f0c6dee0800bb..3c6ecd8f22c6f40fbeec94c000a069d7d87c7624 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 9527bec2660bd847c050fda93a0f0c6dee0800bb
+Subproject commit 3c6ecd8f22c6f40fbeec94c000a069d7d87c7624