Skip to content

Commit

Permalink
Support connecting to rspamd via unix socket (#21)
Browse files Browse the repository at this point in the history
* Support connecting to rspamd via unix socket
  • Loading branch information
pjeby authored Mar 9, 2020
1 parent 57fa57f commit 66e8d01
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.1.6 - 2020-02-29

- Allow connecting to rspamd via unix sockets

## 1.1.5 - 2019-04-01

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ rspamd.ini

Port Rspamd is listening on.

- unix_socket

Path to a unix socket to connect to. If set, overrides host and port.

- add\_headers

Default: sometimes
Expand Down
1 change: 1 addition & 0 deletions config/rspamd.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
;host = localhost
;port = 11333
;unix_socket = /path/to/your/rspamd-client.sock
;add_headers = sometimes

[dkim]
Expand Down
10 changes: 8 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,18 @@ exports.get_options = function (connection) {
// https://github.com/vstakhov/rspamd/blob/master/rules/http_headers.lua
const options = {
headers: {},
port: plugin.cfg.main.port,
host: plugin.cfg.main.host,
path: '/checkv2',
method: 'POST',
};

if (plugin.cfg.main.unix_socket) {
options.socketPath = plugin.cfg.main.unix_socket;
}
else {
options.port = plugin.cfg.main.port;
options.host = plugin.cfg.main.host;
}

if (connection.notes.auth_user) {
options.headers.User = connection.notes.auth_user;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "haraka-plugin-rspamd",
"version": "1.1.5",
"version": "1.1.6",
"description": "Haraka plugin for rspamd",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 66e8d01

Please sign in to comment.