]> Cypherpunks.ru repositories - nncp.git/commitdiff
Autotoss ability
authorSergey Matveev <stargrave@stargrave.org>
Thu, 7 Jan 2021 14:23:18 +0000 (17:23 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Thu, 7 Jan 2021 14:28:12 +0000 (17:28 +0300)
doc/cmds.texi
doc/news.ru.texi
doc/news.texi
src/cmd/nncp-call/main.go
src/cmd/nncp-caller/main.go
src/cmd/nncp-daemon/main.go
src/cmd/nncp-toss/main.go

index ab06f7a37c2bdcc7c1cd333e361b85dd1e0a5270..575807af676e230feda3fd1de28c02383f9088d3 100644 (file)
@@ -101,6 +101,7 @@ $ nncp-call [options]
     [-pkts PKT,PKT,...]
     [-rxrate INT]
     [-txrate INT]
+    [-autotoss*]
     NODE[:ADDR] [FORCEADDR]
 @end example
 
@@ -138,6 +139,10 @@ file is renamed from @file{.part} one and when you rerun
 @command{nncp-call} again, remote node will receive completion
 notification.
 
+@option{-autotoss} options runs tosser on node's spool after call
+is finished. All @option{-autotoss-*} options is the same as in
+@ref{nncp-toss} command.
+
 @node nncp-caller
 @section nncp-caller
 
@@ -237,7 +242,7 @@ not used often in practice, if ever.
 @section nncp-daemon
 
 @example
-$ nncp-daemon [options] [-maxconn INT] [-bind ADDR] [-inetd]
+$ nncp-daemon [options] [-maxconn INT] [-bind ADDR] [-inetd] [-autotoss*]
 @end example
 
 Start listening TCP daemon, wait for incoming connections and run
@@ -258,6 +263,10 @@ propagate up to 5 minutes in practice. Example inetd-entry:
 uucp   stream  tcp6    nowait  nncpuser        /usr/local/bin/nncp-daemon      nncp-daemon -quiet -inetd
 @end verbatim
 
+@option{-autotoss} options runs tosser on node's spool after call
+is finished. All @option{-autotoss-*} options is the same as in
+@ref{nncp-toss} command.
+
 @node nncp-exec
 @section nncp-exec
 
index 10c3f51db4874622202d12faf7384739f4c43e85..d06a15ae882a52e5406312662cec2bb7d1188778 100644 (file)
 @option{-nocompress} опции. Несжатые пакеты не совместимы с предыдущими
 версиями NNCP.
 
+@item
+У команд @command{nncp-call}, @command{nncp-caller} и @command{nncp-daemon}
+появились @option{-autotoss*} опции для запуска tosser после завершения звонка.
+
 @item
 Обновлены зависимые библиотеки.
 
index cb232e4ff7f4a0b8963e52a8a4dacf72be8cbe97..ff9a47fc28ac88173e9fb6698f85758f340ac2fe 100644 (file)
@@ -19,6 +19,10 @@ Bugfixes in @command{nncp-call(er)}/@command{nncp-daemon},
 options now. Uncompressed packets are not compatible with previous NNCP
 versions.
 
+@item
+@command{nncp-call}, @command{nncp-caller} and @command{nncp-daemon} commands
+have @option{-autotoss*} options for running tosser after call is ended.
+
 @item
 Updated dependencies.
 
index 1b4c2347338ee9613f4f5c86e5acb4590e06a6fe..52e0fcb2887dd8a247d7e057ed20ca30463b0c8a 100644 (file)
@@ -58,6 +58,13 @@ func main() {
 
                onlineDeadlineSec = flag.Uint("onlinedeadline", 0, "Override onlinedeadline option")
                maxOnlineTimeSec  = flag.Uint("maxonlinetime", 0, "Override maxonlinetime option")
+
+               autotoss       = flag.Bool("autotoss", false, "Toss after call is finished")
+               autotossDoSeen = flag.Bool("autotoss-seen", false, "Create .seen files during tossing")
+               autotossNoFile = flag.Bool("autotoss-nofile", false, "Do not process \"file\" packets during tossing")
+               autotossNoFreq = flag.Bool("autotoss-nofreq", false, "Do not process \"freq\" packets during tossing")
+               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")
        )
        flag.Usage = usage
        flag.Parse()
@@ -153,7 +160,7 @@ func main() {
        }
 
        ctx.Umask()
-       if !ctx.CallNode(
+       badCode := !ctx.CallNode(
                node,
                addrs,
                nice,
@@ -164,7 +171,20 @@ func main() {
                maxOnlineTime,
                *listOnly,
                onlyPkts,
-       ) {
+       )
+       if *autotoss {
+               badCode = ctx.Toss(
+                       node.Id,
+                       nice,
+                       false,
+                       *autotossDoSeen,
+                       *autotossNoFile,
+                       *autotossNoFreq,
+                       *autotossNoExec,
+                       *autotossNoTrns,
+               ) || badCode
+       }
+       if badCode {
                os.Exit(1)
        }
 }
index 7ab7e4231c73271955de9259fc7d1e6a77c7ff73..421f0faa08d3593c94933dfb76f3b7776aa1584f 100644 (file)
@@ -49,6 +49,13 @@ func main() {
                debug     = flag.Bool("debug", false, "Print debug messages")
                version   = flag.Bool("version", false, "Print version information")
                warranty  = flag.Bool("warranty", false, "Print warranty information")
+
+               autotoss       = flag.Bool("autotoss", false, "Toss after call is finished")
+               autotossDoSeen = flag.Bool("autotoss-seen", false, "Create .seen files during tossing")
+               autotossNoFile = flag.Bool("autotoss-nofile", false, "Do not process \"file\" packets during tossing")
+               autotossNoFreq = flag.Bool("autotoss-nofreq", false, "Do not process \"freq\" packets during tossing")
+               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")
        )
        flag.Usage = usage
        flag.Parse()
@@ -145,6 +152,19 @@ func main() {
                                                        false,
                                                        nil,
                                                )
+                                               if *autotoss {
+                                                       ctx.Toss(
+                                                               node.Id,
+                                                               call.Nice,
+                                                               false,
+                                                               *autotossDoSeen,
+                                                               *autotossNoFile,
+                                                               *autotossNoFreq,
+                                                               *autotossNoExec,
+                                                               *autotossNoTrns,
+                                                       )
+                                               }
+
                                                node.Lock()
                                                node.Busy = false
                                                node.Unlock()
index 7e40deb3a2da33b8bc8ed045d4eda5886d8a9e04..b7aceb75e11f90eb1f99f26c7da7915c981739b8 100644 (file)
@@ -66,7 +66,7 @@ func (c InetdConn) Close() error {
        return c.w.Close()
 }
 
-func performSP(ctx *nncp.Ctx, conn nncp.ConnDeadlined, nice uint8) {
+func performSP(ctx *nncp.Ctx, conn nncp.ConnDeadlined, nice uint8) *nncp.SPState {
        state := nncp.SPState{
                Ctx:  ctx,
                Nice: nice,
@@ -89,6 +89,7 @@ func performSP(ctx *nncp.Ctx, conn nncp.ConnDeadlined, nice uint8) {
                }
                ctx.LogE("call-start", nncp.SDS{"node": nodeId}, err, "")
        }
+       return &state
 }
 
 func main() {
@@ -106,6 +107,13 @@ func main() {
                debug     = flag.Bool("debug", false, "Print debug messages")
                version   = flag.Bool("version", false, "Print version information")
                warranty  = flag.Bool("warranty", false, "Print warranty information")
+
+               autotoss       = flag.Bool("autotoss", false, "Toss after call is finished")
+               autotossDoSeen = flag.Bool("autotoss-seen", false, "Create .seen files during tossing")
+               autotossNoFile = flag.Bool("autotoss-nofile", false, "Do not process \"file\" packets during tossing")
+               autotossNoFreq = flag.Bool("autotoss-nofreq", false, "Do not process \"freq\" packets during tossing")
+               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")
        )
        flag.Usage = usage
        flag.Parse()
@@ -159,8 +167,20 @@ func main() {
                }
                ctx.LogD("daemon", nncp.SDS{"addr": conn.RemoteAddr()}, "accepted")
                go func(conn net.Conn) {
-                       performSP(ctx, conn, nice)
+                       state := performSP(ctx, conn, nice)
                        conn.Close() // #nosec G104
+                       if *autotoss && state.Node != nil {
+                               ctx.Toss(
+                                       state.Node.Id,
+                                       nice,
+                                       false,
+                                       *autotossDoSeen,
+                                       *autotossNoFile,
+                                       *autotossNoFreq,
+                                       *autotossNoExec,
+                                       *autotossNoTrns,
+                               )
+                       }
                }(conn)
        }
 }
index 0722c5ea0f702e0e9f15cfb4a8d4b76ddcd8b32a..b26da3e4ecdcac497bc98c6731c00581aefc48a2 100644 (file)
@@ -43,10 +43,10 @@ func main() {
                dryRun    = flag.Bool("dryrun", false, "Do not actually write any tossed data")
                doSeen    = flag.Bool("seen", false, "Create .seen files")
                cycle     = flag.Uint("cycle", 0, "Repeat tossing after N seconds in infinite loop")
-               noFile    = flag.Bool("nofile", false, "Do not process packets with type: file")
-               noFreq    = flag.Bool("nofreq", false, "Do not process packets with type: freq")
-               noExec    = flag.Bool("noexec", false, "Do not process packets with type: exec")
-               noTrns    = flag.Bool("notrns", false, "Do not process packets with type: transitional")
+               noFile    = flag.Bool("nofile", false, "Do not process \"file\" packets")
+               noFreq    = flag.Bool("nofreq", false, "Do not process \"freq\" packets")
+               noExec    = flag.Bool("noexec", false, "Do not process \"exec\" packets")
+               noTrns    = flag.Bool("notrns", false, "Do not process \"transitional\" packets")
                spoolPath = flag.String("spool", "", "Override path to spool")
                logPath   = flag.String("log", "", "Override path to logfile")
                quiet     = flag.Bool("quiet", false, "Print only errors")