diff options
author | Larry Hynes <larry@larryhynes.com> | 2016-06-09 21:08:09 +0100 |
---|---|---|
committer | Larry Hynes <larry@larryhynes.com> | 2016-06-09 21:08:09 +0100 |
commit | 204034dd45454882385b54077712b38ec663bfe6 (patch) | |
tree | 3360e8c8f7667d7331f0261b9db6b365919a44c8 /doc | |
parent | 9fb162704d186ca35b66cef49a57a5088e74c5e4 (diff) | |
download | rspamd-204034dd45454882385b54077712b38ec663bfe6.tar.gz rspamd-204034dd45454882385b54077712b38ec663bfe6.zip |
[Doc] Correct doc/markdown/architecture/protocol.md
Diffstat (limited to 'doc')
-rw-r--r-- | doc/markdown/architecture/protocol.md | 110 |
1 files changed, 54 insertions, 56 deletions
diff --git a/doc/markdown/architecture/protocol.md b/doc/markdown/architecture/protocol.md index 51ac8e9c6..75a512718 100644 --- a/doc/markdown/architecture/protocol.md +++ b/doc/markdown/architecture/protocol.md @@ -1,15 +1,12 @@ -# Rspamd protocol +# rspamd protocol ## Protocol basics -Rspamd uses HTTP protocol of either version 1.0 or 1.1. However, there is compatibility layer described further in this document. -Rspamd defines some servicing headers that allows to pass extra information about a message scanned, such as envelope data, IP address, -SMTP sasl authentication data and so on. Rspamd supports both normal and chunked encoded HTTP request, however, form URL encoding is **NOT** supported currently. +rspamd uses the HTTP protocol, either version 1.0 or 1.1. (There is also a compatibility layer described further in this document.) rspamd defines some headers which allow the passing of extra information about a scanned message, such as envelope data, IP address or SMTP sasl authentication data, etc. rspamd supports normal and chunked encoded HTTP requests; however, form URL encoding is **NOT** supported currently. -## Rspamd HTTP request +## rspamd HTTP request -Rspamd encourages usage of HTTP protocol since it is standard and can be used by literally every programming language without exotic libraries. -The typical HTTP request looks like the following: +rspamd encourages the use of the HTTP protocol since it is standard and can be used by every programming language without the use of exotic libraries. A typical HTTP request looks like the following: POST /check HTTP/1.0 Content-Length: 26969 @@ -21,32 +18,31 @@ The typical HTTP request looks like the following: <your message goes here> -You can also use chunked encoding that allows streamlined data transfer which is useful if you don't know the length of the message. +You can also use chunked encoding that allows streamlined data transfer which is useful if you don't know the length of a message. ### HTTP request -Normally, you should just use '/check' here. However, if you talk to the controller then you might want to use controllers commands here. +Normally, you should just use '/check' here. However, if you want to communicate with the controller then you might want to use controllers commands. (TODO: write this part) ### HTTP headers -To avoid unnecessary work, rspamd allows MTA to pass pre-processed data about the message by using either HTTP headers or JSON control block (described further in this document). -Rspamd supports the following non-standard HTTP headers: +To avoid unnecessary work, rspamd allows an MTA to pass pre-processed data about the message by using either HTTP headers or a JSON control block (described further in this document). rspamd supports the following non-standard HTTP headers: | Header | Description | -| :-------------- | :-------------------------------- | -| **Deliver-To:** | Defines actual delivery recipient of message. Can be used for personalized statistic and for user specific options.| -| **IP:** | Defines IP from which this message is received. | -| **Helo:** | Defines SMTP helo. | -| **Hostname:** | Defines resolved hostname. | -| **From:** | Defines SMTP mail from command data. | -| **Queue-Id:** | Defines SMTP queue id for message (can be used instead of message id in logging). | -| **Rcpt:** | Defines SMTP recipient (it may be several `Rcpt` headers). | -| **Pass:** | If this header has `all` value, all filters would be checked for this message. | -| **Subject:** | Defines subject of message (is used for non-mime messages). | +| :-------------- | :-------------------------------- | +| **Deliver-To:** | Defines actual delivery recipient of message. Can be used for personalized statistics and for user specific options. | +| **IP:** | Defines IP from which this message is received. | +| **Helo:** | Defines SMTP | +| **Hostname:** | Defines resolved | +| **From:** | Defines SMTP mail from command | +| **Queue-Id:** | Defines SMTP queue id for message (can be used instead of message id in logging). | +| **Rcpt:** | Defines SMTP recipient (it may be several `Rcpt` | +| **Pass:** | If this header has `all` value, all filters would be checked for this message. | +| **Subject:** | Defines subject of message (is used for non-mime messages). | | **User:** | Defines SMTP user. | -| **Message-Length:** | Defines the length of message excluding the control block. | +| **Message-Length:** | Defines the length of message excluding the control block. | Controller also defines certain headers: @@ -54,9 +50,9 @@ Controller also defines certain headers: Standard HTTP headers, such as `Content-Length`, are also supported. -## Rspamd HTTP reply +## rspamd HTTP reply -Rspamd reply is encoded using `json` format. Here is a typical HTTP reply: +rspamd reply is encoded in `JSON`. Here is a typical HTTP reply: HTTP/1.1 200 OK Connection: close @@ -111,7 +107,7 @@ Rspamd reply is encoded using `json` format. Here is a typical HTTP reply: For convenience, the reply is LINTed using [jsonlint](http://jsonlint.com). The actual reply is compressed for speed. -The reply can be treated as the JSON object where keys are metric names (namely `default`) and values are objects that represent metric. +The reply can be treated as a JSON object where keys are metric names (namely `default`) and values are objects that represent metrics. Each metric has the following fields: @@ -124,27 +120,26 @@ Each metric has the following fields: - `greylist` - message should be greylisted; - `add header` - message is suspicious and should be marked as spam - `rewrite subject` - message is suspicious and should have subject rewritten - - `soft reject` - message should be temporary rejected at the moment (for example, due to rate limit exhausting) + - `soft reject` - message should be temporary rejected (for example, due to rate limit exhausting) - `reject` - message should be rejected as spam -Additionally, metric contains all symbols added during message's processing indexed by symbols' names. +Additionally, metric contains all symbols added during a message's processing, indexed by symbol names. -Moreover, some other keys might be in the reply: +Additional keys which may be in the reply include: -* `subject` - if action is `rewrite subject` then this value defines the desired subject for a message +* `subject` - if action is `rewrite subject` this value defines the desired subject for a message * `urls` - a list of urls found in a message (only hostnames) * `emails` - a list of emails found in a message * `message-id` - ID of message (useful for logging) -* `messages` - array of optional messages added by some rspamd filters (such as `SPF`) +* `messages` - array of optional messages added by rspamd filters (such as `SPF`) -## Rspamd JSON control block +## rspamd JSON control block -Since rspamd 0.9 it is also possible to pass additional data by using request body prepending JSON control block to the message. Hence, you can use either headers or JSON block to pass data from MTA to rspamd. -The advantage of JSON block is that it can be encrypted using `httpcrypt`. Headers encryption is currently unsupported. +Since rspamd version 0.9 it is also possible to pass additional data by prepending a JSON control block to a message. So you can use either headers or a JSON block to pass data from the MTA to rspamd. The advantage of the JSON block is that it can be encrypted using `httpcrypt`. Header encryption is currently unsupported. -To use JSON control block, you need to pass extra header to rspamd called `Message-Length`. This header should be equal to the size of the message **excluding** JSON control block. Therefore, the size of control block is equal to `Content-Length` - `Message-Length`. Rspamd assumes that a message starts immediately after control block (with no extra CRLF). This method is equally compatible with streaming transfer, however even if not specifying `Content-Length` you are still required to specify `Message-Length`. +To use a JSON control block, you need to pass an extra header called `Message-Length` to rspamd. This header should be equal to the size of the message **excluding** the JSON control block. Therefore, the size of the control block is equal to `Content-Length - Message-Length`. rspamd assumes that a message starts immediately after the control block (with no extra CRLF). This method is equally compatible with streaming transfer, however even if you are not specifying `Content-Length` you are still required to specify `Message-Length`. -Here is an example of JSON control block: +Here is an example of a JSON control block: ~~~json { @@ -156,38 +151,41 @@ Here is an example of JSON control block: } ~~~ -Moreover, [UCL](https://github.com/vstakhov/libucl) json extensions and syntax conventions are also supported inside control block. +Moreover, [UCL](https://github.com/vstakhov/libucl) json extensions and syntax conventions are also supported inside the control block. ## Legacy RSPAMC protocol -For compatibility, rspamd also supports legacy `RSPAMC` and also spamassassin `SPAMC` protocols. Thought their usage is discouraged, these protocols could be still used as last resort to communicate with rspamd from legacy applications. -The rspamc dialog looks as following: +For compatibility, rspamd supports legacy `RSPAMC` and also SpamAssassin `SPAMC` protocols. Though their usage is discouraged, these protocols can still be used as a last resort to communicate with rspamd from legacy applications. - SYMBOLS RSPAMC/1.1 - Content-Length: 2200 +The RSPAMC dialog looks as follows: - <message octets> +~~~ +SYMBOLS RSPAMC/1.1 +Content-Length: 2200 - RSPAMD/1.1 0 OK - Metric: default; True; 10.40 / 10.00 / 0.00 - Symbol: R_UNDISC_RCPT - Symbol: ONCE_RECEIVED - Symbol: R_MISSING_CHARSET - Urls: +<message octets> + +RSPAMD/1.1 0 OK +Metric: default; True; 10.40 / 10.00 / 0.00 +Symbol: R_UNDISC_RCPT +Symbol: ONCE_RECEIVED +Symbol: R_MISSING_CHARSET +Urls: +~~~ -Rspamc protocol support different commands as well: +The RSPAMC protocol also supports different commands: -| Command | Description | -| :-------| :----- | -| CHECK | Check a message and output results for each metric. But do not output symbols. | -| SYMBOLS | Same as `CHECK` but output symbols. | -| PROCESS | Same as `SYMBOLS` but output also original message with inserted X-Spam headers. | -| PING | Do not do any processing, just check rspamd state: | +| Command | Description | +| :-------| :----- | +| CHECK | Check a message and output results for each metric, but do not output symbols. | +| SYMBOLS | Same as `CHECK`, but output symbols. | +| PROCESS | Same as `SYMBOLS` but also output the original message with inserted X-Spam headers. | +| PING | Do not do any processing, just check rspamd state. | -After command there should be one mandatory header: `Content-Length` that defines message's length in bytes and optional headers (same as for HTTP). +After the command, there should be one mandatory header - `Content-Length` - which defines a message's length in bytes, and optional headers (same as for HTTP). -Rspamd supports spamassassin `spamc` protocol and you can even pass rspamc headers in spamc mode, but reply of rspamd in `spamc` mode is truncated to "default" metric only with no options for symbols being displayed. Rspamc reply looks as following: +rspamd supports SpamAssassin's `spamc` protocol, and you can even pass rspamc headers in spamc mode, but the reply of rspamd in `spamc` mode is truncated to the "default" metric only with no options for symbols being displayed. Rspamc reply looks as follows: RSPAMD/1.1 0 OK Metric: default; True; 10.40 / 10.00 / 0.00 |