Merge pull request #601 from benleb/add-gateway-option

add gateway option to bt-tether
This commit is contained in:
evilsocket 2019-11-14 11:04:30 +01:00 committed by GitHub
commit 3efa3a935a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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,7 +545,10 @@ class BTTether(plugins.Plugin):
continue continue
addr = f"{device.ip}/{device.netmask}" 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) wrapped_interface = IfaceWrapper(interface)
logging.debug('BT-TETHER: Add ip to %s', interface) logging.debug('BT-TETHER: Add ip to %s', interface)