From 86a3443b8d47ffd60e9bd1cd33721baa047a0c93 Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Mon, 4 Nov 2019 17:55:16 +0100 Subject: [PATCH] Handle exception if no Interface found --- pwnagotchi/plugins/default/bt-tether.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pwnagotchi/plugins/default/bt-tether.py b/pwnagotchi/plugins/default/bt-tether.py index ba19072..50cdd0d 100644 --- a/pwnagotchi/plugins/default/bt-tether.py +++ b/pwnagotchi/plugins/default/bt-tether.py @@ -519,14 +519,21 @@ class BTTether(plugins.Plugin): logging.debug('BT-TETHER: Try to create nap connection with %s ...', device.name) device.network, success = BTNap.nap(dev_remote) + interface = None if success: - if device.interface() is None: + try: + interface = device.interface() + except Exception: + logging.debug('BT-TETHER: Could not establish nap connection with %s', device.name) + continue + + if interface is None: ui.set('bluetooth', 'BE') logging.debug('BT-TETHER: Could not establish nap connection with %s', device.name) continue - logging.debug('BT-TETHER: Created interface (%s)', device.interface()) + logging.debug('BT-TETHER: Created interface (%s)', interface) ui.set('bluetooth', 'C') any_device_connected = True device.tries = 0 # reset tries @@ -535,7 +542,6 @@ class BTTether(plugins.Plugin): ui.set('bluetooth', 'NF') continue - interface = device.interface() addr = f"{device.ip}/{device.netmask}" gateway = ".".join(device.ip.split('.')[:-1] + ['1'])