MIMEDEFANG-NOTIFY(7)
๐ NAME ๐
okay so bestie, mimedefang-notify โ it's literally the conventions that mimedefang-multiplexor(8) uses to tell an external program that stuff changed. state changes, notification vibes, the whole thing. ๐ฆ
๐ธ DESCRIPTION ๐ธ
so here's the tea. if you hand the -O option to mimedefang-multiplexor, it will let external programs connect to a socket and get pinged whenever certain state changes happen inside the multiplexor. โจ
and those external programs? they can react however they want. no rules, main character energy. the external program that sits there listening for state changes is called a listener. periodt.
๐ NOTIFICATION OVERVIEW ๐
from the listener's point of view, the whole thing goes like this:
- the listener connects to a TCP or UNIX-domain socket. ๐
- the listener tells
mimedefang-multiplexorwhich message types it's interested in. ๐ - the listener loops forever, reading messages off the socket and reacting to them. ๐
๐ MESSAGES ๐
each message from the multiplexor is normally just one uppercase letter, maybe followed by a space and some arguments, then a newline. simple. clean. iconic.
two special messages exist, and they're giving very much "system announcement":
*OKfollowed by a newline โ this one shows up when a listener first connects. ๐ซถ*ERRfollowed by some text and a newline โ this one shows up when an error happens. ๐ญ
and now the normal messages, bestie:
Bโ issued whenever a worker gets killed because of a busy timeout. ๐F nโ issued whenever the number of free workers changes. the parameternis the number of free workers. ๐งฎRโ issued whenever someone has forced a filter reread. ๐S n nmsgโ issued whenever workern's status tag changes. the status tag is a string saying what the worker is currently doing; the-Zoption to the multiplexor lets the Perl code update the status tag, so you get a good idea what each worker is up to. ๐Uโ issued whenever a worker has died unexpectedly. ๐Yโ issued whenever the number of free workers changes from zero to non-zero. ๐Zโ issued whenever the number of free workers falls to zero. ๐
๐ฆ EXPRESSING INTEREST ๐ฆ
okay important: a listener gets zero messages until it has expressed interest in the message types it wants. no interest, no gossip. ๐ฌ
to express interest, the listener sends a question mark (?) followed by the types of messages it's interested in, followed by a newline, over the socket.
so for example, a listener that's into the R and F messages would send this line:
?RF
and a listener that wants every possible message type should send:
?*
once a listener has expressed interest, it may receive messages at literally any time, so it should be monitoring the socket for messages. ๐โจ
ngl this part matters: a listener always receives the special messages*OKand*ERR, even if it never expressed interest in them. no opting out, bestie. ๐
โญ EXAMPLE โญ
the following Perl script implements a listener that, on Linux, rejects new SMTP connections if all workers are busy, and accepts them again once a worker is free. existing SMTP connections are not shut down โ the system merely refuses new connections if all the workers are busy. ๐ซ
this script assumes you used the -O inet:4567 option to mimedefang-multiplexor.
#!/usr/bin/perl -w
#
# On Linux, prepare to use this script like this:
# /sbin/iptables -N smtp_connect
# /sbin/iptables -A INPUT --proto tcp --dport 25 --syn -j smtp_connect
# Then run the script as root.
use IO::Socket::INET;
sub no_free_workers {
print STDERR "No free workers!\n";
system("/sbin/iptables -A smtp_connect -j REJECT");
}
sub some_free_workers {
print STDERR "Some free workers.\n";
system("/sbin/iptables -F smtp_connect");
}
sub main {
my $sock;
$sock = IO::Socket::INET->new(PeerAddr => '127.0.0.1',
PeerPort => '4567',
Proto => 'tcp');
# We are only interested in Y and Z messages
print $sock "?YZ\n";
$sock->flush();
while(<$sock>) {
if (/^Z/) {
no_free_workers();
}
if (/^Y/) {
some_free_workers();
}
}
# EOF from multiplexor?? Better undo firewalling
system("/sbin/iptables -F smtp_connect");
}
main();
๐ SEE ALSO ๐
mimedefang.pl(8), mimedefang(8), mimedefang-multiplexor(8), mimedefang-filter(5) ๐ซถ
and that's the whole page, bestie!! ๐ this one's from the 4th Berkeley Distribution, dated 8 February 2005 โ vintage but still slaying, no cap. go forth and listen to your sockets. ๐โจ
๐ฆ where this page comes from
- debian bookworm: mimedefang 3.3-1
- debian trixie: mimedefang 3.6-2 ยท GPL-2.0-only
- epel 10: mimedefang 3.7.1-1.el10_3 ยท GPL-2.0-only AND GPL-2.0-or-later
- epel 9: mimedefang 3.7.1-1.el9 ยท GPL-2.0-only AND GPL-2.0-or-later
- fedora 43: mimedefang 3.6-3.fc43 ยท GPL-2.0-only AND GPL-2.0-or-later
- fedora 43: mimedefang 3.7.1-1.fc43 ยท GPL-2.0-only AND GPL-2.0-or-later
- fedora 44: mimedefang 3.6-4.fc44 ยท GPL-2.0-only AND GPL-2.0-or-later
- fedora 44: mimedefang 3.7.1-1.fc44 ยท GPL-2.0-only AND GPL-2.0-or-later
- ubuntu jammy: mimedefang 2.84-4build3
- ubuntu noble: mimedefang 3.3-1build4
- ubuntu questing: mimedefang 3.6-2.1
- ubuntu resolute: mimedefang 3.6-2.1build1 ยท GPL-2.0-only
- ubuntu stonking: mimedefang 3.6-2.1build2 ยท GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms