Merge pull request #496 from dadav/fix/bt-tet-defaults

Fix bt-tether config
This commit is contained in:
evilsocket 2019-11-02 12:13:08 +01:00 committed by GitHub
commit ace61836e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 9 deletions

View File

@ -73,6 +73,7 @@ main:
enabled: false # if you want to use this, set ui.display.video.address to 0.0.0.0
devices:
android-phone:
enabled: false
search_order: 1 # search for this first
mac: ~ # mac of your bluetooth device
ip: '192.168.44.44' # ip from which your pwnagotchi should be reachable
@ -83,9 +84,10 @@ main:
share_internet: false
priority: 1 # low routing priority; ios (prio: 999) would win here
ios-phone:
enabled: false
search_order: 2 # search for this second
mac: ~ # mac of your bluetooth device
ip: '172.20.10.2' # ip from which your pwnagotchi should be reachable
ip: '172.20.10.6' # ip from which your pwnagotchi should be reachable
netmask: 24
interval: 5 # check every 5 minutes for device
scantime: 20

View File

@ -426,29 +426,30 @@ class BTTether(plugins.Plugin):
self.devices = dict()
def on_loaded(self):
# new config
if 'devices' in self.options:
for device, options in self.options['devices'].items():
for device_opt in ['priority', 'scantime', 'search_order', 'max_tries', 'share_internet', 'mac', 'ip', 'netmask', 'interval']:
for device_opt in ['enabled', 'priority', 'scantime', 'search_order', '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.", device_opt, device)
break
else:
if options['enabled']:
self.devices[device] = Device(name=device, **options)
elif 'mac' in self.options:
# legacy
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)
return
self.devices['default'] = Device(name='default', **self.options)
else:
logging.error("BT-TET: No configuration found")
return
self.devices['legacy'] = Device(name='legacy', **self.options)
if not self.devices:
logging.error("BT-TET: No valid devices found")
return
# ensure bluetooth is running
bt_unit = SystemdUnitWrapper('bluetooth.service')
if not bt_unit.is_active():