NAME
Mail::MIMEDefang::Net - Network related methods for email filters
DESCRIPTION
Mail::MIMEDefang::Net are a set of methods that can be called
from mimedefang-filter to call network related services.
METHODS
-
expand_ipv6_address
Method that returns an IPv6 address with all zero fields explicitly expanded, any field shorter than 4 hex digits will be padded with zeros.
-
reverse_ip_address_for_rbl
Method that returns the ip address in the appropriately-reversed format used for RBL lookups.
-
relay_is_blacklisted
Method that returns the result of the lookup (eg 127.0.0.2). Parameters are the ip address of the relay host and the domain of the rbl server.
-
email_is_blacklisted
Method that returns the result of the lookup (eg 127.0.0.2). Parameters are an email address, the domain of the hashbl server, and the type of hashing (MD5 or SHA1).
-
is_public_ip4_address $ip_addr
Returns true if $ip_addr is a publicly-routable IPv4 address, false otherwise
-
is_public_ip6_address $ip_addr
Returns true if $ip_addr is a publicly-routable IPv6 address, false otherwise
-
get_mx_ip_addresses $domain [$resolver_object] [$sort_by_pref]
Get the IPv4 and IPv6 addresses (A and AAAA records) of all MX hosts for given domain. If there are no MX hosts, then return the A and AAAA records of the domain itself.
If
$sort_by_prefis true, the addresses are returned in ascending order of MX preference (hosts with equal preference keep the resolver order). Otherwise they are returned in the order of the DNS answer. Passundefas$resolver_objectto use the shared resolver. -
md_get_bogus_mx_hosts $domain
Returns a list of "bogus" IP addresses that are in $domain's list of MX records. A "bogus" IP address is loopback/private/multicast/etc. Both IPv4 and IPv6 addresses are checked.
-
get_ptr_record $ip_address [$resolver_object]
Get PTR record for given IPv4 or IPv6 address.
-
md_get_dmarc_record $domain
Returns the DMARC record of a domain.
-
relay_is_blacklisted_multi
Method that rerurns a hash table with one entry per original domain. Entries in hash will be:
{ $domain =<gt$return }>, where $return is one of SERVFAIL, NXDOMAIN or a list of IP addresses as a dotted-quad. -
relay_is_blacklisted_multi_count
Method that returns a number indicating how many RBLs the host was blacklisted in.
-
relay_is_blacklisted_multi_list
Method that returns an array indicating the domains in which the relay is blacklisted.
-
md_dns_txt($resolver, $name [, $filter])
Query
$namefor TXT records using the suppliedNet::DNS::Resolverobject. In list context it returns every TXT string found, in scalar context only the first one; on any error (NXDOMAIN, SERVFAIL, no TXT records) it returns an empty list orundef. The character-strings of a TXT record are concatenated without separators (RFC 7208 3.3).The optional
$filterargument is aRegexp(e.g.qr/^v=spf1\b/i); when given, only TXT records whose text matches$filterare returned, which lets callers pick a specific record type (SPF, BIMI, ...) out of a domain that publishes several unrelated TXT records. -
md_shared_resolver()
Returns a
Net::DNS::Resolver(withdefnames(0)) that is created once per worker process and then reused (and created again after afork()). It is the resolver whose answers "md_dns_query" caches. -
md_caching_resolver()
Returns an object that can be used where a
Net::DNS::Resolveris expected by modules that only call itssendanderrorstringmethods, likeMail::SPF::Server(dns_resolveroption) andMail::DKIM::DNS::resolver(). Lookups go throughmd_dns_queryon the resolver returned bymd_shared_resolver, so their answers are cached;errorstringrefers to the last lookup made through the object. Every other method is passed to the shared resolver. -
md_dns_cache_clear()
Empties the DNS answer cache used by "md_dns_query".
-
md_dns_query($resolver, $name, $type [, $method [, $nocache]])
Looks up
$name/$typelike thequery(default),sendorbgsendmethod ofNet::DNS::Resolver, chosen by$method, and with the same return values: aNet::DNS::Packetforqueryandsend, a socket to pass tobgreadforbgsend.When
$resolveris undefined or is the object returned by "md_shared_resolver", definitive answers are cached in the worker for as long as their TTL allows, but never longer than five minutes: positive answers use the smallest TTL of the answer section and NXDOMAIN or empty answers are kept for one minute. Timeouts, SERVFAIL and other errors are never cached. A resolver passed in by the caller is used as is, with no caching.Nothing is cached, and the cache is not consulted, when
$nocacheis true or$methodisbgsend.relay_is_blacklisted_multiusesbgsend, so blocklist answers are always fresh.The returned packet may be shared with other callers and must be treated as read-only.