* [PATCH] unsubscribe.milter
@ 2023-11-25 1:05 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2023-11-25 1:05 UTC (permalink / raw)
To: test
---
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;
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-11-25 1:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-25 1:05 [PATCH] unsubscribe.milter Eric Wong
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).