Please linters
This commit is contained in:
parent
5f7a0a4abd
commit
610ccec47a
@ -1,3 +1,6 @@
|
|||||||
|
'''
|
||||||
|
Lowlevel routines for calling the pf binary with passwordless sudo
|
||||||
|
'''
|
||||||
import logging
|
import logging
|
||||||
from subprocess import run
|
from subprocess import run
|
||||||
|
|
||||||
@ -12,6 +15,9 @@ _PFCTL_TABLE_PAT = r'''\s+(?P<addr>\S+)\n
|
|||||||
\s+Out/Pass:\s+\[\s+Packets:\s+(?P<out_pckt_pass>\d+)\s+Bytes:\s+(?P<out_bytes_pass>\d+)\s+\]'''
|
\s+Out/Pass:\s+\[\s+Packets:\s+(?P<out_pckt_pass>\d+)\s+Bytes:\s+(?P<out_bytes_pass>\d+)\s+\]'''
|
||||||
|
|
||||||
def pfctl_cfg_read(anchor):
|
def pfctl_cfg_read(anchor):
|
||||||
|
'''
|
||||||
|
Read pf rules stored under a certain anchor
|
||||||
|
'''
|
||||||
cmd = [_SUDO, _PFCTL, '-a', anchor, '-sr']
|
cmd = [_SUDO, _PFCTL, '-a', anchor, '-sr']
|
||||||
logging.info('Running %s', cmd)
|
logging.info('Running %s', cmd)
|
||||||
|
|
||||||
@ -22,6 +28,9 @@ def pfctl_cfg_read(anchor):
|
|||||||
|
|
||||||
|
|
||||||
def pfctl_cfg_write(anchor, cfg):
|
def pfctl_cfg_write(anchor, cfg):
|
||||||
|
'''
|
||||||
|
Write pf rules under a certain anchor
|
||||||
|
'''
|
||||||
cmd = [_SUDO, _PFCTL, '-a', anchor, '-f-']
|
cmd = [_SUDO, _PFCTL, '-a', anchor, '-f-']
|
||||||
logging.info('Running %s', cmd)
|
logging.info('Running %s', cmd)
|
||||||
logging.info('Config %s', cfg)
|
logging.info('Config %s', cfg)
|
||||||
@ -36,6 +45,9 @@ def pfctl_cfg_write(anchor, cfg):
|
|||||||
|
|
||||||
|
|
||||||
def pfctl_table_op(anchor, **kwargs):
|
def pfctl_table_op(anchor, **kwargs):
|
||||||
|
'''
|
||||||
|
pf table operation
|
||||||
|
'''
|
||||||
table = kwargs['table']
|
table = kwargs['table']
|
||||||
operation = kwargs['operation']
|
operation = kwargs['operation']
|
||||||
value = kwargs['value'] if 'value' in kwargs else None
|
value = kwargs['value'] if 'value' in kwargs else None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user