Your IP : 13.58.32.115
3
\�� � @ s^ d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl
mZ ddlm
Z
mZ ddddd gZejd Zd
ZG dd� d�Ze� ad
ZdZdZd%dd�ZG dd� dej�ZG dd� dej�ZG dd� de�ZG dd� de�ZG dd � d e�ZG dd� d�Z dd� Z!e"dk�rZe!� Z#e#j$Z$de$k�rpe$j%d�Z&e'e$de&� e(� e)� dg�Z*e$e&d d� Z$nddl+Z*e,e*e$�Z-e-e#j.e#j/fe#j0e#j1fe#j2e#j3d�Z4e#j5�r6yddl6Z6W n. e7k
�r� e8d ej9d!� ej:d� Y nX e6j;d"�d# Z<yej5e<� W n. e=k
�r4 e8d$ej9d!� ej:d� Y nX yej>� W n e?k
�rX Y nX dS )&a� An RFC 5321 smtp proxy with optional RFC 1870 and RFC 6531 extensions.
Usage: %(program)s [options] [localhost:localport [remotehost:remoteport]]
Options:
--nosetuid
-n
This program generally tries to setuid `nobody', unless this flag is
set. The setuid call will fail if this program is not run as root (in
which case, use this flag).
--version
-V
Print the version number and exit.
--class classname
-c classname
Use `classname' as the concrete SMTP proxy class. Uses `PureProxy' by
default.
--size limit
-s limit
Restrict the total size of the incoming message to "limit" number of
bytes via the RFC 1870 SIZE extension. Defaults to 33554432 bytes.
--smtputf8
-u
Enable the SMTPUTF8 extension and behave as an RFC 6531 smtp proxy.
--debug
-d
Turn on debugging prints.
--help
-h
Print this message and exit.
Version: %(__version__)s
If localhost is not given then `localhost' is used, and if localport is not
given then 8025 is used. If remotehost is not given then `localhost' is used,
and if remoteport is not given, then 25 is used.
� N)�warn)�
get_addr_spec�get_angle_addr�SMTPChannel�
SMTPServer�DebuggingServer� PureProxy�MailmanProxyzPython SMTP proxy version 0.3c @ s e Zd Zdd� Zdd� ZdS )�Devnullc C s d S )N� )�self�msgr r �/usr/lib64/python3.6/smtpd.py�writef s z
Devnull.writec C s d S )Nr )r r r r �flushg s z
Devnull.flushN)�__name__�
__module__�__qualname__r r r r r r r
e s r
�
z, i � c C s4 t tt� tjd� |r&t |tjd� tj| � d S )N)�file)�print�__doc__�globals�sys�stderr�exit)�coder
r r r �usagep s r c @ s� e Zd ZdZdZdZejefdd��Ze dd� �Z
edd d fd
d�Zdd
� Z
dd� Ze dd� �Zejdd� �Ze dd� �Zejdd� �Ze dd� �Zejdd� �Ze dd� �Zejdd� �Ze dd� �Zejdd� �Ze dd � �Zejd!d � �Ze d"d#� �Zejd$d#� �Ze d%d&� �Zejd'd&� �Ze d(d)� �Zejd*d)� �Ze d+d,� �Zejd-d,� �Ze d.d/� �Zejd0d/� �Zd1d2� Zd3d4� Zd5d6� Zd7d8� Zd9d:� Zd;d<� Z d=d>� Z!d?d@� Z"dAdB� Z#dCdD� Z$dEdF� Z%dGdH� Z&dIdJ� Z'dKdL� Z(dMdN� Z)dOdP� Z*dQdR� Z+dS )Sr r � i c C s | S )Nr )�xr r r �<lambda>| s zSMTPChannel.<lambda>c C s* yt | jj� �S tk
r$ | jS X d S )N)�max�command_size_limits�values�
ValueError�command_size_limit)r r r r �max_command_size_limit~ s z"SMTPChannel.max_command_size_limitNFc C s t jj| ||d� || _|| _|| _|| _|| _|| _|rF|rFt d��|rdd| _
d| _d| _t
| _nd| _
d| _td�| _d | _| j� d| _d
| _| jj� tj� | _y|j� | _W n: tk
r� } z| j� |jd tjkr� d S d }~X nX tdt | j�t!d
� | j"d| jt#f � d S )N)�mapzFdecode_data and enable_SMTPUTF8 cannot be set to True at the same timer z
�.� s
� .�
Fr zPeer:)r z 220 %s %s)$�asynchat�
async_chat�__init__�smtp_server�conn�addr�data_size_limit�enable_SMTPUTF8�_decode_datar% �_emptystring�_linesep�_dotsep�NEWLINE�_newline�ord�_set_rset_state�
seen_greeting�
extended_smtpr# �clear�socketZgetfqdn�fqdnZgetpeername�peer�OSError�close�args�errnoZENOTCONNr �repr�DEBUGSTREAM�push�__version__) r Zserverr1 r2 r3 r( r4 �decode_data�errr r r r/ � s@
zSMTPChannel.__init__c C s. | j | _d| _g | _d| _d| _| jd� dS )z/Reset state variables to their post-DATA state.NFr s
)�COMMAND�
smtp_state�mailfrom�rcpttos�require_SMTPUTF8� num_bytes�set_terminator)r r r r �_set_post_data_state� s z SMTPChannel._set_post_data_statec C s | j � d| _g | _dS )z.Reset all state variables except the greeting.r N)rT �
received_data�received_lines)r r r r r<