From 5366b2b898beb51630d77907d2b0651501afbca6 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Thu, 27 Aug 2015 18:09:32 +0000 Subject: [PATCH] (configd/legacy) align result of "filter list osfp" --- src/opnsense/scripts/filter/list_osfp.py | 10 +++++++++- .../service/conf/actions.d/actions_filter.conf | 2 +- src/www/firewall_rules_edit.php | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/opnsense/scripts/filter/list_osfp.py b/src/opnsense/scripts/filter/list_osfp.py index d0c386739..8b7397098 100755 --- a/src/opnsense/scripts/filter/list_osfp.py +++ b/src/opnsense/scripts/filter/list_osfp.py @@ -31,6 +31,7 @@ import tempfile import subprocess import os +import sys import ujson result=[] @@ -42,4 +43,11 @@ with tempfile.NamedTemporaryFile() as output_stream: for line in data.split('\n')[2:]: result.append(line.replace('\t',' ').strip()) -print(ujson.dumps(result)) +# handle command line argument (type selection) +if len(sys.argv) > 1 and sys.argv[1] == 'json': + print(ujson.dumps(result)) +else: + # output plain + print ('------------------------- OS fingerprints -------------------------') + for ostype in result: + print (ostype) diff --git a/src/opnsense/service/conf/actions.d/actions_filter.conf b/src/opnsense/service/conf/actions.d/actions_filter.conf index c543fb51f..ac30a91ac 100644 --- a/src/opnsense/service/conf/actions.d/actions_filter.conf +++ b/src/opnsense/service/conf/actions.d/actions_filter.conf @@ -18,7 +18,7 @@ message:refresh url table aliasses [list.osfp] command:/usr/local/opnsense/scripts/filter/list_osfp.py -parameters: +parameters: %s type:script_output message:request osfp diff --git a/src/www/firewall_rules_edit.php b/src/www/firewall_rules_edit.php index 400834c35..608e94c61 100644 --- a/src/www/firewall_rules_edit.php +++ b/src/www/firewall_rules_edit.php @@ -36,7 +36,7 @@ require_once("interfaces.inc"); $tcpflags = array("syn", "ack", "fin", "rst", "psh", "urg", "ece", "cwr"); /* OS types, request from backend */ -$ostypes = json_decode(configd_run('filter list osfp')); +$ostypes = json_decode(configd_run('filter list osfp json')); /** * build array with interface options for this form