Ensure tcpdump is installed before running capture command.
This commit is contained in:
parent
7badc83530
commit
8b7ad05ad6
@ -5,7 +5,7 @@ from iottb.definitions import *
|
||||
from iottb.models.capture_metadata_model import CaptureMetadata
|
||||
from iottb.models.device_metadata_model import DeviceMetadata, dir_contains_device_metadata
|
||||
from iottb.utils.capture_utils import get_capture_src_folder, make_capture_src_folder
|
||||
|
||||
from iottb.utils.tcpdump_utils import check_installed
|
||||
|
||||
def setup_capture_parser(subparsers):
|
||||
parser = subparsers.add_parser('sniff', help='Sniff packets with tcpdump')
|
||||
@ -74,6 +74,7 @@ def run_tcpdump(cmd):
|
||||
p = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
||||
if p.returncode != 0:
|
||||
print(f'Error running tcpdump {p.stderr}')
|
||||
# TODO add logging
|
||||
else:
|
||||
print(f'tcpdump run successfully\n: {p.stdout}')
|
||||
except KeyboardInterrupt:
|
||||
@ -81,6 +82,9 @@ def run_tcpdump(cmd):
|
||||
|
||||
|
||||
def handle_capture(args):
|
||||
if not check_installed():
|
||||
print('Please install tcpdump first')
|
||||
exit(ReturnCodes.ABORTED)
|
||||
assert args.device_root is not None, f'Device root directory is required'
|
||||
assert dir_contains_device_metadata(args.device_root), f'Device metadata file \'{args.device_root}\' does not exist'
|
||||
# get device metadata
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user