1/* RHSBL checker.
2   Copyright (C) 2006, 2007 Jan Rafaj
3   Copyright (C) 2008-2021 Sergey Poznyakoff
4
5   This program is free software; you can redistribute it and/or modify
6   it under the terms of the GNU General Public License as published by
7   the Free Software Foundation; either version 3, or (at your option)
8   any later version.
9
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   GNU General Public License for more details.
14
15   You should have received a copy of the GNU General Public License
16   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
17
18module 'match_rhsbl'.
19
20require 'status'
21require 'dns'
22require 'match_cidr'
23
24#pragma regex push +extended
25func match_rhsbl(string email, string zone, string iprange)
26  returns number
27do
28  if iprange = 'ANY'
29    set iprange '127.0.0.0/8'
30  fi
31  if not email matches '@.+$'
32    throw e_failure "%email: invalid e-mail"
33  fi
34
35  return match_cidr (resolve (domainpart(email), zone), iprange)
36done
37#pragma regex pop
38