diff --git a/docs/pages/configuration/config/web-ui.mdx b/docs/pages/configuration/config/web-ui.mdx index a9b8cd21..e0a82a7a 100644 --- a/docs/pages/configuration/config/web-ui.mdx +++ b/docs/pages/configuration/config/web-ui.mdx @@ -15,9 +15,9 @@ hyperglass provides extensive customization options for the look and feel of the [DNS over HTTPS](https://www.rfc-editor.org/rfc/rfc8484) is used to look up an FQDN query target from the perspective of the user's browser. -| Parameter | Type | Default Value | Description | -| :------------------ | :----- | :------------ | :-------------------------------------- | -| `dns_provider.name` | String | cloudflare | Cloudflare or Google DNS are supported. | +| Parameter | Type | Default Value | Description | +| :------------------ | :----- | :-------------------------------------- | :-------------------------------------- | +| `dns_provider.url` | String | https://cloudflare-dns.com/dns-query | HTTP url of your dns provider | ### Logo diff --git a/hyperglass/constants.py b/hyperglass/constants.py index c0907169..6e171ab4 100644 --- a/hyperglass/constants.py +++ b/hyperglass/constants.py @@ -25,11 +25,6 @@ STATUS_CODE_MAP = {"warning": 400, "error": 400, "danger": 500} -DNS_OVER_HTTPS = { - "google": "https://dns.google/resolve", - "cloudflare": "https://cloudflare-dns.com/dns-query", -} - PARSED_RESPONSE_FIELDS = ( ("Prefix", "prefix", "left"), ("Active", "active", None), diff --git a/hyperglass/models/config/web.py b/hyperglass/models/config/web.py index f2a8a35f..58528aa1 100644 --- a/hyperglass/models/config/web.py +++ b/hyperglass/models/config/web.py @@ -5,19 +5,18 @@ from pathlib import Path # Third Party -from pydantic import Field, HttpUrl, FilePath, ValidationInfo, field_validator, model_validator +from pydantic import Field, HttpUrl, FilePath, ValidationInfo, field_validator from pydantic_extra_types.color import Color # Project from hyperglass.defaults import DEFAULT_HELP, DEFAULT_TERMS -from hyperglass.constants import DNS_OVER_HTTPS, FUNC_COLOR_MAP +from hyperglass.constants import FUNC_COLOR_MAP # Local from ..main import HyperglassModel from .opengraph import OpenGraph DEFAULT_IMAGES = Path(__file__).parent.parent.parent / "images" -DOH_PROVIDERS_PATTERN = "|".join(DNS_OVER_HTTPS.keys()) PERCENTAGE_PATTERN = r"^([1-9][0-9]?|100)\%?$" Percentage = Field(pattern=r"^([1-9][0-9]?|100)\%$") @@ -186,18 +185,7 @@ class Theme(HyperglassModel): class DnsOverHttps(HyperglassModel): """Validation model for DNS over HTTPS resolution.""" - name: str = Field(default="cloudflare", pattern=DOH_PROVIDERS_PATTERN) - url: str = "" - - @model_validator(mode="before") - def validate_dns(cls, data: "DnsOverHttps") -> t.Dict[str, str]: - """Assign url field to model based on selected provider.""" - name = data.get("name", "cloudflare") - url = DNS_OVER_HTTPS[name] - return { - "name": name, - "url": url, - } + url: HttpUrl = "https://cloudflare-dns.com/dns-query" class HighlightPattern(HyperglassModel): diff --git a/hyperglass/models/main.py b/hyperglass/models/main.py index 672dd2c0..56a5582a 100644 --- a/hyperglass/models/main.py +++ b/hyperglass/models/main.py @@ -62,7 +62,7 @@ def convert_paths(self, value: t.Type[PathTypeT]) -> PathTypeT: *(p for p in value.parts if p not in Settings.original_app_path.parts) ) - if isinstance(value, str) and str(Settings.original_app_path) in value: + if isinstance(value, str) and value.startswith(str(Settings.original_app_path)): if Settings.container: path = Path(value) return str( diff --git a/hyperglass/ui/types/config.ts b/hyperglass/ui/types/config.ts index 82b89121..3dc839b7 100644 --- a/hyperglass/ui/types/config.ts +++ b/hyperglass/ui/types/config.ts @@ -88,7 +88,7 @@ interface _Highlight { interface _Web { credit: _Credit; - dns_provider: { name: string; url: string }; + dns_provider: { url: string }; links: _Link[]; menus: _Menu[]; greeting: _Greeting;