Skip to content

Commit 0f0aeab

Browse files
authored
Merge pull request #36 from mneumann/feature/add-settings-id
Add cmdline option for rspamd Settings-ID HTTP header
2 parents 95d4037 + 1cfe989 commit 0f0aeab

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,34 @@ filter "rspamd" proc-exec "filter-rspamd -url http://example.org:11333"
6868
listen on all filter "rspamd"
6969
```
7070

71+
Optionally a `-settings-id` parameter can be used to select a specific rspamd
72+
setting. One usecase is for example to apply different rspamd rules to incoming
73+
and outgoing emails:
74+
75+
```
76+
filter "rspamd-incoming" proc-exec "filter-rspamd"
77+
filter "rspamd-outgoing" proc-exec "filter-rspamd -settings-id outgoing"
78+
79+
listen on all filter "rspamd-incoming"
80+
listen on all port submission filter "rspamd-outgoing"
81+
```
82+
83+
And in `rspamd/local.d/settings.conf`:
84+
85+
```
86+
outgoing {
87+
id = "outgoing";
88+
apply {
89+
enable_groups = ["dkim"];
90+
actions {
91+
reject = 100.0;
92+
greylist = 100.0;
93+
"add header" = 100.0;
94+
}
95+
}
96+
}
97+
```
98+
99+
Every email passed through the `rspamd-outgoing` filter will use the rspamd `outgoing` rule instead of the default rule.
71100

72101
Any configuration with regard to thresholds or enabled modules must be done in rspamd itself.

filter-rspamd.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
)
3131

3232
var rspamdURL *string
33+
var rspamdSettingsId *string
3334
var version string
3435

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

342+
if *rspamdSettingsId != "" {
343+
req.Header.Add("Settings-ID", *rspamdSettingsId)
344+
}
345+
341346
if s.userName != "" {
342347
req.Header.Add("User", s.userName)
343348
}
@@ -552,6 +557,8 @@ func skipConfig(scanner *bufio.Scanner) {
552557

553558
func main() {
554559
rspamdURL = flag.String("url", "http://localhost:11333", "rspamd base url")
560+
rspamdSettingsId = flag.String("settings-id", "", "rspamd Settings-ID")
561+
555562
flag.Parse()
556563

557564
PledgePromises("stdio rpath inet dns unveil")

0 commit comments

Comments
 (0)