Skip to content

Commit

Permalink
add support for any DoH provider; closes #254; closes #256
Browse files Browse the repository at this point in the history
  • Loading branch information
thatmattlove committed Jun 1, 2024
1 parent bfcae89 commit aab4ada
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 4 additions & 3 deletions docs/pages/configuration/config/web-ui.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ 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.name` | String | cloudflare | If `cloudflare` or `google` are provided, no URL is necessary. |
| `dns_provider.url` | String | `https://cloudflare-dns.com/dns-query` | Provide a custom DNS over HTTPS URL if you'd like to use your own resolver. |

### Logo

Expand Down
8 changes: 7 additions & 1 deletion hyperglass/models/config/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,19 @@ class Theme(HyperglassModel):
class DnsOverHttps(HyperglassModel):
"""Validation model for DNS over HTTPS resolution."""

name: str = Field(default="cloudflare", pattern=DOH_PROVIDERS_PATTERN)
name: str = "cloudflare"
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 = data.get("url", DNS_OVER_HTTPS["cloudflare"])
if url not in DNS_OVER_HTTPS.values():
return {
"name": "custom",
"url": url,
}
url = DNS_OVER_HTTPS[name]
return {
"name": name,
Expand Down

0 comments on commit aab4ada

Please sign in to comment.