Esempio n. 1
0
 def __init__(self, tls=None, **client_kwargs):
     super(MxSmtpRelay, self).__init__()
     self._mx_records = {}
     self._force_mx = {}
     self._relayers = {}
     self._client_kwargs = client_kwargs
     self._client_kwargs['tls'] = validate_tls(tls)
Esempio n. 2
0
    def __init__(self, socket, handlers, auth=False,
                 tls=None, tls_immediately=False, tls_wrapper=None,
                 command_timeout=None, data_timeout=None):
        self.handlers = handlers
        self.extensions = Extensions()

        self.io = IO(socket, tls_wrapper)

        self.bannered = False
        self.have_mailfrom = None
        self.have_rcptto = None
        self.ehlo_as = None
        self.authed = False

        self.extensions.add('8BITMIME')
        self.extensions.add('PIPELINING')
        self.extensions.add('ENHANCEDSTATUSCODES')
        self.extensions.add('SMTPUTF8')
        if tls and not tls_immediately:
            self.extensions.add('STARTTLS')
        if auth:
            if isinstance(auth, list):
                auth_obj = SASLAuth(auth)
            else:
                auth_obj = SASLAuth()
            auth_session = AuthSession(auth_obj, self.io)
            self.extensions.add('AUTH', auth_session)

        self.tls = validate_tls(tls, server_side=True)
        self.tls_immediately = tls_immediately

        self.command_timeout = command_timeout
        self.data_timeout = data_timeout or command_timeout
Esempio n. 3
0
 def __init__(self, tls=None, **client_kwargs):
     super(MxSmtpRelay, self).__init__()
     self._mx_records = {}
     self._force_mx = {}
     self._relayers = {}
     self._client_kwargs = client_kwargs
     self._client_kwargs['tls'] = validate_tls(tls)
Esempio n. 4
0
 def __init__(self, host, port=25, pool_size=None, client_class=None,
              tls=None, **client_kwargs):
     super(StaticSmtpRelay, self).__init__(pool_size)
     self.client_class = client_class or self._default_class
     self.host = host
     self.port = port
     self.client_kwargs = client_kwargs
     self.client_kwargs['tls'] = validate_tls(tls)
Esempio n. 5
0
 def __init__(self, url, pool_size=None, tls=None, ehlo_as=None,
              timeout=None, idle_timeout=None):
     super(HttpRelay, self).__init__(pool_size)
     self.url = urlparse.urlsplit(url, 'http')
     self.tls = validate_tls(tls)
     self.ehlo_as = ehlo_as or getfqdn()
     self.timeout = timeout
     self.idle_timeout = idle_timeout
Esempio n. 6
0
 def __init__(self, listener, queue, pool=None, max_size=None,
              validator_class=None, auth=False,
              tls=None, tls_immediately=False,
              command_timeout=None, data_timeout=None,
              hostname=None):
     super(SmtpEdge, self).__init__(listener, queue, pool, hostname)
     self.max_size = max_size
     self.command_timeout = command_timeout
     self.data_timeout = data_timeout
     self.validator_class = validator_class
     self.auth = auth
     self.tls = validate_tls(tls)
     self.tls_immediately = tls_immediately
Esempio n. 7
0
 def __init__(self,
              url,
              pool_size=None,
              tls=None,
              ehlo_as=None,
              timeout=None,
              idle_timeout=None):
     super(HttpRelay, self).__init__(pool_size)
     self.url = urlparse.urlsplit(url, 'http')
     self.tls = validate_tls(tls)
     self.ehlo_as = ehlo_as or getfqdn()
     self.timeout = timeout
     self.idle_timeout = idle_timeout
Esempio n. 8
0
 def __init__(self,
              host,
              port=25,
              pool_size=None,
              client_class=None,
              tls=None,
              **client_kwargs):
     super(StaticSmtpRelay, self).__init__(pool_size)
     self.client_class = client_class or self._default_class
     self.host = host
     self.port = port
     self.client_kwargs = client_kwargs
     self.client_kwargs['tls'] = validate_tls(tls)
Esempio n. 9
0
    def build_server(self, listener, pool=None, tls=None):
        """Constructs and returns a WSGI server engine, configured to use the
        current object as its application.

        :param listener: Usually a ``(ip, port)`` tuple defining the interface
                         and port upon which to listen for connections.
        :param pool: If given, defines a specific :class:`gevent.pool.Pool` to
                     use for new greenlets.
        :param tls: Optional dictionary of TLS settings passed directly as
                    keyword arguments to :class:`gevent.ssl.SSLSocket`.
        :rtype: :class:`gevent.pywsgi.WSGIServer`

        """
        spawn = pool or 'default'
        tls = validate_tls(tls)
        return GeventWSGIServer(listener, self, log=sys.stdout, spawn=spawn,
                                **tls)
Esempio n. 10
0
    def __init__(
        self,
        socket,
        handlers,
        auth=False,
        tls=None,
        tls_immediately=False,
        tls_wrapper=None,
        command_timeout=None,
        data_timeout=None,
    ):
        self.handlers = handlers
        self.extensions = Extensions()

        self.io = IO(socket, tls_wrapper)

        self.bannered = False
        self.have_mailfrom = None
        self.have_rcptto = None
        self.ehlo_as = None
        self.authed = False

        self.extensions.add("8BITMIME")
        self.extensions.add("PIPELINING")
        self.extensions.add("ENHANCEDSTATUSCODES")
        self.extensions.add("SMTPUTF8")
        if tls and not tls_immediately:
            self.extensions.add("STARTTLS")
        if auth:
            if isinstance(auth, list):
                auth_obj = SASLAuth(auth)
            else:
                auth_obj = SASLAuth()
            auth_session = AuthSession(auth_obj, self.io)
            self.extensions.add("AUTH", auth_session)

        self.tls = validate_tls(tls, server_side=True)
        self.tls_immediately = tls_immediately

        self.command_timeout = command_timeout
        self.data_timeout = data_timeout or command_timeout