1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00

add flags_pretty

This commit is contained in:
Kelly Brazil
2020-05-29 12:55:16 -07:00
parent 6ce18de84c
commit f07b7eaa47

View File

@ -101,7 +101,7 @@ import jc.parsers.universal
class info():
version = '1.0'
version = '1.1'
description = 'route command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -132,6 +132,9 @@ def process(proc_data):
"gateway": string,
"genmask": string,
"flags": string,
"flags_pretty": [
string,
]
"metric": integer,
"ref": integer,
"use": integer,
@ -152,6 +155,29 @@ def process(proc_data):
except (ValueError):
entry[key] = None
# add flags_pretty
# Flag mapping from https://www.man7.org/linux/man-pages/man8/route.8.html
if 'flags' in entry:
flag_map = {
'U': 'UP',
'H': 'HOST',
'G': 'GATEWAY',
'R': 'REINSTATE',
'D': 'DYNAMIC',
'M': 'MODIFIED',
'A': 'ADDRCONF',
'C': 'CACHE',
'!': 'REJECT'
}
pretty_flags = []
for flag in entry['flags']:
if flag in flag_map:
pretty_flags.append(flag_map[flag])
entry['flags_pretty'] = pretty_flags
return proc_data