# -*- coding: utf-8 -*-
"""data models for POP3 protocol
.. versionadded:: 1.10.0
"""
from typing import TYPE_CHECKING
from pcapkit.corekit.infoclass import info_final
from pcapkit.protocols.data import Protocol
if TYPE_CHECKING:
from typing import Optional
from typing_extensions import Literal
from pcapkit.const.pop3.command import Command as Enum_Command
from pcapkit.const.pop3.response_code import ResponseCode
from pcapkit.protocols.application.pop3.protocol import Status as POP3_Status
from pcapkit.protocols.application.pop3.protocol import Type as POP3_Type
__all__ = [
'POP3',
'Command', 'Response', 'Challenge', 'Tail',
]
[docs]
class POP3(Protocol):
"""Data model for POP3 protocol."""
#: Type.
type: 'POP3_Type'
[docs]
@info_final
class Command(POP3):
"""Data model for a POP3 command (:rfc:`1939#section-3`)."""
#: Type.
type: 'Literal[POP3_Type.COMMAND]'
#: Command keyword.
cmmd: 'Enum_Command'
#: Parameters, in order.
args: 'tuple[str, ...]'
#: Keyword as received, in its original case; :attr:`cmmd` is the
#: case-insensitive lookup of it.
raw_cmmd: 'bytes'
if TYPE_CHECKING:
def __init__(self, type: 'Literal[POP3_Type.COMMAND]', cmmd: 'Enum_Command', args: 'tuple[str, ...]', raw_cmmd: 'bytes') -> 'None': ... # pylint: disable=unused-argument,super-init-not-called,multiple-statements,line-too-long,redefined-builtin
[docs]
@info_final
class Response(POP3):
"""Data model for a POP3 response, single-line or multi-line
(:rfc:`1939#section-3`)."""
#: Type.
type: 'Literal[POP3_Type.RESPONSE]'
#: Status indicator.
status: 'POP3_Status'
#: Text after the status indicator and SP, :obj:`None` where the line ends
#: with the status indicator.
text: 'Optional[str]'
#: Response code :attr:`text` opens with (:rfc:`2449#section-8`), if any.
code: 'Optional[ResponseCode]'
#: Lines after the first, as sent, byte-stuffed, without their CRLF or the
#: line ending the response; :obj:`None` for a single-line response.
lines: 'Optional[tuple[bytes, ...]]'
#: The same lines with the byte-stuffing undone.
body: 'Optional[tuple[bytes, ...]]'
if TYPE_CHECKING:
def __init__(self, type: 'Literal[POP3_Type.RESPONSE]', status: 'POP3_Status', text: 'Optional[str]', code: 'Optional[ResponseCode]', lines: 'Optional[tuple[bytes, ...]]', body: 'Optional[tuple[bytes, ...]]') -> 'None': ... # pylint: disable=unused-argument,super-init-not-called,multiple-statements,line-too-long,redefined-builtin
[docs]
@info_final
class Challenge(POP3):
"""Data model for a server challenge of the ``AUTH`` command
(:rfc:`5034#section-4`)."""
#: Type.
type: 'Literal[POP3_Type.CHALLENGE]'
#: Challenge in Base64, as sent; empty for an empty challenge.
challenge: 'str'
if TYPE_CHECKING:
def __init__(self, type: 'Literal[POP3_Type.CHALLENGE]', challenge: 'str') -> 'None': ... # pylint: disable=unused-argument,super-init-not-called,multiple-statements,line-too-long,redefined-builtin
[docs]
@info_final
class Tail(POP3):
"""Data model for the rest of a multi-line response whose first line an
earlier segment carried, up to and including the line ending it
(:rfc:`1939#section-3`)."""
#: Type.
type: 'Literal[POP3_Type.TAIL]'
#: Lines as sent, byte-stuffed, without their CRLF or the line ending the
#: response.
lines: 'tuple[bytes, ...]'
#: The same lines with the byte-stuffing undone.
body: 'tuple[bytes, ...]'
if TYPE_CHECKING:
def __init__(self, type: 'Literal[POP3_Type.TAIL]', lines: 'tuple[bytes, ...]', body: 'tuple[bytes, ...]') -> 'None': ... # pylint: disable=unused-argument,super-init-not-called,multiple-statements,line-too-long,redefined-builtin