�
Ϫ�f � �V � d Z ddlmZ ddlZddlmZ ddlmZmZ ddl m
ZmZ
ddlmZmZ ddlmZmZ dd lmZ d
� Z
d� Z G d� d
ej, ej. � Zesej2 dk\ r
eeeeef f ZneZ G d� deej: � Z G d� dej: � Zy)z1
Postfix mail transport agent related protocols.
� )�annotationsN)�UserDict)�
TYPE_CHECKING�Union)�quote�unquote)�defer�protocol)�basic�policies)�logc �^ � t | � }t |t � r|j d� }|S �N�ascii)�_quote�
isinstance�str�encode��s�quoteds �;/usr/lib/python3/dist-packages/twisted/protocols/postfix.pyr r s( � �
�A�Y�F��&�#�����w�'���M� c �| � t | t � r| j d� } t | � }|j d� S r )r �bytes�decode�_unquoter r s r r r s2 � ��!�U��
�H�H�W���
�a�[�F��=�=��!�!r c �D � e Zd ZdZdZdZd� Zdd�Zd� Zd� Z d� Z
d � Zd
� Zy)
�PostfixTCPMapServera
Postfix mail transport agent TCP map protocol implementation.
Receive requests for data matching given key via lineReceived,
asks it's factory for the data with self.factory.get(key), and
returns the data to the requester. None means no entry found.
You can use postfix's postmap to test the map service::
/usr/sbin/postmap -q KEY tcp:localhost:4242
iX �
c �: � | j | j � y �N)�
setTimeout�timeout)�selfs r �connectionMadez"PostfixTCPMapServer.connectionMade5 s � �������%r c �b � | j t |� j d� dz |z � y)z8
Send an SMTP-like code with a message.
r � N)�sendLiner r )r% �code�messages r �sendCodezPostfixTCPMapServer.sendCode8 s) � �
�
�
�c�$�i�&�&�w�/�$�6��@�Ar c � � | j � |j d d� \ }} t | d|j d� z � } ||� y # t $ r |}d }Y �8w xY w# t
$ rM t
t j � d � j d� }| j dd|z dz |z � Y y w xY w# t $ r | j dd� Y y w xY w)N� �do_r � s Command s failed: s unknown command)�resetTimeout�split�
ValueError�getattrr �
BaseExceptionr �sys�exc_infor r, �AttributeError)r% �line�request�params�f�excInfos r �lineReceivedz PostfixTCPMapServer.lineReceived> |