mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-21 00:19:42 +02:00
fix for scenarios where the default port range didn't always display, or overrode existing port ranges.
This commit is contained in:
BIN
jc/man/jc.1.gz
BIN
jc/man/jc.1.gz
Binary file not shown.
@ -303,6 +303,8 @@ def _parse_to_from(linedata, direction, rule_obj=None):
|
|||||||
linedata = linedata_list[0]
|
linedata = linedata_list[0]
|
||||||
else:
|
else:
|
||||||
rule_obj[direction + '_transport'] = 'any'
|
rule_obj[direction + '_transport'] = 'any'
|
||||||
|
else:
|
||||||
|
rule_obj[direction + '_transport'] = 'any'
|
||||||
|
|
||||||
# pull out ipv4 or ipv6 addresses
|
# pull out ipv4 or ipv6 addresses
|
||||||
linedata_list = linedata.split()
|
linedata_list = linedata.split()
|
||||||
@ -364,17 +366,9 @@ def _parse_to_from(linedata, direction, rule_obj=None):
|
|||||||
rule_obj[direction + '_ip_prefix'] = '0'
|
rule_obj[direction + '_ip_prefix'] = '0'
|
||||||
|
|
||||||
# finally set default ports if no ports exist and there should be some
|
# finally set default ports if no ports exist and there should be some
|
||||||
set_default = False
|
|
||||||
if direction + '_transport' in rule_obj:
|
if direction + '_transport' in rule_obj:
|
||||||
if rule_obj[direction + '_transport'] in ['tcp', 'udp', 'any']:
|
if rule_obj[direction + '_transport'] in ['tcp', 'udp', 'any']:
|
||||||
if not port_list and not port_ranges:
|
if not port_list and not port_ranges:
|
||||||
set_default = True
|
|
||||||
|
|
||||||
else:
|
|
||||||
rule_obj[direction + '_transport'] = 'any'
|
|
||||||
set_default = True
|
|
||||||
|
|
||||||
if set_default:
|
|
||||||
rule_obj[direction + '_port_ranges'] = [
|
rule_obj[direction + '_port_ranges'] = [
|
||||||
{
|
{
|
||||||
'start': '0',
|
'start': '0',
|
||||||
|
BIN
man/jc.1.gz
BIN
man/jc.1.gz
Binary file not shown.
2
tests/fixtures/generic/ufw-numbered.json
vendored
2
tests/fixtures/generic/ufw-numbered.json
vendored
File diff suppressed because one or more lines are too long
2
tests/fixtures/generic/ufw.json
vendored
2
tests/fixtures/generic/ufw.json
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user