Commit Graph
6 Commits
Author SHA1 Message Date
David Evans 8ac6696b3c Implement encoding logging mode for redaction (#678)
Resolves #662

Command/Response Encoder can be configured using loggingMode. If turned on then user-sensitive strings won't be encoding, but any metadata will.

For example, 1 LOGIN username password becomes 1 LOGIN "" "", thereby hiding the user's information.
2022-01-26 15:50:12 -08:00
David Evans 59a57ee70b New client state machine (#610)
The client state machine has now been fully rewritten, and encapsulates the miniature state machines implemented in previous PRs.

I've extracted the state machine from IMAPClientHandler and moved it into ClientStateMachine, hence all the code deletion.

The state machine receives a command, response, or continuation request from the IMAPClientHandler and returns an array of Chunk/EventLoopPromise pairs that the client handler should then write to the network.

Also we didn't previously queue Append commands like we did for others, however it's now become apparent that all commands types should be queued, so we do that now.

A lot of tests have been added to make sure everything works.

Note that a lot of sendCommand tests have been deleted as we now precondition on user errors instead of throwing.
2021-09-10 13:45:11 +01:00
David Evans 79657fd985 Track command tags and restrict potential concurrent commands. (#596)
In most cases in IMAP it's possible to allow multiple commands to run concurrently. However, in some cases this would lead to undefined behaviour.

In particular, when appending, append is the only command that can be sent/active, as for authenticating, and obviously IDLE.

This PR implements that by tracking the outgoing tags, and the incoming tagged responses.
2021-07-30 11:04:15 +01:00
David Evans 9484279fe6 Add Append support to new client state machine (#595)
Identical pattern to that used for IDLE and AUTHENTICATE. The main ClientStateMachine detects the append command being sent, and switches state to contain a sub-machine that is dedicated to validating the lifecycle of an append command.

We support "standard" message appends, as well as catenation, and continuation requests for both.
2021-07-28 17:18:53 +01:00
David Evans d49bbc1968 New state machine authentication flow (#587)
Add support for authentication to the new client state machine, with a typical workflow test, and a test to show that attempting to send another command while authenticating will result in an error.
2021-07-20 13:30:40 +01:00
David Evans d7db35c768 New state machine with boilerplate for IDLE command (#586)
NOTE: The many defaults used when switching over things is just because this is an example. If we're happy with how this looks, I'll remove them and handle properly.

This is a basic demonstrative implementation of the new client state machine that shows how the IDLE command is supported.

For an idle state to be established, the client needs to send the idleStart command, and the server needs to respond with a continuationRequest, at which point the state is idle.
2021-07-19 14:58:44 +01:00