diff options
author | Petr <30545094+pasabanov@users.noreply.github.com> | 2024-07-17 12:00:42 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-17 11:00:42 +0200 |
commit | 0a3a82680d6171a005fa944916ef551b4c3aafa7 (patch) | |
tree | 8b26a4681b6aaac1626a07473e58d151cd44a72a /utils/hostname2list.py | |
parent | 989dde1a40f9303f0e6331141f6433fd1b4ef5d9 (diff) |
python: reformatted, fixed bugs (#2504)
Diffstat (limited to 'utils/hostname2list.py')
-rwxr-xr-x | utils/hostname2list.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/utils/hostname2list.py b/utils/hostname2list.py index d466b015d..beb078a1f 100755 --- a/utils/hostname2list.py +++ b/utils/hostname2list.py @@ -1,19 +1,17 @@ #!/usr/bin/env python3 import sys -import socket, struct # This scripts is used to create "hostname/sni -> protocols" lists. if len(sys.argv) < 6: print("Usage: {} <file> <name> <protocol> <category> <breed>".format(sys.argv[0])) - sys.exit (1) + sys.exit(1) name = sys.argv[2] proto = sys.argv[3] category = sys.argv[4] breed = sys.argv[5] - print("""/* * * This file is generated automatically and part of nDPI @@ -37,23 +35,23 @@ print("""/* """) -print("static ndpi_protocol_match "+proto.lower()+"_hostname_list[] = {") +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 != ""): + if line != "": lines += 1 x = line.split("/") - if(len(x) == 2): + if len(x) == 2: host = x[0] else: host = line - if(host != ""): + if host != "": print(' { ' + f'"{host}", "{name}", {proto}, {category}, {breed}, NDPI_PROTOCOL_DEFAULT_LEVEL' + ' },') print(" /* End */") |