]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - config/cfgroot/ipblocklist-functions.pl
ipblocklist-functions.pl: Add get_ipset_db_file() function.
[people/pmueller/ipfire-2.x.git] / config / cfgroot / ipblocklist-functions.pl
1 #!/usr/bin/perl -w
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 2 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 package IPblocklist;
23
24 require '/var/ipfire/ipblocklist/sources';
25
26 # Location where the blocklists in ipset compatible format are stored.
27 our $blocklist_dir = "/var/lib/ipblocklist";
28
29 # File extension of the blocklist files.
30 our $blocklist_file_extension = ".conf";
31
32 #
33 ## Function to get all available blocklists.
34 #
35 sub get_blocklists () {
36 my @blocklists;
37
38 # Loop through the hash of blocklists.
39 foreach my $blocklist ( keys %IPblocklist::List::sources ) {
40 # Add the list to the array.
41 push(@blocklists, $blocklist);
42 }
43
44 # Sort and return the array.
45 return sort(@blocklists);
46 }
47
48 #
49 ## Tiny function to get the full path and name of a given blocklist.
50 #
51 sub get_ipset_db_file($) {
52 my ($set) = @_;
53
54 # Generate the
55 my $file = "$blocklist_dir/$set$blocklist_file_extension";
56
57 # Return the file name.
58 return $file;
59 }
60
61 1;