diff options
author | lns <matzeton@googlemail.com> | 2023-05-20 17:16:31 +0200 |
---|---|---|
committer | lns <matzeton@googlemail.com> | 2023-05-20 17:16:31 +0200 |
commit | fac703d878e45b227b5e938849466fe58d180253 (patch) | |
tree | 8b993735fce657515bc38dec824af460101b3443 /utils/hostname2list.py | |
parent | 5e8f93c2d157b4af818bc80b2737ee17e920e8e9 (diff) |
Improved helper scripts to be more restrictive.improved/helper-scripts
Signed-off-by: lns <matzeton@googlemail.com>
Diffstat (limited to 'utils/hostname2list.py')
-rwxr-xr-x | utils/hostname2list.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/utils/hostname2list.py b/utils/hostname2list.py index af0a5c349..e3facfdf0 100755 --- a/utils/hostname2list.py +++ b/utils/hostname2list.py @@ -39,8 +39,10 @@ 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): + lines += 1 line = line.rstrip() if(line != ""): @@ -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) |