text
stringlengths
1
93.6k
if SETTINGS["HTTP_Interface_IP"]:
print(f"INFO: \"HTTP_Interface_IP\" set to {SETTINGS['HTTP_Interface_IP']}")
SETTINGS["HTTP_Interface_IP"] = temp_ip
if validate_setting(imported, "HTTP_Port", int) and imported["HTTP_Port"] >= 1 and imported["HTTP_Port"] <= 65535:
SETTINGS["HTTP_Port"] = imported["HTTP_Port"]
if SETTINGS["HTTP_Port"] != 80:
print("WARNING: HTTP is not port 80, User's Manual method will not work")
else:
print('WARNING: "HTTP_Port" in settings is invalid, using default')
if validate_setting(imported, "HTTPS_Interface_IP", str):
try:
ipaddress.ip_address(imported["HTTPS_Interface_IP"])
SETTINGS["HTTPS_Interface_IP"] = imported["HTTPS_Interface_IP"]
except ValueError:
if imported["HTTPS_Interface_IP"]:
print('WARNING: "HTTPS_Interface_IP" in settings is not a valid IP, attempting to set default')
temp_ip = get_lan()
if not temp_ip:
closer('ERROR: Could not determine default for "HTTPS_Interface_IP"')
if SETTINGS["HTTPS_Interface_IP"]:
print(f"INFO: \"HTTPS_Interface_IP\" set to {SETTINGS['HTTPS_Interface_IP']}")
SETTINGS["HTTPS_Interface_IP"] = temp_ip
else:
print('WARNING: "HTTPS_Interface_IP" in settings is not a valid IP, attempting to set default')
temp_ip = get_lan()
if not temp_ip:
closer('ERROR: Could not determine default for "HTTPS_Interface_IP"')
if SETTINGS["HTTPS_Interface_IP"]:
print(f"INFO: \"HTTPS_Interface_IP\" set to {SETTINGS['HTTPS_Interface_IP']}")
SETTINGS["HTTPS_Interface_IP"] = temp_ip
if validate_setting(imported, "HTTPS_Port", int) and imported["HTTPS_Port"] >= 1 and imported["HTTPS_Port"] <= 65535:
SETTINGS["HTTPS_Port"] = imported["HTTPS_Port"]
if SETTINGS["HTTPS_Port"] != 443:
print("WARNING: HTTPS is not port 443, User's Manual method will not work")
else:
print('WARNING: "HTTPS_Port" in settings is invalid, using default')
if validate_setting(imported, "Compression_Level", int) and imported["Compression_Level"] >= 0 and imported["Compression_Level"] <= 9:
SETTINGS["Compression_Level"] = imported["Compression_Level"]
else:
print('WARNING: "Compression_Level" in settings is invalid, using default')
if SETTINGS["DNS_Port"] == SETTINGS["HTTP_Port"] and SETTINGS["DNS_Interface_IP"] == SETTINGS["HTTP_Interface_IP"]:
closer("ERROR: DNS and HTTP cannot share the same port on the same interface")
if validate_setting(imported, "UA_Check", bool):
SETTINGS["UA_Check"] = imported["UA_Check"]
else:
print('WARNING: "UA_Check" in settings is invalid, using default')
if validate_setting(imported, "Theme", str) and os.path.isfile(os.path.join(THEME_LOC, imported["Theme"], "index.html")):
SETTINGS["Theme"] = imported["Theme"]
elif os.path.isfile(os.path.join(THEME_LOC, "Default", "index.html")):
closer('ERROR: "Theme" in settings is invalid, and default is missing')
else:
print('WARNING: "Theme" in settings is invalid, using default')
if (validate_setting(imported, "Auto_Payload", str) and os.path.isfile(os.path.join(PAYLOAD_LOC, imported["Auto_Payload"]))) or not imported["Auto_Payload"]:
SETTINGS["Auto_Payload"] = imported["Auto_Payload"]
else:
print('WARNING: "Auto_Payload" in settings is invalid, using default')
if validate_setting(imported, "Payload_Timeout", int) and imported["Payload_Timeout"] > 0 and imported["Payload_Timeout"] < 100:
SETTINGS["Payload_Timeout"] = imported["Payload_Timeout"]
else:
print('WARNING: "Payload_Timeout" in settings is invalid, using default')
if validate_setting(imported, "DNS_Rules", dict):
if validate_setting(imported["DNS_Rules"], "Redirect_IP", str):
try:
ipaddress.ip_address(imported["DNS_Rules"]["Redirect_IP"])
SETTINGS["DNS_Rules"]["Redirect_IP"] = imported["DNS_Rules"]["Redirect_IP"]
except ValueError:
if SETTINGS["DNS_Rules"]["Redirect_IP"]:
print(f"WARNING: \"DNS_Rules['Redirect_IP']\" in settings is invalid, using the set \"HTTP_Interface_IP\": {SETTINGS['HTTP_Interface_IP']}")
SETTINGS["DNS_Rules"]["Redirect_IP"] = SETTINGS["HTTP_Interface_IP"]
if SETTINGS["HTTP_Interface_IP"] != SETTINGS["DNS_Rules"]["Redirect_IP"]:
print("WARNING: DNS is not redirecting directly to this hosts HTTP server")
if validate_setting(imported["DNS_Rules"], "Redirect", list):
i = 1
temp_array = []
for entry in imported["DNS_Rules"]["Redirect"]:
if validate_setting(entry, "", str):
temp_array.append(entry)
else:
print(f"WARNING: Invalid entry in \"DNS_Rules['Redirect']\" settings, discarding rule # {i}")
i += 1
SETTINGS["DNS_Rules"]["Redirect"] = imported["DNS_Rules"]["Redirect"]