text
stringlengths
1
93.6k
print("ERROR: Malformed settings.json, using defaults")
return
if validate_setting(imported, "Debug", bool):
SETTINGS["Debug"] = imported["Debug"]
else:
print('WARNING: "Debug" in settings is invalid, using default')
if validate_setting(imported, "Root_Check", bool):
SETTINGS["Root_Check"] = imported["Root_Check"]
else:
print('WARNING: "Root_Check" in settings is invalid, using default')
if validate_setting(imported, "Public", bool):
SETTINGS["Public"] = imported["Public"]
else:
print('WARNING: "Public" in settings is invalid, using default')
if validate_setting(imported, "DNS", bool):
SETTINGS["DNS"] = imported["DNS"]
if not SETTINGS["DNS"]:
print("WARNING: DNS is disabled, User's Manual method will not work")
else:
print('WARNING: "DNS" in settings is invalid, using default')
if validate_setting(imported, "HTTP", bool):
SETTINGS["HTTP"] = imported["HTTP"]
if not SETTINGS["HTTP"]:
print("WARNING: HTTP is disabled, no files will be served by this host")
else:
print('WARNING: "HTTP" in settings is invalid, using default')
if validate_setting(imported, "HTTPS", bool):
SETTINGS["HTTPS"] = imported["HTTPS"]
if not SETTINGS["HTTPS"]:
print("WARNING: HTTPS is disabled, no files will be served by this host")
else:
print('WARNING: "HTTPS" in settings is invalid, using default')
if not SETTINGS["DNS"] and not SETTINGS["HTTP"]: # TODO:
closer("ERROR: Neither the DNS or the HTTP servers are enabled")
if validate_setting(imported, "DNS_Interface_IP", str):
try:
ipaddress.ip_address(imported["DNS_Interface_IP"])
SETTINGS["DNS_Interface_IP"] = imported["DNS_Interface_IP"]
except ValueError:
if imported["DNS_Interface_IP"]:
print('WARNING: "DNS_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 "DNS_Interface_IP"')
if SETTINGS["DNS_Interface_IP"]:
print(f"INFO: \"DNS_Interface_IP\" set to {SETTINGS['DNS_Interface_IP']}")
SETTINGS["DNS_Interface_IP"] = temp_ip
else:
print('WARNING: "DNS_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 "DNS_Interface_IP"')
if SETTINGS["DNS_Interface_IP"]:
print(f"INFO: \"DNS_Interface_IP\" set to {SETTINGS['DNS_Interface_IP']}")
SETTINGS["DNS_Interface_IP"] = temp_ip
if validate_setting(imported, "DNS_Port", int) and imported["DNS_Port"] > 0 and imported["DNS_Port"] < 65535:
SETTINGS["DNS_Port"] = imported["DNS_Port"]
if SETTINGS["DNS_Port"] != 53:
print("WARNING: DNS is not port 53, this is for VERY advanced users only")
else:
print('WARNING: "DNS_Port" in settings is invalid, using default')
if validate_setting(imported, "HTTP_Interface_IP", str):
try:
ipaddress.ip_address(imported["HTTP_Interface_IP"])
SETTINGS["HTTP_Interface_IP"] = imported["HTTP_Interface_IP"]
except ValueError:
if imported["HTTP_Interface_IP"]:
print('WARNING: "HTTP_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 "HTTP_Interface_IP"')
if SETTINGS["HTTP_Interface_IP"]:
print(f"INFO: \"HTTP_Interface_IP\" set to {SETTINGS['HTTP_Interface_IP']}")
SETTINGS["HTTP_Interface_IP"] = temp_ip
else:
print('WARNING: "HTTP_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 "HTTP_Interface_IP"')