From d2d8534d4121467ba132f8682cdf66f9907630e9 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Sun, 17 Jan 2021 19:49:01 +0300 Subject: [PATCH] Autotoss call options --- doc/call.texi | 8 ++++++++ doc/news.ru.texi | 7 +++++++ doc/news.texi | 7 +++++++ src/call.go | 7 +++++++ src/cfg.go | 41 +++++++++++++++++++++++++++++-------- src/cmd/nncp-caller/main.go | 21 +++++++------------ src/cmd/nncp-cfgnew/main.go | 7 +++++++ 7 files changed, 76 insertions(+), 22 deletions(-) diff --git a/doc/call.texi b/doc/call.texi index 447b764..ac24b2a 100644 --- a/doc/call.texi +++ b/doc/call.texi @@ -11,6 +11,9 @@ calls: [ cron: "*/1 * * * MON-FRI" onlinedeadline: 3600 nice: PRIORITY+10 + + autotoss: true + autotoss-doseen: true }, { cron: "30 * * * SAT,SUN" @@ -185,4 +188,9 @@ configuration option when calling. Optional. Override @ref{CfgMaxOnlineTime, @emph{maxonlinetime}} configuration option when calling. +@item autotoss, -doseen, -nofile, -nofreq, -noexec, -notrns +Optionally enable auto tossing: run tosser on node's spool every second +during the call. You can control either are @file{.seen} files must be +created, or skip any kind of packet processing. + @end table diff --git a/doc/news.ru.texi b/doc/news.ru.texi index 9edf2aa..d2c0479 100644 --- a/doc/news.ru.texi +++ b/doc/news.ru.texi @@ -9,6 +9,13 @@ @option{-autotoss*} опции запускают tosser не после завершения вызова, а во время него ежесекундно. +@item +В @option{calls} секции конфигурации появились опции +@option{autotoss}, @option{autotoss-doseen}, +@option{autotoss-nofile}, @option{autotoss-nofreq}, +@option{autotoss-noexec}, @option{autotoss-notrns}. +Вы можете настраивать опции автоматического tosser для каждого вызова. + @end itemize @node Релиз 5.5.1 diff --git a/doc/news.texi b/doc/news.texi index 624143d..1b701a9 100644 --- a/doc/news.texi +++ b/doc/news.texi @@ -11,6 +11,13 @@ See also this page @ref{Новости, on russian}. @option{-autotoss*} option runs tosser not after the call, but every second while it is active. +@item +@option{autotoss}, @option{autotoss-doseen}, +@option{autotoss-nofile}, @option{autotoss-nofreq}, +@option{autotoss-noexec}, @option{autotoss-notrns} options available in +@option{calls} configuration section. You can configure per-call +automatic tosser options. + @end itemize @node Release 5.5.1 diff --git a/src/call.go b/src/call.go index f859167..87fb5ae 100644 --- a/src/call.go +++ b/src/call.go @@ -33,6 +33,13 @@ type Call struct { Addr *string OnlineDeadline time.Duration MaxOnlineTime time.Duration + + AutoToss bool + AutoTossDoSeen bool + AutoTossNoFile bool + AutoTossNoFreq bool + AutoTossNoExec bool + AutoTossNoTrns bool } func (ctx *Ctx) CallNode( diff --git a/src/cfg.go b/src/cfg.go index 50ad498..a72d371 100644 --- a/src/cfg.go +++ b/src/cfg.go @@ -81,6 +81,13 @@ type CallJSON struct { Addr *string `json:"addr,omitempty"` OnlineDeadline *uint `json:"onlinedeadline,omitempty"` MaxOnlineTime *uint `json:"maxonlinetime,omitempty"` + + AutoToss *bool `json:"autotoss,omitempty"` + AutoTossDoSeen *bool `json:"autotoss-doseen,omitempty"` + AutoTossNoFile *bool `json:"autotoss-nofile,omitempty"` + AutoTossNoFreq *bool `json:"autotoss-nofreq,omitempty"` + AutoTossNoExec *bool `json:"autotoss-noexec,omitempty"` + AutoTossNoTrns *bool `json:"autotoss-notrns,omitempty"` } type NodeOurJSON struct { @@ -260,12 +267,7 @@ func NewNode(name string, cfg NodeJSON) (*Node, error) { onlineDeadline = time.Duration(*callCfg.OnlineDeadline) * time.Second } - var maxOnlineTime time.Duration - if callCfg.MaxOnlineTime != nil { - maxOnlineTime = time.Duration(*callCfg.MaxOnlineTime) * time.Second - } - - calls = append(calls, &Call{ + call := Call{ Cron: expr, Nice: nice, Xx: xx, @@ -273,8 +275,31 @@ func NewNode(name string, cfg NodeJSON) (*Node, error) { TxRate: txRate, Addr: addr, OnlineDeadline: onlineDeadline, - MaxOnlineTime: maxOnlineTime, - }) + } + + if callCfg.MaxOnlineTime != nil { + call.MaxOnlineTime = time.Duration(*callCfg.MaxOnlineTime) * time.Second + } + if callCfg.AutoToss != nil { + call.AutoToss = *callCfg.AutoToss + } + if callCfg.AutoTossDoSeen != nil { + call.AutoTossDoSeen = *callCfg.AutoTossDoSeen + } + if callCfg.AutoTossNoFile != nil { + call.AutoTossNoFile = *callCfg.AutoTossNoFile + } + if callCfg.AutoTossNoFreq != nil { + call.AutoTossNoFreq = *callCfg.AutoTossNoFreq + } + if callCfg.AutoTossNoExec != nil { + call.AutoTossNoExec = *callCfg.AutoTossNoExec + } + if callCfg.AutoTossNoTrns != nil { + call.AutoTossNoTrns = *callCfg.AutoTossNoTrns + } + + calls = append(calls, &call) } node := Node{ diff --git a/src/cmd/nncp-caller/main.go b/src/cmd/nncp-caller/main.go index 0a549e4..826033c 100644 --- a/src/cmd/nncp-caller/main.go +++ b/src/cmd/nncp-caller/main.go @@ -49,13 +49,6 @@ 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() @@ -143,15 +136,15 @@ func main() { var autoTossFinish chan struct{} var autoTossBadCode chan bool - if *autoToss { + if call.AutoToss { autoTossFinish, autoTossBadCode = ctx.AutoToss( node.Id, call.Nice, - *autoTossDoSeen, - *autoTossNoFile, - *autoTossNoFreq, - *autoTossNoExec, - *autoTossNoTrns, + call.AutoTossDoSeen, + call.AutoTossNoFile, + call.AutoTossNoFreq, + call.AutoTossNoExec, + call.AutoTossNoTrns, ) } @@ -168,7 +161,7 @@ func main() { nil, ) - if *autoToss { + if call.AutoToss { close(autoTossFinish) <-autoTossBadCode } diff --git a/src/cmd/nncp-cfgnew/main.go b/src/cmd/nncp-cfgnew/main.go index a1358ad..93f3749 100644 --- a/src/cmd/nncp-cfgnew/main.go +++ b/src/cmd/nncp-cfgnew/main.go @@ -210,6 +210,13 @@ func main() { # # txrate: 20 # # xx: rx # # addr: lan + # # + # # autotoss: false + # # autotoss-doseen: true + # # autotoss-nofile: true + # # autotoss-nofreq: true + # # autotoss-noexec: true + # # autotoss-notrns: true # # }, # # ] # } -- 2.44.0