Skip to content

Commit 9f4831b

Browse files
committed
Remove always accept ICMP
Other minor cosmetic changes
1 parent 5f098f5 commit 9f4831b

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

nft-blackhole.conf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Config file for nft-blackhole in yaml
22

33

4-
5-
# IP versions supported
4+
# IP versions supported: 'on' or 'off', default 'off'
65
IP_VERSION:
76
v4: on
87
v6: on

nft-blackhole.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
__author__ = "Tomasz Cebula <tomasz.cebula@gmail.com>"
66
__license__ = "MIT"
7-
__version__ = "0.1.1"
7+
__version__ = "1.0.0"
88

99
import argparse
1010
from sys import stderr
@@ -38,7 +38,7 @@
3838
COUNTRY_LIST[COUNTRY_LIST.index(False)] = 'no'
3939

4040
SET_TEMPLATE = ('table inet blackhole {\n\tset ${set_name} {\n\t\ttype ${ip_ver}_addr\n'
41-
'\t\tflags interval\n\t\tauto-merge\n\t\telements = { ${ip_list} }\n\t}\n}')
41+
'\t\tflags interval\n\t\tauto-merge\n\t\telements = { ${ip_list} }\n\t}\n}').expandtabs()
4242

4343
IP_VER = []
4444
for ip_v in ['v4', 'v6']:
@@ -76,6 +76,7 @@ def stop():
7676
'''Stopping nft-blackhole'''
7777
run(['nft', 'delete', 'table', 'inet', 'blackhole'], check=False)
7878

79+
7980
def start():
8081
'''Starting nft-blackhole'''
8182
nft_template = open('/usr/share/nft-blackhole/nft-blackhole.template').read()
@@ -151,6 +152,7 @@ def whitelist_sets(reload=False):
151152
if WHITELIST[ip_ver]:
152153
run(['nft', '-f', '-'], input=nft_set.encode(), check=True)
153154

155+
154156
def blacklist_sets(reload=False):
155157
'''Create blacklist sets'''
156158
for ip_ver in IP_VER:
@@ -163,6 +165,7 @@ def blacklist_sets(reload=False):
163165
if ip_list:
164166
run(['nft', '-f', '-'], input=nft_set.encode(), check=True)
165167

168+
166169
def country_sets(reload=False):
167170
'''Create country sets'''
168171
for ip_ver in IP_VER:

nft-blackhole.template

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ table inet blackhole {
4545
ip6 saddr @blacklist-v6 counter ${block_policy}
4646
ip saddr @country-v4 counter ${country_policy}
4747
ip6 saddr @country-v6 counter ${country_policy}
48-
ip protocol icmp accept
4948
counter
5049
}
5150
}

0 commit comments

Comments
 (0)