From: Sergey Matveev Date: Thu, 7 Jan 2021 14:23:18 +0000 (+0300) Subject: Autotoss ability X-Git-Tag: v5.5.0^2 X-Git-Url: http://www.git.cypherpunks.ru/?p=nncp.git;a=commitdiff_plain;h=1aebea616a9218d0bc8b4fffa10aa2f49c8d071b Autotoss ability --- diff --git a/doc/cmds.texi b/doc/cmds.texi index ab06f7a..575807a 100644 --- a/doc/cmds.texi +++ b/doc/cmds.texi @@ -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 diff --git a/doc/news.ru.texi b/doc/news.ru.texi index 10c3f51..d06a15a 100644 --- a/doc/news.ru.texi +++ b/doc/news.ru.texi @@ -17,6 +17,10 @@ @option{-nocompress} опции. Несжатые пакеты не совместимы с предыдущими версиями NNCP. +@item +У команд @command{nncp-call}, @command{nncp-caller} и @command{nncp-daemon} +появились @option{-autotoss*} опции для запуска tosser после завершения звонка. + @item Обновлены зависимые библиотеки. diff --git a/doc/news.texi b/doc/news.texi index cb232e4..ff9a47f 100644 --- a/doc/news.texi +++ b/doc/news.texi @@ -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. diff --git a/src/cmd/nncp-call/main.go b/src/cmd/nncp-call/main.go index 1b4c234..52e0fcb 100644 --- a/src/cmd/nncp-call/main.go +++ b/src/cmd/nncp-call/main.go @@ -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) } } diff --git a/src/cmd/nncp-caller/main.go b/src/cmd/nncp-caller/main.go index 7ab7e42..421f0fa 100644 --- a/src/cmd/nncp-caller/main.go +++ b/src/cmd/nncp-caller/main.go @@ -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() diff --git a/src/cmd/nncp-daemon/main.go b/src/cmd/nncp-daemon/main.go index 7e40deb..b7aceb7 100644 --- a/src/cmd/nncp-daemon/main.go +++ b/src/cmd/nncp-daemon/main.go @@ -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) } } diff --git a/src/cmd/nncp-toss/main.go b/src/cmd/nncp-toss/main.go index 0722c5e..b26da3e 100644 --- a/src/cmd/nncp-toss/main.go +++ b/src/cmd/nncp-toss/main.go @@ -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")