logger.log("JOBS", "ℹ️", "Checking if mmdb file is valid ...") with maxminddb.open_database("/opt/bunkerweb/tmp/asn.mmdb") as reader: pass # Check if file has changed file_hash = jobs.file_hash("/opt/bunkerweb/tmp/asn.mmdb") cache_hash = jobs.cache_hash("/opt/bunkerweb/cache/asn.mmdb") if file_hash == cache_hash: logger.log( "JOBS", "ℹ️", "New file is identical to cache file, reload is not needed") os._exit(0) # Move it to cache folder logger.log("JOBS", "ℹ️", "Moving mmdb file to cache ...") cached, err = jobs.cache_file("/opt/bunkerweb/tmp/asn.mmdb", "/opt/bunkerweb/cache/asn.mmdb", file_hash) if not cached: logger.log("JOBS", "❌", "Error while caching mmdb file : " + err) os._exit(2) # Success logger.log("JOBS", "ℹ️", "Downloaded new mmdb from " + mmdb_url) status = 1 except: status = 2 logger.log("JOBS", "❌", "Exception while running mmdb-asn.py :") print(traceback.format_exc()) sys.exit(status)
file_hash = jobs.file_hash("/opt/bunkerweb/tmp/whitelist/" + kind + ".list") cache_hash = jobs.cache_hash( "/opt/bunkerweb/cache/whitelist/" + kind + ".list") if file_hash == cache_hash: logger.log( "WHITELIST", "ℹ️", "New file " + kind + ".list is identical to cache file, reload is not needed" ) else: logger.log( "WHITELIST", "ℹ️", "New file " + kind + ".list is different than cache file, reload is needed") # Put file in cache cached, err = jobs.cache_file( "/opt/bunkerweb/tmp/whitelist/" + kind + ".list", "/opt/bunkerweb/cache/whitelist/" + kind + ".list", file_hash) if not cached: logger.log("WHITELIST", "❌", "Error while caching whitelist : " + err) status = 2 if status != 2: status = 1 except: status = 2 logger.log( "WHITELIST", "❌", "Exception while getting whitelist from " + url + " :") print(traceback.format_exc()) except:
"Exception while getting RealIP list from " + url + " :") print(traceback.format_exc()) f.close() # Check if file has changed file_hash = jobs.file_hash("/opt/bunkerweb/tmp/realip-combined.list") cache_hash = jobs.cache_hash("/opt/bunkerweb/cache/realip/combined.list") if file_hash == cache_hash: logger.log( "REALIP", "ℹ️", "New file is identical to cache file, reload is not needed") os._exit(0) # Put file in cache cached, err = jobs.cache_file("/opt/bunkerweb/tmp/realip-combined.list", "/opt/bunkerweb/cache/realip/combined.list", file_hash) if not cached: logger.log("REALIP", "❌", "Error while caching list : " + err) os._exit(2) logger.log("REALIP", "ℹ️", "Downloaded " + str(i) + " trusted IP/net") status = 1 except: status = 2 logger.log("REALIP", "❌", "Exception while running realip-download.py :") print(traceback.format_exc()) sys.exit(status)
with maxminddb.open_database("/opt/bunkerweb/tmp/country.mmdb") as reader: pass # Check if file has changed file_hash = jobs.file_hash("/opt/bunkerweb/tmp/country.mmdb") cache_hash = jobs.cache_hash("/opt/bunkerweb/cache/country.mmdb") if file_hash == cache_hash: logger.log( "JOBS", "ℹ️", "New file is identical to cache file, reload is not needed") os._exit(0) # Move it to cache folder logger.log("JOBS", "ℹ️", "Moving mmdb file to cache ...") cached, err = jobs.cache_file("/opt/bunkerweb/tmp/country.mmdb", "/opt/bunkerweb/cache/country.mmdb", file_hash) if not cached: logger.log("JOBS", "❌", "Error while caching mmdb file : " + err) os._exit(2) # Success logger.log("JOBS", "ℹ️", "Downloaded new mmdb from " + mmdb_url) status = 1 except: status = 2 logger.log("JOBS", "❌", "Exception while running mmdb-country.py :") print(traceback.format_exc())