Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: DoH ability to use custom servers #256

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 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,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

Expand Down
5 changes: 0 additions & 5 deletions hyperglass/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
18 changes: 3 additions & 15 deletions hyperglass/models/config/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)\%$")
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion hyperglass/ui/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading