mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
Version 2.3.6
Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com> Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>
This commit is contained in:
@ -4,7 +4,6 @@ import time
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
from pwnagotchi._version import __version__
|
from pwnagotchi._version import __version__
|
||||||
|
|
||||||
_name = None
|
_name = None
|
||||||
|
@ -1 +1 @@
|
|||||||
__version__ = '2.3.5'
|
__version__ = '2.3.6'
|
||||||
|
@ -394,7 +394,6 @@ class Agent(Client, Automata, AsyncAdvertiser, AsyncTrainer):
|
|||||||
# start a thread and pass in the mainloop
|
# start a thread and pass in the mainloop
|
||||||
_thread.start_new_thread(self._event_poller, (asyncio.get_event_loop(),))
|
_thread.start_new_thread(self._event_poller, (asyncio.get_event_loop(),))
|
||||||
|
|
||||||
|
|
||||||
def is_module_running(self, module):
|
def is_module_running(self, module):
|
||||||
s = self.session()
|
s = self.session()
|
||||||
for m in s['modules']:
|
for m in s['modules']:
|
||||||
|
@ -23,7 +23,8 @@ def decode(r, verbose_errors=True):
|
|||||||
|
|
||||||
|
|
||||||
class Client(object):
|
class Client(object):
|
||||||
def __init__(self, hostname='localhost', scheme='http', port=8081, username='user', password='pass'):
|
def __init__(self, hostname='localhost', scheme='http', port=8081, username='user', password='pass',
|
||||||
|
max_websockets=5):
|
||||||
self.hostname = hostname
|
self.hostname = hostname
|
||||||
self.scheme = scheme
|
self.scheme = scheme
|
||||||
self.port = port
|
self.port = port
|
||||||
@ -32,6 +33,8 @@ class Client(object):
|
|||||||
self.url = "%s://%s:%d/api" % (scheme, hostname, port)
|
self.url = "%s://%s:%d/api" % (scheme, hostname, port)
|
||||||
self.websocket = "ws://%s:%s@%s:%d/api" % (username, password, hostname, port)
|
self.websocket = "ws://%s:%s@%s:%d/api" % (username, password, hostname, port)
|
||||||
self.auth = HTTPBasicAuth(username, password)
|
self.auth = HTTPBasicAuth(username, password)
|
||||||
|
self.max_websockets = max_websockets
|
||||||
|
self.websocket_semaphore = asyncio.Semaphore(max_websockets)
|
||||||
|
|
||||||
# session takes optional argument to pull a sub-dictionary
|
# session takes optional argument to pull a sub-dictionary
|
||||||
# ex.: "session/wifi", "session/ble"
|
# ex.: "session/wifi", "session/ble"
|
||||||
@ -41,24 +44,25 @@ class Client(object):
|
|||||||
|
|
||||||
@backoff.on_exception(backoff.expo, requests.exceptions.ConnectionError, max_tries=10)
|
@backoff.on_exception(backoff.expo, requests.exceptions.ConnectionError, max_tries=10)
|
||||||
async def start_websocket(self, consumer):
|
async def start_websocket(self, consumer):
|
||||||
s = "%s/events" % self.websocket
|
async with self.websocket_semaphore:
|
||||||
while True:
|
s = "%s/events" % self.websocket
|
||||||
try:
|
while True:
|
||||||
async with websockets.connect(s, ping_interval=60, ping_timeout=90) as ws:
|
try:
|
||||||
async for msg in ws:
|
async with websockets.connect(s, ping_interval=60, ping_timeout=90) as ws:
|
||||||
try:
|
async for msg in ws:
|
||||||
await consumer(msg)
|
try:
|
||||||
except Exception as ex:
|
await consumer(msg)
|
||||||
logging.debug("Error while parsing event (%s)", ex)
|
except Exception as ex:
|
||||||
except websockets.exceptions.ConnectionClosedError:
|
logging.debug("Error while parsing event (%s)", ex)
|
||||||
logging.debug("Lost websocket connection. Reconnecting...")
|
except websockets.ConnectionClosedError:
|
||||||
await asyncio.sleep(1) # Sleep for x seconds before reconnecting
|
logging.debug("Lost websocket connection. Reconnecting...")
|
||||||
except websockets.exceptions.WebSocketException as wex:
|
await asyncio.sleep(5) # Sleep for x seconds before reconnecting
|
||||||
logging.debug("Websocket exception (%s)", wex)
|
except websockets.WebSocketException as wex:
|
||||||
await asyncio.sleep(1) # Sleep for x seconds before reconnecting
|
logging.debug("Websocket exception (%s)", wex)
|
||||||
except Exception as e:
|
await asyncio.sleep(5) # Sleep for x seconds before reconnecting
|
||||||
logging.exception("Other error while opening websocket (%s) with parameter %s", e, s)
|
except Exception as e:
|
||||||
await asyncio.sleep(1) # Sleep for x seconds before reconnecting
|
logging.exception("Other error while opening websocket (%s) with parameter %s", e, s)
|
||||||
|
await asyncio.sleep(5) # Sleep for x seconds before reconnecting
|
||||||
|
|
||||||
@backoff.on_exception(backoff.expo, requests.exceptions.ConnectionError, max_tries=10)
|
@backoff.on_exception(backoff.expo, requests.exceptions.ConnectionError, max_tries=10)
|
||||||
def run(self, command, verbose_errors=True):
|
def run(self, command, verbose_errors=True):
|
||||||
|
@ -40,8 +40,8 @@ main.plugins.pisugar2.enabled = false
|
|||||||
main.plugins.pisugar2.shutdown = 5
|
main.plugins.pisugar2.shutdown = 5
|
||||||
main.plugins.pisugar2.sync_rtc_on_boot = false
|
main.plugins.pisugar2.sync_rtc_on_boot = false
|
||||||
|
|
||||||
main.plugins.grid.enabled = false
|
main.plugins.grid.enabled = true
|
||||||
main.plugins.grid.report = false
|
main.plugins.grid.report = true
|
||||||
main.plugins.grid.exclude = [
|
main.plugins.grid.exclude = [
|
||||||
"YourHomeNetworkHere"
|
"YourHomeNetworkHere"
|
||||||
]
|
]
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
import socket
|
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
@ -84,7 +83,8 @@ def update_data(last_session):
|
|||||||
},
|
},
|
||||||
'uname': subprocess.getoutput("uname -a"),
|
'uname': subprocess.getoutput("uname -a"),
|
||||||
'brain': brain,
|
'brain': brain,
|
||||||
'version': pwnagotchi.__version__
|
'version': pwnagotchi.__version__,
|
||||||
|
'build': "Pwnagotchi-Torch by Jayofelony"
|
||||||
}
|
}
|
||||||
|
|
||||||
logging.debug("updating grid data: %s" % data)
|
logging.debug("updating grid data: %s" % data)
|
||||||
|
Reference in New Issue
Block a user