Thanks to visit codestin.com
Credit goes to github.com

Skip to content

✨ Track IMAP connection state #416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 11, 2025
Merged

✨ Track IMAP connection state #416

merged 2 commits into from
Mar 11, 2025

Conversation

nevans
Copy link
Collaborator

@nevans nevans commented Mar 11, 2025

Tracking IMAP connection state has many uses. But in this PR, we're only tracking the session state and exposing a #connection_state attribute reader.

For forward-compatibility, the only documented methods on the connection state objects are (currently) #name and #to_sym, which will return one of not_authenticated, authenticated, selected, or logout.

From RFC9051:

                   +----------------------+
                   |connection established|
                   +----------------------+
                              ||
                              \/
            +--------------------------------------+
            |          server greeting             |
            +--------------------------------------+
                      || (1)       || (2)        || (3)
                      \/           ||            ||
            +-----------------+    ||            ||
            |Not Authenticated|    ||            ||
            +-----------------+    ||            ||
             || (7)   || (4)       ||            ||
             ||       \/           \/            ||
             ||     +----------------+           ||
             ||     | Authenticated  |<=++       ||
             ||     +----------------+  ||       ||
             ||       || (7)   || (5)   || (6)   ||
             ||       ||       \/       ||       ||
             ||       ||    +--------+  ||       ||
             ||       ||    |Selected|==++       ||
             ||       ||    +--------+           ||
             ||       ||       || (7)            ||
             \/       \/       \/                \/
            +--------------------------------------+
            |               Logout                 |
            +--------------------------------------+
                              ||
                              \/
                +-------------------------------+
                |both sides close the connection|
                +-------------------------------+

Legend for the above diagram:

(1) connection without pre-authentication (OK greeting)
(2) pre-authenticated connection (PREAUTH greeting)
(3) rejected connection (BYE greeting)
(4) successful LOGIN or AUTHENTICATE command
(5) successful SELECT or EXAMINE command
(6) CLOSE or UNSELECT command, unsolicited CLOSED response code, or
    failed SELECT or EXAMINE command
(7) LOGOUT command, server shutdown, or connection closed

Before the server greeting, the state is not_authenticated.
After the connection closes, the state remains logout.

nevans added 2 commits March 11, 2025 13:20
Because a `#connection_state` attribute will be added, I'd like to
consistently name the connection states everywhere they are used.
Tracking connection state can have many uses.  But in this version,
we're only tracking the session state and exposing a `#connection_state`
attribute reader.

For forward-compatibility, the only documented methods on the connection
state objects are (currently) `#name` and `#to_sym`, which will return
one of `not_authenticated`, `authenticated`, `selected`, or `logout`.

From RFC9051:
```
                   +----------------------+
                   |connection established|
                   +----------------------+
                              ||
                              \/
            +--------------------------------------+
            |          server greeting             |
            +--------------------------------------+
                      || (1)       || (2)        || (3)
                      \/           ||            ||
            +-----------------+    ||            ||
            |Not Authenticated|    ||            ||
            +-----------------+    ||            ||
             || (7)   || (4)       ||            ||
             ||       \/           \/            ||
             ||     +----------------+           ||
             ||     | Authenticated  |<=++       ||
             ||     +----------------+  ||       ||
             ||       || (7)   || (5)   || (6)   ||
             ||       ||       \/       ||       ||
             ||       ||    +--------+  ||       ||
             ||       ||    |Selected|==++       ||
             ||       ||    +--------+           ||
             ||       ||       || (7)            ||
             \/       \/       \/                \/
            +--------------------------------------+
            |               Logout                 |
            +--------------------------------------+
                              ||
                              \/
                +-------------------------------+
                |both sides close the connection|
                +-------------------------------+
```
> Legend for the above diagram:
>
> (1) connection without pre-authentication (OK greeting)
> (2) pre-authenticated connection (PREAUTH greeting)
> (3) rejected connection (BYE greeting)
> (4) successful LOGIN or AUTHENTICATE command
> (5) successful SELECT or EXAMINE command
> (6) CLOSE or UNSELECT command, unsolicited CLOSED response code, or
>     failed SELECT or EXAMINE command
> (7) LOGOUT command, server shutdown, or connection closed

Before the server greeting, the state is `not_authenticated`.
After the connection closes, the state remains `logout`.
@nevans nevans merged commit 27d0cb6 into master Mar 11, 2025
37 checks passed
@nevans nevans deleted the track-connection-state branch March 11, 2025 22:46
@nevans nevans added the enhancement New feature or request label Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant