mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
@ -1,10 +1,9 @@
|
|||||||
# Handles the commandline stuff
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
import glob
|
import glob
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
import socket # <-- Added for DNS check
|
||||||
from fnmatch import fnmatch
|
from fnmatch import fnmatch
|
||||||
from pwnagotchi.utils import download_file, unzip, save_config, parse_version, md5
|
from pwnagotchi.utils import download_file, unzip, save_config, parse_version, md5
|
||||||
from pwnagotchi.plugins import default_path
|
from pwnagotchi.plugins import default_path
|
||||||
@ -164,8 +163,8 @@ def upgrade(args, config, pattern='*'):
|
|||||||
installed_version = _extract_version(filename)
|
installed_version = _extract_version(filename)
|
||||||
|
|
||||||
if installed_version and available_version:
|
if installed_version and available_version:
|
||||||
if available_version <= installed_version:
|
if available_version <= installed_version:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -348,12 +347,34 @@ def _analyse_dir(path):
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
def _check_internet():
|
||||||
|
"""
|
||||||
|
Simple DNS check to verify that we can resolve a common hostname.
|
||||||
|
Returns True if DNS resolution succeeds, False otherwise.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
socket.gethostbyname('google.com')
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def update(config):
|
def update(config):
|
||||||
"""
|
"""
|
||||||
Updates the database
|
Updates the database
|
||||||
"""
|
"""
|
||||||
global SAVE_DIR
|
global SAVE_DIR
|
||||||
|
|
||||||
|
if not _check_internet():
|
||||||
|
logging.error("No internet connection or DNS not working. Please follow these instructions:")
|
||||||
|
logging.error("https://github.com/jayofelony/pwnagotchi/wiki/Step-2-Connecting")
|
||||||
|
print("No internet/DNS. Please follow these instructions:")
|
||||||
|
print("https://github.com/jayofelony/pwnagotchi/wiki/Step-2-Connecting")
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
logging.info("Internet detected - Please run sudo pwnagotchi plugins list")
|
||||||
|
print("Internet detected - Please run sudo pwnagotchi plugins list")
|
||||||
|
|
||||||
urls = config['main']['custom_plugin_repos']
|
urls = config['main']['custom_plugin_repos']
|
||||||
if not urls:
|
if not urls:
|
||||||
logging.info('No plugin repositories configured.')
|
logging.info('No plugin repositories configured.')
|
||||||
@ -393,3 +414,4 @@ def update(config):
|
|||||||
logging.error('Error while updating plugins: %s', ex)
|
logging.error('Error while updating plugins: %s', ex)
|
||||||
rc = 1
|
rc = 1
|
||||||
return rc
|
return rc
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user