Merge pull request from dadav/fix/bt-tet-loaded-msg

More bt-tether fixes
This commit is contained in:
evilsocket 2019-11-05 10:48:19 +01:00 committed by GitHub
commit bdf585afe5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -434,7 +434,7 @@ class BTTether(plugins.Plugin):
'max_tries', 'share_internet', 'mac', 'ip',
'netmask', 'interval']:
if device_opt not in options or (device_opt in options and options[device_opt] is None):
logging.error("BT-TET: Pleace specify the %s for device %s.",
logging.error("BT-TETHER: Please specify the %s for device %s.",
device_opt, device)
break
else:
@ -445,22 +445,23 @@ class BTTether(plugins.Plugin):
if 'mac' in self.options:
for opt in ['share_internet', 'mac', 'ip', 'netmask', 'interval']:
if opt not in self.options or (opt in self.options and self.options[opt] is None):
logging.error("BT-TET: Please specify the %s in your config.yml.", opt)
logging.error("BT-TETHER: Please specify the %s in your config.yml.", opt)
return
self.devices['legacy'] = Device(name='legacy', **self.options)
if not self.devices:
logging.error("BT-TET: No valid devices found")
logging.error("BT-TETHER: No valid devices found")
return
# ensure bluetooth is running
bt_unit = SystemdUnitWrapper('bluetooth.service')
if not bt_unit.is_active():
if not bt_unit.start():
logging.error("BT-TET: Can't start bluetooth.service")
logging.error("BT-TETHER: Can't start bluetooth.service")
return
logging.info("BT-TETHER: Sussessfully loaded ...")
self.ready = True
def on_ui_setup(self, ui):
@ -518,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
@ -534,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'])