diff --git a/contrib/backends/srndv2/src/srnd/spam.go b/contrib/backends/srndv2/src/srnd/spam.go index 2566250..7eac89e 100644 --- a/contrib/backends/srndv2/src/srnd/spam.go +++ b/contrib/backends/srndv2/src/srnd/spam.go @@ -25,13 +25,13 @@ func (sp *SpamFilter) Configure(c SpamConfig) { sp.addr = c.addr } -func (sp *SpamFilter) Enabled() bool { - return sp.enabled +func (sp *SpamFilter) Enabled(newsgroup string) bool { + return sp.enabled && newsgroup != "ctl" } -func (sp *SpamFilter) Rewrite(msg io.Reader, out io.WriteCloser) error { +func (sp *SpamFilter) Rewrite(msg io.Reader, out io.WriteCloser, group string) error { var buff [65636]byte - if !sp.Enabled() { + if !sp.Enabled(group) { return ErrSpamFilterNotEnabled } addr, err := net.ResolveTCPAddr("tcp", sp.addr) diff --git a/contrib/backends/srndv2/src/srnd/store.go b/contrib/backends/srndv2/src/srnd/store.go index bb83454..ac78431 100644 --- a/contrib/backends/srndv2/src/srnd/store.go +++ b/contrib/backends/srndv2/src/srnd/store.go @@ -65,7 +65,7 @@ type ArticleStore interface { // process nntp message, register attachments and the article // write the body into writer as we go through the message // writes mime body and does any spam rewrite - ProcessMessage(wr io.Writer, msg io.Reader, filter func(string) bool) error + ProcessMessage(wr io.Writer, msg io.Reader, filter func(string) bool, group string) error // register this post with the daemon RegisterPost(nntp NNTPMessage) error // register signed message @@ -441,7 +441,7 @@ func (self *articleStore) getMIMEHeader(messageID string) (hdr textproto.MIMEHea return hdr } -func (self *articleStore) ProcessMessage(wr io.Writer, msg io.Reader, spamfilter func(string) bool) (err error) { +func (self *articleStore) ProcessMessage(wr io.Writer, msg io.Reader, spamfilter func(string) bool, group string) (err error) { process := func(nntp NNTPMessage) { if !spamfilter(nntp.Message()) { err = errors.New("spam message") @@ -462,12 +462,12 @@ func (self *articleStore) ProcessMessage(wr io.Writer, msg io.Reader, spamfilter log.Println("error procesing message body", err) } } - if self.spamd.Enabled() { + if self.spamd.Enabled(group) { 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) + e := self.spamd.Rewrite(pr_in, pw_out, group) ec <- e }() go func() { diff --git a/contrib/backends/srndv2/src/srnd/util.go b/contrib/backends/srndv2/src/srnd/util.go index 5b9037d..9bf9925 100644 --- a/contrib/backends/srndv2/src/srnd/util.go +++ b/contrib/backends/srndv2/src/srnd/util.go @@ -769,7 +769,7 @@ func storeMessage(daemon *NNTPDaemon, hdr textproto.MIMEHeader, body io.Reader) io.CopyBuffer(pw, body, buff[:]) pw.Close() }() - err = daemon.store.ProcessMessage(f, pr, daemon.CheckText) + err = daemon.store.ProcessMessage(f, pr, daemon.CheckText, hdr.Get("Newsgroups")) pr.Close() if err == nil { // tell daemon