X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcmd%2Fnncp-daemon%2Fmain.go;h=b7aceb75e11f90eb1f99f26c7da7915c981739b8;hb=1aebea616a9218d0bc8b4fffa10aa2f49c8d071b;hp=7e40deb3a2da33b8bc8ed045d4eda5886d8a9e04;hpb=3894bc10b3ac753b7048d83db0a3b5b5843b7232;p=nncp.git 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) } }