diff --git a/contrib/backends/srndv2/src/srnd/spam.go b/contrib/backends/srndv2/src/srnd/spam.go index 1e072c7..2566250 100644 --- a/contrib/backends/srndv2/src/srnd/spam.go +++ b/contrib/backends/srndv2/src/srnd/spam.go @@ -13,6 +13,7 @@ import ( var ErrSpamFilterNotEnabled = errors.New("spam filter access attempted when disabled") var ErrSpamFilterFailed = errors.New("spam filter failed") +var ErrMessageIsSpam = errors.New("message is spam") type SpamFilter struct { addr string @@ -55,6 +56,9 @@ func (sp *SpamFilter) Rewrite(msg io.Reader, out io.WriteCloser) error { return err } l = strings.TrimSpace(l) + if strings.HasPrefix(l, "Spam: True ") { + return ErrMessageIsSpam + } log.Println("SpamFilter:", l) if l == "" { _, err = io.CopyBuffer(out, r, buff[:]) diff --git a/contrib/backends/srndv2/src/srnd/store.go b/contrib/backends/srndv2/src/srnd/store.go index c761d8a..9e0a140 100644 --- a/contrib/backends/srndv2/src/srnd/store.go +++ b/contrib/backends/srndv2/src/srnd/store.go @@ -465,11 +465,9 @@ func (self *articleStore) ProcessMessage(wr io.Writer, msg io.Reader, spamfilter if self.spamd.Enabled() { pr_in, pw_in := io.Pipe() pr_out, pw_out := io.Pipe() + ec := make(chan error) go func() { - e := self.spamd.Rewrite(pr_in, pw_out) - if e != nil { - log.Println("failed to check spam", e) - } + ec <- self.spamd.Rewrite(pr_in, pw_out) }() go func() { var buff [65536]byte @@ -491,6 +489,10 @@ func (self *articleStore) ProcessMessage(wr io.Writer, msg io.Reader, spamfilter } writeMIMEHeader(wr, m.Header) read_message_body(m.Body, m.Header, self, wr, false, process) + er := <-ec + if er != nil { + return er + } } else { r := bufio.NewReader(msg) m, e := readMIMEHeader(r)