mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
edit bettercap.py
Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>
This commit is contained in:
@ -79,27 +79,26 @@ class Client(object):
|
|||||||
try:
|
try:
|
||||||
await consumer(msg)
|
await consumer(msg)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logging.debug("error while parsing event (%s)", ex)
|
logging.debug("[bettercap] error while parsing event (%s)", ex)
|
||||||
except websockets.ConnectionClosedError:
|
except websockets.ConnectionClosedError:
|
||||||
try:
|
try:
|
||||||
pong = await ws.ping()
|
pong = await ws.ping()
|
||||||
await asyncio.wait_for(pong, timeout=ping_timeout)
|
await asyncio.wait_for(pong, timeout=ping_timeout)
|
||||||
logging.warning('ping OK, keeping connection alive...')
|
logging.warning('[bettercap] ping OK, keeping connection alive...')
|
||||||
continue
|
continue
|
||||||
except:
|
except:
|
||||||
sleep_time = min_sleep + max_sleep*random.random()
|
sleep_time = min_sleep + max_sleep*random.random()
|
||||||
logging.warning('ping error - retrying connection in {} sec'.format(sleep_time))
|
logging.warning('[bettercap] ping error - retrying connection in {} sec'.format(sleep_time))
|
||||||
await asyncio.sleep(sleep_time)
|
await asyncio.sleep(sleep_time)
|
||||||
break
|
break
|
||||||
except ConnectionRefusedError:
|
except ConnectionRefusedError:
|
||||||
sleep_time = min_sleep + max_sleep*random.random()
|
sleep_time = min_sleep + max_sleep*random.random()
|
||||||
logging.warning('nobody seems to be listening at the bettercap endpoint...')
|
logging.warning('[bettercap] nobody seems to be listening at the bettercap endpoint...')
|
||||||
logging.warning('retrying connection in {} sec'.format(sleep_time))
|
logging.warning('[bettercap] retrying connection in {} sec'.format(sleep_time))
|
||||||
await asyncio.sleep(sleep_time)
|
await asyncio.sleep(sleep_time)
|
||||||
continue
|
continue
|
||||||
except OSError:
|
except OSError:
|
||||||
sleep_time = min_sleep + max_sleep*random.random()
|
logging.warning('[bettercap] connection to the bettercap endpoint failed...')
|
||||||
logging.warning('connection to the bettercap endpoint failed...')
|
|
||||||
pwnagotchi.reboot()
|
pwnagotchi.reboot()
|
||||||
|
|
||||||
def run(self, command, verbose_errors=True):
|
def run(self, command, verbose_errors=True):
|
||||||
@ -108,8 +107,8 @@ class Client(object):
|
|||||||
r = requests.post("%s/session" % self.url, auth=self.auth, json={'cmd': command})
|
r = requests.post("%s/session" % self.url, auth=self.auth, json={'cmd': command})
|
||||||
except requests.exceptions.ConnectionError as e:
|
except requests.exceptions.ConnectionError as e:
|
||||||
sleep_time = min_sleep + max_sleep*random.random()
|
sleep_time = min_sleep + max_sleep*random.random()
|
||||||
logging.warning("can't run my request... connection to the bettercap endpoint failed...")
|
logging.warning("[bettercap] can't run my request... connection to the bettercap endpoint failed...")
|
||||||
logging.warning('retrying run in {} sec'.format(sleep_time))
|
logging.warning('[bettercap] retrying run in {} sec'.format(sleep_time))
|
||||||
sleep(sleep_time)
|
sleep(sleep_time)
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
Reference in New Issue
Block a user