Skip to content

Commit

Permalink
Merge pull request #36 from mneumann/feature/add-settings-id
Browse files Browse the repository at this point in the history
Add cmdline option for rspamd Settings-ID HTTP header
  • Loading branch information
poolpOrg authored Nov 30, 2020
2 parents 95d4037 + 1cfe989 commit 0f0aeab
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,34 @@ filter "rspamd" proc-exec "filter-rspamd -url http://example.org:11333"
listen on all filter "rspamd"
```

Optionally a `-settings-id` parameter can be used to select a specific rspamd
setting. One usecase is for example to apply different rspamd rules to incoming
and outgoing emails:

```
filter "rspamd-incoming" proc-exec "filter-rspamd"
filter "rspamd-outgoing" proc-exec "filter-rspamd -settings-id outgoing"
listen on all filter "rspamd-incoming"
listen on all port submission filter "rspamd-outgoing"
```

And in `rspamd/local.d/settings.conf`:

```
outgoing {
id = "outgoing";
apply {
enable_groups = ["dkim"];
actions {
reject = 100.0;
greylist = 100.0;
"add header" = 100.0;
}
}
}
```

Every email passed through the `rspamd-outgoing` filter will use the rspamd `outgoing` rule instead of the default rule.

Any configuration with regard to thresholds or enabled modules must be done in rspamd itself.
7 changes: 7 additions & 0 deletions filter-rspamd.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
)

var rspamdURL *string
var rspamdSettingsId *string
var version string

var outputChannel chan string
Expand Down Expand Up @@ -338,6 +339,10 @@ func rspamdQuery(s *session, token string) {
req.Header.Add("Queue-Id", s.tx.msgid)
req.Header.Add("From", s.tx.mailFrom)

if *rspamdSettingsId != "" {
req.Header.Add("Settings-ID", *rspamdSettingsId)
}

if s.userName != "" {
req.Header.Add("User", s.userName)
}
Expand Down Expand Up @@ -552,6 +557,8 @@ func skipConfig(scanner *bufio.Scanner) {

func main() {
rspamdURL = flag.String("url", "http://localhost:11333", "rspamd base url")
rspamdSettingsId = flag.String("settings-id", "", "rspamd Settings-ID")

flag.Parse()

PledgePromises("stdio rpath inet dns unveil")
Expand Down

0 comments on commit 0f0aeab

Please sign in to comment.