]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/toss.go
nncp-exec -nocompress/-use-tmp options
[nncp.git] / src / toss.go
index ecc60ed2efacc4e89c9123a7d247912aab4f8cfc..f70ffd3dd7674051af5cc74c5a7d5b0a8061ce3e 100644 (file)
@@ -126,7 +126,7 @@ func (ctx *Ctx) Toss(
                sds["size"] = pktSize
                ctx.LogD("rx", sds, "taken")
                switch pkt.Type {
-               case PktTypeExec:
+               case PktTypeExec, PktTypeExecFat:
                        if noExec {
                                goto Closing
                        }
@@ -148,8 +148,10 @@ func (ctx *Ctx) Toss(
                                isBad = true
                                goto Closing
                        }
-                       if err = decompressor.Reset(pipeR); err != nil {
-                               log.Fatalln(err)
+                       if pkt.Type == PktTypeExec {
+                               if err = decompressor.Reset(pipeR); err != nil {
+                                       log.Fatalln(err)
+                               }
                        }
                        if !dryRun {
                                cmd := exec.Command(
@@ -162,7 +164,11 @@ func (ctx *Ctx) Toss(
                                        "NNCP_SENDER="+sender.Id.String(),
                                        "NNCP_NICE="+strconv.Itoa(int(pkt.Nice)),
                                )
-                               cmd.Stdin = decompressor
+                               if pkt.Type == PktTypeExec {
+                                       cmd.Stdin = decompressor
+                               } else {
+                                       cmd.Stdin = pipeR
+                               }
                                output, err := cmd.Output()
                                if err != nil {
                                        ctx.LogE("rx", sds, err, "handle")