Exemple #1
0
from socket import getfqdn, error as socket_error
from functools import wraps

from gevent import Timeout
from gevent.socket import create_connection

from slimta.smtp import SmtpError
from slimta.smtp.reply import Reply, timed_out, connection_failed
from slimta.smtp.client import Client
from slimta import logging
from ..pool import RelayPoolClient
from . import SmtpRelayError

__all__ = ['SmtpRelayClient']

log = logging.getSocketLogger(__name__)
hostname = getfqdn()


def current_command(cmd):
    def deco(old_f):
        @wraps(old_f)
        def new_f(self, *args, **kwargs):
            prev = self.current_command
            self.current_command = cmd
            ret = old_f(self, *args, **kwargs)
            self.current_command = prev
            return ret
        return new_f
    return deco
 def setUp(self):
     self.log = getSocketLogger('test')
Exemple #3
0
from socket import getfqdn, error as socket_error
from functools import wraps

from gevent import Timeout
from gevent.socket import create_connection

from slimta.smtp import SmtpError
from slimta.smtp.reply import Reply, timed_out
from slimta.smtp.client import Client
from slimta import logging
from ..pool import RelayPoolClient
from . import SmtpRelayError

__all__ = ['SmtpRelayClient']

log = logging.getSocketLogger(__name__)
hostname = getfqdn()


def current_command(cmd):
    def deco(old_f):
        @wraps(old_f)
        def new_f(self, *args, **kwargs):
            prev = self.current_command
            self.current_command = cmd
            ret = old_f(self, *args, **kwargs)
            self.current_command = prev
            return ret
        return new_f
    return deco
Exemple #4
0
"""Package providing support for the `PROXY protocol`_ on various edge
services.

.. _PROXY protocol: http://www.haproxy.org/download/1.5/doc/proxy-protocol.txt

"""

from __future__ import absolute_import

from gevent import socket

from slimta.logging import getSocketLogger

__all__ = ["ProxyProtocolV1"]

log = getSocketLogger(__name__)


class ProxyProtocolV1(object):
    """Implements version 1 of the proxy protocol, to avoid losing information
    about the original connection when routing traffic through a proxy. This
    process involves an extra line sent by the client at the beginning of every
    cconnection.

    Mix-in before an implementation of :class:`~slimta.edge.EdgeServer` to
    expect every connection to begin with a proxy protocol header. The
    ``address`` argument passed in to the
    :meth:`~slimta.edge.EdgeServer.handle` method will contain information
    about the original connection source, before proxying.

    """
 def setUp(self):
     self.log = getSocketLogger('test')
"""Package providing support for the `PROXY protocol`_ on various edge
services.

.. _PROXY protocol: http://www.haproxy.org/download/1.5/doc/proxy-protocol.txt

"""

from __future__ import absolute_import

from gevent import socket

from slimta.logging import getSocketLogger

__all__ = ['ProxyProtocolV1']

log = getSocketLogger(__name__)


class ProxyProtocolV1(object):
    """Implements version 1 of the proxy protocol, to avoid losing information
    about the original connection when routing traffic through a proxy. This
    process involves an extra line sent by the client at the beginning of every
    cconnection.

    Mix-in before an implementation of :class:`~slimta.edge.EdgeServer` to
    expect every connection to begin with a proxy protocol header. The
    ``address`` argument passed in to the
    :meth:`~slimta.edge.EdgeServer.handle` method will contain information
    about the original connection source, before proxying.

    """