From 1d255b577d5bd0b43e09ff9befe3cf385b2c2dc3 Mon Sep 17 00:00:00 2001 From: Ben Lebherz Date: Wed, 13 Nov 2019 15:37:20 +0100 Subject: [PATCH] add gateway option to bt-tether --- pwnagotchi/plugins/default/bt-tether.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pwnagotchi/plugins/default/bt-tether.py b/pwnagotchi/plugins/default/bt-tether.py index 23af2ae..6acaf27 100644 --- a/pwnagotchi/plugins/default/bt-tether.py +++ b/pwnagotchi/plugins/default/bt-tether.py @@ -1,14 +1,15 @@ -import os -import time -import re import logging +import os import subprocess +import time + import dbus + +import pwnagotchi.plugins as plugins +import pwnagotchi.ui.fonts as fonts from pwnagotchi.ui.components import LabeledValue from pwnagotchi.ui.view import BLACK -import pwnagotchi.ui.fonts as fonts from pwnagotchi.utils import StatusFile -import pwnagotchi.plugins as plugins class BTError(Exception): @@ -382,7 +383,7 @@ class IfaceWrapper: class Device: - def __init__(self, name, share_internet, mac, ip, netmask, interval, priority=10, scantime=15, search_order=0, max_tries=0, **kwargs): + def __init__(self, name, share_internet, mac, ip, netmask, interval, gateway=None, priority=10, scantime=15, search_order=0, max_tries=0, **kwargs): self.name = name self.status = StatusFile(f'/root/.bt-tether-{name}') self.status.update() @@ -394,6 +395,7 @@ class Device: self.share_internet = share_internet self.ip = ip self.netmask = netmask + self.gateway = gateway self.interval = interval self.mac = mac self.scantime = scantime @@ -543,7 +545,10 @@ class BTTether(plugins.Plugin): continue addr = f"{device.ip}/{device.netmask}" - gateway = ".".join(device.ip.split('.')[:-1] + ['1']) + if device.gateway: + gateway = device.gateway + else: + gateway = ".".join(device.ip.split('.')[:-1] + ['1']) wrapped_interface = IfaceWrapper(interface) logging.debug('BT-TETHER: Add ip to %s', interface)