1
0
mirror of https://git.burble.com/burble.dn42/bird-lg.git synced 2024-05-12 03:55:36 +00:00

Merge pull request #2 from Tchekda/regex

Fixed COMBINED_UNWANTED_NAMES empty issue
This commit is contained in:
Simon Marsh
2020-02-09 17:01:10 +00:00
committed by GitHub

11
lg.py
View File

@ -235,11 +235,12 @@ def whois():
SUMMARY_UNWANTED_PROTOS = ["Kernel", "Static", "Device", "BFD", "Direct", "RPKI"]
# Array of regular expressions to match against protocol names,
# and filter them from the summary view
SUMMARY_UNWANTED_NAMES = [ ]
# combine the unwanted names to a single regex
COMBINED_UNWANTED_NAMES = '(?:%s)' % '|'.join(SUMMARY_UNWANTED_NAMES)
SUMMARY_UNWANTED_NAMES = []
COMBINED_UNWANTED_NAMES = None
if len(SUMMARY_UNWANTED_NAMES) > 0 : # If regex list is not empty
# combine the unwanted names to a single regex
COMBINED_UNWANTED_NAMES = '(?:%s)' % '|'.join(SUMMARY_UNWANTED_NAMES)
@app.route("/summary/<hosts>")
@app.route("/summary/<hosts>/<proto>")
@ -272,7 +273,7 @@ def summary(hosts, proto="ipv4"):
if (
len(split) >= 5 and
split[1] not in SUMMARY_UNWANTED_PROTOS and
not re.match(COMBINED_UNWANTED_NAMES, split[0])
(COMBINED_UNWANTED_NAMES is None or not re.match(COMBINED_UNWANTED_NAMES, split[0])) # If the list is empty or doesn't match the protocol name
):
props = dict()
props["name"] = split[0]