Mail::...stname(3pm)
π Mail::Milter::Module::ConnectMatchesHostname π
okay bestie, this is the 3pm manual page from the User Contributed Perl Documentation section, and it's about a lil milter module that vibes-checks connecting hosts. let's get into it π
πΈ NAME πΈ
Mail::Milter::Module::ConnectMatchesHostnameβ milter to accept/reject connecting hosts matching regex(es)
β¨ SYNOPSIS β¨
here's the whole vibe in code form, no notes:
use Mail::Milter::Module::ConnectMatchesHostname;
my $milter = new Mail::Milter::Module::ConnectMatchesHostname;
my $milter2 = &ConnectMatchesHostname; # convenience
$milter2->set_message('Connecting hostname %H looks like a dynamic address');
π DESCRIPTION π
so basically this milter module rejects any connecting host whose hostname contains one of a group of built-in patterns that match the IP address of the connecting host. iconic behaviour, honestly. it's normally used to sniff out dynamic pool addresses π΅οΈβοΈ
currently, these patterns embedded in the hostname count as a match, where 10.11.12.13 is the IPv4 address of the connecting host. in all these cases the string has to be preceded by a non-digit character, or else it has to be sitting right at the start of the hostname:
010.011.012.013. (optionally without internal dots, or with - in place of .)
013.012.011.010. (optionally with - in place of .)
10.11.12.13. (optionally without internal dots, or with - in place of .)
13.12.11.10. (optionally with - in place of .)
0A0B0C0D (hexadecimal, ignoring case)
more specific patterns are anticipated to be added in the future. and because of that, if you use ConnectMatchesHostname, pay attention to this perldoc manual page when you update to a newer version of Mail::Milter. like, actually read it, bestie, it's giving important π
one final note π«Ά ISPs can and do use "dynamic-looking" reverse DNS entries for what they consider to be legitimate server addresses. this is not ideal, and it may require embedding this module in a Chain set to "accept_break" with regular expressions β for example:
my $milter = new Mail::Milter::Chain(
&ConnectRegex(
'\.fooisp\.com$',
)->accept_match(1);
&ConnectMatchesHostname,
)->accept_break(1);
π METHODS π
π new()
creates a ConnectMatchesHostname object. simple as that, periodt β¨
π« set_message(MESSAGE)
sets the message used when rejecting connections. this string may contain the substring %H, which gets replaced by the matching hostname, and/or the substring %A, which gets replaced by the matching IP address π₯
this method returns a reference to the object itself, which lets you chain the method call. main character energy fr fr π
π BUGS π
in Sendmail 8.11 and 8.12, a milter rejection at "connect" stage does not allow the reply message to be set β it simply becomes "not accepting messages". however, this module still attempts to set the reply code and message in the hope that this will be fixed. manifesting that fix for us πβ¨
the implementation of this module could be much more efficient. not me dragging the module's own code but okay π
π AUTHOR π
Todd Vierling, <tv@duh.org> <tv@pobox.com>
π¦ SEE ALSO π¦
Mail::Milter::Object
π POD ERRORS π
hey! the above document had some coding errors, which are explained below:
around line 98:
You can't have =items (as at line 110) unless the first thing after
the =over is an =item
and that's the whole page, bestie!! this one shipped with perl v5.36.0 and it's dated 2023-01-22 β go forth and filter those dynamic pool addresses, ily πβ¨
π¦ where this page comes from
- debian bookworm: libmail-milter-perl 0.07-2 Β· BSD-3-Clause
- ubuntu noble: libmail-milter-perl 0.07-2 Β· BSD-3-Clause
- ubuntu resolute: libmail-milter-perl 0.07-2 Β· BSD-3-Clause
- ubuntu stonking: libmail-milter-perl 0.07-2 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms