slimta.util

Package containing a variety of useful modules utilities that didn’t really belong anywhere else.

slimta.util.build_ipv4_socket_creator([only_ports=None])

Returns a function that will act like socket.create_connection() but only using IPv4 addresses. This function can be used as the socket_creator argument to some classes like MxSmtpRelay.

Parameters:only_ports – If given, can be a list to limit which ports are restricted to IPv4. Connections to all other ports may be IPv6.
slimta.util.create_connection_ipv4(address[, timeout=None[, source_address=None[, only_ports=None]]])

Attempts to mimick to socket.create_connection(), but connections are only made to IPv4 addresses.

Parameters:only_ports – If given, can be a list to limit which ports are restricted to IPv4. Connections to all other ports may be IPv6.
slimta.util.create_listeners(address[, family=<AddressFamily.AF_UNSPEC: 0>[, socktype=<SocketKind.SOCK_STREAM: 1>[, proto=0]]])

Uses socket.getaddrinfo() to create listening sockets for available socket parameters. For example, giving address as ('localhost', 80) on a system with IPv6 would return one socket bound to 127.0.0.1 and one bound to ``::1`.

May also be used for socket.AF_UNIX with a file path to produce a single unix domain socket listening on that path.

Parameters:
  • address – A (host, port) tuple to listen on.
  • family – the socket family, default AF_UNSPEC.
  • socktype – the socket type, default SOCK_STREAM.
  • proto – the socket protocol, default IPPROTO_IP.

Sub-Modules: