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")
+ noMail = flag.Bool("nomail", false, "Do not process packets with type: mail")
+ noTrns = flag.Bool("notrns", false, "Do not process packets with type: transitional")
spoolPath = flag.String("spool", "", "Override path to spool")
logPath = flag.String("log", "", "Override path to logfile")
quiet = flag.Bool("quiet", false, "Print only errors")
if nodeOnly != nil && nodeId != *nodeOnly.Id {
continue
}
- isBad = ctx.Toss(node.Id, nice, *dryRun, *doSeen)
+ isBad = ctx.Toss(
+ node.Id,
+ nice,
+ *dryRun,
+ *doSeen,
+ *noFile,
+ *noFreq,
+ *noMail,
+ *noTrns,
+ )
}
if *cycle > 0 {
time.Sleep(time.Duration(*cycle) * time.Second)
))
}
-func (ctx *Ctx) Toss(nodeId *NodeId, nice uint8, dryRun, doSeen bool) bool {
+func (ctx *Ctx) Toss(nodeId *NodeId, nice uint8, dryRun, doSeen, noFile, noFreq, noMail, noTrns bool) bool {
isBad := false
for job := range ctx.Jobs(nodeId, TRx) {
pktName := filepath.Base(job.Fd.Name())
ctx.LogD("rx", sds, "taken")
switch pkt.Type {
case PktTypeMail:
+ if noMail {
+ goto Closing
+ }
recipients := make([]string, 0)
for _, recipient := range bytes.Split(pkt.Path[:int(pkt.PathLen)], []byte{0}) {
recipients = append(recipients, string(recipient))
}
}
case PktTypeFile:
+ if noFile {
+ goto Closing
+ }
dst := string(pkt.Path[:int(pkt.PathLen)])
sds := SdsAdd(sds, SDS{"type": "file", "dst": dst})
if filepath.IsAbs(dst) {
}
}
case PktTypeFreq:
+ if noFreq {
+ goto Closing
+ }
src := string(pkt.Path[:int(pkt.PathLen)])
if filepath.IsAbs(src) {
ctx.LogE("rx", sds, "non-relative source path")
}
}
case PktTypeTrns:
+ if noTrns {
+ goto Closing
+ }
dst := new([blake2b.Size256]byte)
copy(dst[:], pkt.Path[:int(pkt.PathLen)])
nodeId := NodeId(*dst)
if len(dirFiles(rxPath)) == 0 {
continue
}
- ctx.Toss(ctx.Self.Id, DefaultNiceMail-1, false, false)
+ ctx.Toss(ctx.Self.Id, DefaultNiceMail-1, false, false, false, false, false, false)
if len(dirFiles(rxPath)) == 0 {
return false
}
ctx.Neigh[*nodeOur.Id].Sendmail = []string{"/bin/sh", "-c", "false"}
- ctx.Toss(ctx.Self.Id, DefaultNiceMail, false, false)
+ ctx.Toss(ctx.Self.Id, DefaultNiceMail, false, false, false, false, false, false)
if len(dirFiles(rxPath)) == 0 {
return false
}
"/bin/sh", "-c",
fmt.Sprintf("cat >> %s", filepath.Join(spool, "mbox")),
}
- ctx.Toss(ctx.Self.Id, DefaultNiceMail, false, false)
+ ctx.Toss(ctx.Self.Id, DefaultNiceMail, false, false, false, false, false, false)
if len(dirFiles(rxPath)) != 0 {
return false
}
}
rxPath := filepath.Join(spool, ctx.Self.Id.String(), string(TRx))
os.Rename(filepath.Join(spool, ctx.Self.Id.String(), string(TTx)), rxPath)
- ctx.Toss(ctx.Self.Id, DefaultNiceFile, false, false)
+ ctx.Toss(ctx.Self.Id, DefaultNiceFile, false, false, false, false, false, false)
if len(dirFiles(rxPath)) == 0 {
return false
}
ctx.Neigh[*nodeOur.Id].Incoming = &incomingPath
- ctx.Toss(ctx.Self.Id, DefaultNiceFile, false, false)
+ ctx.Toss(ctx.Self.Id, DefaultNiceFile, false, false, false, false, false, false)
if len(dirFiles(rxPath)) != 0 {
return false
}
rxPath := filepath.Join(spool, ctx.Self.Id.String(), string(TRx))
os.Rename(filepath.Join(spool, ctx.Self.Id.String(), string(TTx)), rxPath)
ctx.Neigh[*nodeOur.Id].Incoming = &incomingPath
- ctx.Toss(ctx.Self.Id, DefaultNiceFile, false, false)
+ ctx.Toss(ctx.Self.Id, DefaultNiceFile, false, false, false, false, false, false)
expected := make(map[string]struct{})
expected["samefile"] = struct{}{}
for i := 0; i < files-1; i++ {
txPath := filepath.Join(spool, ctx.Self.Id.String(), string(TTx))
os.Rename(txPath, rxPath)
os.MkdirAll(txPath, os.FileMode(0700))
- ctx.Toss(ctx.Self.Id, DefaultNiceFreq, false, false)
+ ctx.Toss(ctx.Self.Id, DefaultNiceFreq, false, false, false, false, false, false)
if len(dirFiles(txPath)) != 0 || len(dirFiles(rxPath)) == 0 {
return false
}
ctx.Neigh[*nodeOur.Id].Freq = &spool
- ctx.Toss(ctx.Self.Id, DefaultNiceFreq, false, false)
+ ctx.Toss(ctx.Self.Id, DefaultNiceFreq, false, false, false, false, false, false)
if len(dirFiles(txPath)) != 0 || len(dirFiles(rxPath)) == 0 {
return false
}
panic(err)
}
}
- ctx.Toss(ctx.Self.Id, DefaultNiceFreq, false, false)
+ ctx.Toss(ctx.Self.Id, DefaultNiceFreq, false, false, false, false, false, false)
if len(dirFiles(txPath)) == 0 || len(dirFiles(rxPath)) != 0 {
return false
}
panic(err)
}
}
- ctx.Toss(ctx.Self.Id, 123, false, false)
+ ctx.Toss(ctx.Self.Id, 123, false, false, false, false, false, false)
if len(dirFiles(rxPath)) != 0 {
return false
}