add gateway option to bt-tether

This commit is contained in:
Ben Lebherz 2019-11-13 15:37:20 +01:00
parent 1ff14c05a9
commit 1d255b577d

View File

@ -1,14 +1,15 @@
import os
import time
import re
import logging import logging
import os
import subprocess import subprocess
import time
import dbus import dbus
import pwnagotchi.plugins as plugins
import pwnagotchi.ui.fonts as fonts
from pwnagotchi.ui.components import LabeledValue from pwnagotchi.ui.components import LabeledValue
from pwnagotchi.ui.view import BLACK from pwnagotchi.ui.view import BLACK
import pwnagotchi.ui.fonts as fonts
from pwnagotchi.utils import StatusFile from pwnagotchi.utils import StatusFile
import pwnagotchi.plugins as plugins
class BTError(Exception): class BTError(Exception):
@ -382,7 +383,7 @@ class IfaceWrapper:
class Device: 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.name = name
self.status = StatusFile(f'/root/.bt-tether-{name}') self.status = StatusFile(f'/root/.bt-tether-{name}')
self.status.update() self.status.update()
@ -394,6 +395,7 @@ class Device:
self.share_internet = share_internet self.share_internet = share_internet
self.ip = ip self.ip = ip
self.netmask = netmask self.netmask = netmask
self.gateway = gateway
self.interval = interval self.interval = interval
self.mac = mac self.mac = mac
self.scantime = scantime self.scantime = scantime
@ -543,6 +545,9 @@ class BTTether(plugins.Plugin):
continue continue
addr = f"{device.ip}/{device.netmask}" addr = f"{device.ip}/{device.netmask}"
if device.gateway:
gateway = device.gateway
else:
gateway = ".".join(device.ip.split('.')[:-1] + ['1']) gateway = ".".join(device.ip.split('.')[:-1] + ['1'])
wrapped_interface = IfaceWrapper(interface) wrapped_interface = IfaceWrapper(interface)