diff --git a/pwnagotchi/grid.py b/pwnagotchi/grid.py index 60589747..daef21ad 100644 --- a/pwnagotchi/grid.py +++ b/pwnagotchi/grid.py @@ -12,9 +12,9 @@ API_ADDRESS = "http://127.0.0.1:8666/api/v1" def is_connected(): try: - socket.create_connection(("www.google.com", 80)) + socket.create_connection(("api.pwnagotchi.ai", 443), timeout=30) return True - except OSError: + except: pass return False @@ -22,11 +22,11 @@ def is_connected(): def call(path, obj=None): url = '%s%s' % (API_ADDRESS, path) if obj is None: - r = requests.get(url, headers=None) + r = requests.get(url, headers=None, timeout=(30.0, 60.0)) elif isinstance(obj, dict): - r = requests.post(url, headers=None, json=obj) + r = requests.post(url, headers=None, json=obj, timeout=(30.0, 60.0)) else: - r = requests.post(url, headers=None, data=obj) + r = requests.post(url, headers=None, data=obj, timeout=(30.0, 60.0)) if r.status_code != 200: raise Exception("(status %d) %s" % (r.status_code, r.text)) diff --git a/pwnagotchi/plugins/__init__.py b/pwnagotchi/plugins/__init__.py index a183294d..44c27879 100644 --- a/pwnagotchi/plugins/__init__.py +++ b/pwnagotchi/plugins/__init__.py @@ -1,5 +1,6 @@ import os import glob +import _thread import importlib, importlib.util import logging @@ -31,7 +32,7 @@ def one(plugin_name, event_name, *args, **kwargs): callback = getattr(plugin, cb_name, None) if callback is not None and callable(callback): try: - callback(*args, **kwargs) + _thread.start_new_thread(callback, (*args, *kwargs)) except Exception as e: logging.error("error while running %s.%s : %s" % (plugin_name, cb_name, e)) logging.error(e, exc_info=True)