diff --git a/renderer.py b/renderer.py index f89480b..7b5be28 100644 --- a/renderer.py +++ b/renderer.py @@ -63,132 +63,107 @@ def render_overview(): if key["reusable"] and not key_expired: usable_keys_count += 1 if not key["reusable"] and not key["used"] and not key_expired: usable_keys_count += 1 - overview_content = """ -
-
-
- Stats -

- - - - - - -
Machines """+ str(machines_count) +"""
Users """+ str(user_count) +"""
Usable PreAuth Keys """+ str(usable_keys_count) +"""
Enabled/Total Routes """+ str(enabled_routes) +"""/"""+str(total_routes) +"""
Enabled/Total Exits """+ str(exits_enabled_count) +"""/"""+str(exits_count) +"""
-

-
-
-
- """ - # Overview of general configs from the YAML - general_content = """ -
-
-
- General -

- - - - - - -
IP Prefixes """ - if "ip_prefixes" in config_yaml: general_content += str(config_yaml["ip_prefixes"]) - else: general_content += "N/A" - general_content +="""
Server URL """ - if "server_url" in config_yaml: general_content += str(config_yaml["server_url"]) - else: general_content += "N/A" - general_content +="""
Updates Disabled? """ - if "disable_check_updates" in config_yaml: general_content += str(config_yaml["disable_check_updates"]) - else: general_content += "N/A" - general_content +="""
Ephemeral Node Timeout """ - if "ephemeral_node_inactivity_timeout" in config_yaml: general_content += str(config_yaml["ephemeral_node_inactivity_timeout"]) - else: general_content += "N/A" - general_content +="""
Node Update Check Interval """ - if "node_update_check_interval" in config_yaml: general_content += str(config_yaml["node_update_check_interval"]) - else: general_content += "N/A" - general_content +="""
-

-
-
-
- """ + # General Content variables: + ip_prefixes, server_url, disable_check_updates, ephemeral_node_inactivity_timeout, node_update_check_interval = "N/A" + if "ip_prefixes" in config_yaml: ip_prefixes = str(config_yaml["ip_prefixes"]) + if "server_url" in config_yaml: server_url = str(config_yaml["server_url"]) + if "disable_check_updates" in config_yaml: disable_check_updates = str(config_yaml["disable_check_updates"]) + if "ephemeral_node_inactivity_timeout" in config_yaml: ephemeral_node_inactivity_timeout = str(config_yaml["ephemeral_node_inactivity_timeout"]) + if "node_update_check_interval" in config_yaml: node_update_check_interval = str(config_yaml["node_update_check_interval"]) - # Whether OIDC is configured - oidc_content = "" + # OIDC Content variables: + issuer, client_id, scope, use_expiry_from_token, expiry = "N/A" if "oidc" in config_yaml: - oidc_content = """ -
-
-
- Headscale OIDC -

- - - - - - -
Issuer """ - if "issuer" in config_yaml["oidc"] : oidc_content += str(config_yaml["oidc"]["issuer"]) - else: oidc_content += "N/A" - oidc_content += """
Client ID """ - if "client_id" in config_yaml["oidc"] : oidc_content += str(config_yaml["oidc"]["client_id"]) - else: oidc_content += "N/A" - oidc_content += """
Scope """ - if "scope" in config_yaml["oidc"] : oidc_content += str(config_yaml["oidc"]["scope"]) - else: oidc_content += "N/A" - oidc_content += """
Token Expiry """ - if "use_expiry_from_token" in config_yaml["oidc"] : oidc_content += str(config_yaml["oidc"]["use_expiry_from_token"]) - else: oidc_content += "N/A" - oidc_content += """
Expiry """ - if "expiry" in config_yaml["oidc"] : oidc_content += str(config_yaml["oidc"]["expiry"]) - else: oidc_content += "N/A" - oidc_content += """
-

-
-
-
- """ + if "issuer" in config_yaml["oidc"] : issuer = str(config_yaml["oidc"]["issuer"]) + if "client_id" in config_yaml["oidc"] : client_id = str(config_yaml["oidc"]["client_id"]) + if "scope" in config_yaml["oidc"] : scope = str(config_yaml["oidc"]["scope"]) + if "use_expiry_from_token" in config_yaml["oidc"] : use_expiry_from_token = str(config_yaml["oidc"]["use_expiry_from_token"]) + if "expiry" in config_yaml["oidc"] : expiry = str(config_yaml["oidc"]["expiry"]) - derp_content = "" + # Embedded DERP server information. if "derp" in config_yaml: if "server" in config_yaml["derp"] and config_yaml["derp"]["server"]["enabled"] == "True": - derp_content = """ -
-
-
- Built-in DERP -

