Skip to content

Commit ae8678f

Browse files
committed
allow providing alternate url
1 parent 4eb6783 commit ae8678f

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,13 @@ filter "rspamd" proc-exec "/usr/local/bin/filter-rspamd"
4545
listen on all filter "rspamd"
4646
```
4747

48+
A remote rspamd instance can be specified by providing the -url parameter to the filter:
49+
```
50+
filter "rspamd" proc-exec "/usr/local/bin/filter-rspamd -url http://rspamd.poolp.org:11333"
51+
52+
listen on all filter "rspamd"
53+
```
54+
55+
4856
Any configuration with regard to thresholds or enabled modules must be done in rspamd itself.
4957

filter-rspamd.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package main
1818

1919
import (
2020
"bufio"
21+
"flag"
2122
"fmt"
2223
"os"
2324
"strings"
@@ -27,6 +28,8 @@ import (
2728
"encoding/json"
2829
)
2930

31+
var rspamdURL *string
32+
3033
type session struct {
3134
id string
3235

@@ -211,7 +214,7 @@ func flushMessage(s session, token string) {
211214
func rspamdQuery(s session, token string) {
212215
r := strings.NewReader(strings.Join(s.message, "\n"))
213216
client := &http.Client{}
214-
req, err := http.NewRequest("POST", "http://localhost:11333/checkv2", r)
217+
req, err := http.NewRequest("POST", fmt.Sprintf("%s/checkv2", *rspamdURL), r)
215218
if err != nil {
216219
flushMessage(s, token)
217220
return
@@ -323,6 +326,9 @@ func skipConfig(scanner *bufio.Scanner) {
323326
}
324327

325328
func main() {
329+
rspamdURL = flag.String("url", "http://localhost:11333", "rspamd base url")
330+
flag.Parse()
331+
326332
scanner := bufio.NewScanner(os.Stdin)
327333

328334
skipConfig(scanner)

0 commit comments

Comments
 (0)