From: Eric Wong <e@80x24.org>
To: test@public-inbox.org
Subject: [PATCH] unsubscribe.milter
Date: Sat, 25 Nov 2023 01:05:56 +0000 [thread overview]
Message-ID: <20231125010556.15435-1-e@80x24.org> (raw)
---
examples/unsubscribe.milter | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/examples/unsubscribe.milter b/examples/unsubscribe.milter
index 8bad8bd5..fc76cc54 100644
--- a/examples/unsubscribe.milter
+++ b/examples/unsubscribe.milter
@@ -33,8 +33,8 @@ if (open my $fh, '<', $allow_domains) {
local $/ = "\n";
chomp(my @l = <$fh>);
die "close: $!" unless eof($fh) && close($fh);
- my %ad = map { lc($_) => 1 } @l;
- $ALLOW_DOMAINS = \%ad;
+ my %l = map { lc($_) => 1 } @l;
+ $ALLOW_DOMAINS = \%l;
} else {
warn <<EOM;
W: open $allow_domains: $! (all domains allowed)
@@ -43,6 +43,10 @@ W: this is probably not what you want.
EOM
}
+# is a config file necessary?
+my @ALLOW_ADDR = (qr/\A::1\z/, qr/\A127\./);
+my $ALLOW_ADDR = join('|', @ALLOW_ADDR);
+
my %cbs;
$cbs{connect} = sub {
my ($ctx) = @_;
@@ -104,7 +108,12 @@ $cbs{eom} = sub {
eval {
my $priv = $ctx->getpriv;
$ctx->setpriv({ header => {}, envrcpt => {} });
+
my @rcpt = keys %{$priv->{envrcpt}};
+ if ($ALLOW_ADDR) {
+ my $x = $ctx->getsymval('{daemon_addr}');
+ return SMFIS_CONTINUE if $x && $x !~ /$ALLOW_ADDR/;
+ }
# one recipient, one unique HTTP(S) URL
return SMFIS_CONTINUE if @rcpt != 1;
reply other threads:[~2023-11-25 1:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231125010556.15435-1-e@80x24.org \
--to=e@80x24.org \
--cc=test@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).