- - - - headscale-webui/renderer.py - - -
Enabled """ - if "enabled" in config_yaml["derp"]["server"] : derp_content+= str(config_yaml["derp"]["server"]["enabled"]) - else: derp_content+= "N/A" - derp_content+= """
Region ID """ - if "region_id" in config_yaml["derp"]["server"] : derp_content+= str(config_yaml["derp"]["server"]["region_id"]) - else: derp_content+= "N/A" - derp_content+= """
Region Code """ - if "region_code" in config_yaml["derp"]["server"] : derp_content+= str(config_yaml["derp"]["server"]["region_code"]) - else: derp_content+= "N/A" - derp_content+= """
Region Name """ - if "region_name" in config_yaml["derp"]["server"] : derp_content+= str(config_yaml["derp"]["server"]["region_name"]) - else: derp_content+= "N/A" - derp_content+= """
STUN Address """ - if "stun_listen_addr" in config_yaml["derp"]["server"]: derp_content+= str(config_yaml["derp"]["server"]["stun_listen_addr"]) - else: derp_content+= "N/A" - derp_content+= """
-

-
-
-
- """ + if "enabled" in config_yaml["derp"]["server"]: enabled = str(config_yaml["derp"]["server"]["enabled"]) + if "region_id" in config_yaml["derp"]["server"]: region_id = str(config_yaml["derp"]["server"]["region_id"]) + if "region_code" in config_yaml["derp"]["server"]: region_code = str(config_yaml["derp"]["server"]["region_code"]) + if "region_name" in config_yaml["derp"]["server"]: region_name = str(config_yaml["derp"]["server"]["region_name"]) + if "stun_listen_addr" in config_yaml["derp"]["server"]: stun_listen_addr = str(config_yaml["derp"]["server"]["stun_listen_addr"]) + + if "dns_config" in config_yaml: + if "nameservers" in config_yaml["dns_config"]: nameservers = str(config_yaml["dns_config"]["nameservers"]) + if "magic_dns" in config_yaml["dns_config"]: magic_dns = str(config_yaml["dns_config"]["magic_dns"]) + if "domains" in config_yaml["dns_config"]: domains = str(config_yaml["dns_config"]["domains"]) + if "base_domain" in config_yaml["dns_config"]: base_domain = str(config_yaml["dns_config"]["base_domain"]) + + # Start putting the content together + overview_content = """ + + """ + general_content = """ + + """ + oidc_content = """ + + """ + derp_content = """ + + """ + oidc_content = """ + + """ + dns_content = """ + + """ + + # Remove content that isn't needed: + # Remove OIDC if it isn't available: + if "oidc" not in config_yaml: oidc_content = "" + # Remove DERP if it isn't available or isn't enabled + if "derp" not in config_yaml: oidc_content = "" + if "derp" in config_yaml: + if config_file["derp"]["enabled"] == "False": + oidc_content = "" # TODO: # Whether there are custom DERP servers @@ -196,37 +171,6 @@ def render_overview(): # Whether the built-in DERP server is enabled # The IP prefixes # The DNS config - if "dns_config" in config_yaml: - dns_content = """ -
-
-
- DNS -

- - - - - - -
Nameservers """ - if "nameservers" in config_yaml["dns_config"]: dns_content += str(config_yaml["dns_config"]["nameservers"]) - else: dns_content += "N/A" - dns_content += """
MagicDNS """ - if "magic_dns" in config_yaml["dns_config"]: dns_content += str(config_yaml["dns_config"]["magic_dns"]) - else: dns_content += "N/A" - dns_content += """
Domains """ - if "domains" in config_yaml["dns_config"]: dns_content += str(config_yaml["dns_config"]["domains"]) - else: dns_content += "N/A" - dns_content += """
Base Domain """ - if "base_domain" in config_yaml["dns_config"]: dns_content += str(config_yaml["dns_config"]["base_domain"]) - else: dns_content += "N/A" - dns_content += """

-

-
-
-
- """ if config_yaml["derp"]["paths"]: pass # # open the path: # derp_file =