aboutsummaryrefslogtreecommitdiff
path: root/utils/hostname2list.py
diff options
context:
space:
mode:
authorToni <matzeton@googlemail.com>2023-05-28 12:45:44 +0200
committerGitHub <noreply@github.com>2023-05-28 12:45:44 +0200
commit6da3474203fc2ff5981f6c73f7ad02fa81138166 (patch)
treebe8d74931f416143291ffaa1707cfa2f2103c82b /utils/hostname2list.py
parentb11e6a453b0b870957663d214d9f1a0fdf49af90 (diff)
Improved helper scripts. (#1986)
* added additional (more restrictive) checks Signed-off-by: lns <matzeton@googlemail.com>
Diffstat (limited to 'utils/hostname2list.py')
-rwxr-xr-xutils/hostname2list.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/utils/hostname2list.py b/utils/hostname2list.py
index af0a5c349..d466b015d 100755
--- a/utils/hostname2list.py
+++ b/utils/hostname2list.py
@@ -39,11 +39,13 @@ print("""/*
print("static ndpi_protocol_match "+proto.lower()+"_hostname_list[] = {")
+lines = 0
with open(sys.argv[1]) as fp:
for cnt, line in enumerate(fp):
line = line.rstrip()
if(line != ""):
+ lines += 1
x = line.split("/")
if(len(x) == 2):
@@ -57,3 +59,7 @@ with open(sys.argv[1]) as fp:
print(" /* End */")
print(" { NULL, NULL, NDPI_PROTOCOL_UNKNOWN, NDPI_PROTOCOL_CATEGORY_UNSPECIFIED, NDPI_PROTOCOL_SAFE, NDPI_PROTOCOL_DEFAULT_LEVEL }")
print("};")
+
+if lines == 0:
+ sys.stderr.write(f'File {sys.argv[1]} is empty.\n')
+ sys.exit(1)