@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
+@option{-autotoss} option runs tosser on node's spool every second
+during the call. All @option{-autotoss-*} options is the same as in
@ref{nncp-toss} command.
@node nncp-caller
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
+@option{-autotoss} option runs tosser on node's spool every second
+during the call. All @option{-autotoss-*} options is the same as in
@ref{nncp-toss} command.
@node nncp-exec
@node Новости
@section Новости
+@node Релиз 5.6.0
+@subsection Релиз 5.6.0
+@itemize
+
+@item
+@option{-autotoss*} опции запускают tosser не после завершения вызова, а
+во время него ежесекундно.
+
+@end itemize
+
@node Релиз 5.5.1
@subsection Релиз 5.5.1
@itemize
See also this page @ref{Новости, on russian}.
+@node Release 5.6.0
+@section Release 5.6.0
+@itemize
+
+@item
+@option{-autotoss*} option runs tosser not after the call, but every
+second while it is active.
+
+@end itemize
+
@node Release 5.5.1
@section Release 5.5.1
@itemize
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")
+ 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()
}
ctx.Umask()
+
+ var autoTossFinish chan struct{}
+ var autoTossBadCode chan bool
+ if *autoToss {
+ autoTossFinish, autoTossBadCode = ctx.AutoToss(
+ node.Id,
+ nice,
+ *autoTossDoSeen,
+ *autoTossNoFile,
+ *autoTossNoFreq,
+ *autoTossNoExec,
+ *autoTossNoTrns,
+ )
+ }
+
badCode := !ctx.CallNode(
node,
addrs,
*listOnly,
onlyPkts,
)
- if *autotoss {
- badCode = ctx.Toss(
- node.Id,
- nice,
- false,
- *autotossDoSeen,
- *autotossNoFile,
- *autotossNoFreq,
- *autotossNoExec,
- *autotossNoTrns,
- ) || badCode
+
+ if *autoToss {
+ close(autoTossFinish)
+ badCode = (<-autoTossBadCode) || badCode
}
if badCode {
os.Exit(1)
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")
+ 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()
} else {
node.Busy = true
node.Unlock()
+
+ var autoTossFinish chan struct{}
+ var autoTossBadCode chan bool
+ if *autoToss {
+ autoTossFinish, autoTossBadCode = ctx.AutoToss(
+ node.Id,
+ call.Nice,
+ *autoTossDoSeen,
+ *autoTossNoFile,
+ *autoTossNoFreq,
+ *autoTossNoExec,
+ *autoTossNoTrns,
+ )
+ }
+
ctx.CallNode(
node,
addrs,
false,
nil,
)
- if *autotoss {
- ctx.Toss(
- node.Id,
- call.Nice,
- false,
- *autotossDoSeen,
- *autotossNoFile,
- *autotossNoFreq,
- *autotossNoExec,
- *autotossNoTrns,
- )
+
+ if *autoToss {
+ close(autoTossFinish)
+ <-autoTossBadCode
}
node.Lock()
return c.w.Close()
}
-func performSP(ctx *nncp.Ctx, conn nncp.ConnDeadlined, nice uint8) *nncp.SPState {
+func performSP(
+ ctx *nncp.Ctx,
+ conn nncp.ConnDeadlined,
+ nice uint8,
+ nodeIdC chan *nncp.NodeId,
+) {
state := nncp.SPState{
Ctx: ctx,
Nice: nice,
}
if err := state.StartR(conn); err == nil {
ctx.LogI("call-start", nncp.SDS{"node": state.Node.Id}, "connected")
+ nodeIdC <- state.Node.Id
state.Wait()
ctx.LogI("call-finish", nncp.SDS{
"node": state.Node.Id,
}, "")
} else {
nodeId := "unknown"
- if state.Node != nil {
+ if state.Node == nil {
+ nodeIdC <- nil
+ } else {
+ nodeIdC <- state.Node.Id
nodeId = state.Node.Id.String()
}
ctx.LogE("call-start", nncp.SDS{"node": nodeId}, err, "")
}
- return &state
+ close(nodeIdC)
}
func main() {
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")
+ 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()
if *inetd {
os.Stderr.Close() // #nosec G104
conn := &InetdConn{os.Stdin, os.Stdout}
- performSP(ctx, conn, nice)
+ nodeIdC := make(chan *nncp.NodeId)
+ go performSP(ctx, conn, nice, nodeIdC)
+ <-nodeIdC // nodeId
+ <-nodeIdC // call completion
conn.Close() // #nosec G104
return
}
}
ctx.LogD("daemon", nncp.SDS{"addr": conn.RemoteAddr()}, "accepted")
go func(conn net.Conn) {
- state := performSP(ctx, conn, nice)
- conn.Close() // #nosec G104
- if *autotoss && state.Node != nil {
- ctx.Toss(
- state.Node.Id,
+ nodeIdC := make(chan *nncp.NodeId)
+ go performSP(ctx, conn, nice, nodeIdC)
+ nodeId := <-nodeIdC
+ var autoTossFinish chan struct{}
+ var autoTossBadCode chan bool
+ if *autoToss && nodeId != nil {
+ autoTossFinish, autoTossBadCode = ctx.AutoToss(
+ nodeId,
nice,
- false,
- *autotossDoSeen,
- *autotossNoFile,
- *autotossNoFreq,
- *autotossNoExec,
- *autotossNoTrns,
+ *autoTossDoSeen,
+ *autoTossNoFile,
+ *autoTossNoFreq,
+ *autoTossNoExec,
+ *autoTossNoTrns,
)
}
+ <-nodeIdC // call completion
+ if *autoToss {
+ close(autoTossFinish)
+ <-autoTossBadCode
+ }
+ conn.Close() // #nosec G104
}(conn)
}
}
)
var (
- Version string = "5.5.1"
+ Version string = "5.6.0"
Base32Codec *base32.Encoding = base32.StdEncoding.WithPadding(base32.NoPadding)
)
"path/filepath"
"strconv"
"strings"
+ "time"
xdr "github.com/davecgh/go-xdr/xdr2"
"github.com/dustin/go-humanize"
}
return isBad
}
+
+func (ctx *Ctx) AutoToss(
+ nodeId *NodeId,
+ nice uint8,
+ doSeen, noFile, noFreq, noExec, noTrns bool,
+) (chan struct{}, chan bool) {
+ finish := make(chan struct{})
+ badCode := make(chan bool)
+ go func() {
+ bad := false
+ for {
+ select {
+ case <-finish:
+ badCode <- bad
+ break
+ default:
+ }
+ time.Sleep(time.Second)
+ bad = !ctx.Toss(nodeId, nice, false, doSeen, noFile, noFreq, noExec, noTrns)
+ }
+ }()
+ return finish, badCode
+}