Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

add custom DNS Resolver configuration #126

Merged
merged 4 commits into from
Apr 15, 2021
Merged

add custom DNS Resolver configuration #126

merged 4 commits into from
Apr 15, 2021

Conversation

vyzo
Copy link
Contributor

@vyzo vyzo commented Apr 12, 2021

No description provided.

dns.go Outdated
Comment on lines 7 to 9
DefaultResolver string `json:",omitempty"`
// CustomResolvers is a map of domains to URLs for custom DoH resolution.
CustomResolvers map[string]string `json:",omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a default resolver? I'd assume that we could have a single "." entry in a Resolvers map, right?

Also, let's briefly (very briefly) document the format (i.e., URL? Multiaddr?).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: some documentation in code can happen here, but the user facing docs live in go-ipfs https://github.com/ipfs/go-ipfs/blob/master/docs/config.md

Copy link
Member

@lidel lidel Apr 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on removing DefaultResolver and renaming CustomResolvers to simple Resolvers

Don't skip in JSON

We should avoid json:",omitempty" here.
It is better for discoverability to have empty DNS.Resolvers (ok to have {}) – that is what we already do in Pinning.RemoteServices.

Values

We could support multiaddrs and URLs, but for DoH URL will be what people want to copy&paste while setting it up, so ok with saying this needs to be https:// URL with DoH endpoint.

Keys

I was thinking about interop with wider DNS ecosystem here and suggest we don't invent any new notation with * as I initially syggested, but follow the existing DNS convention of using the explicit FQDN syntax in our config files.

To illustrate, a custom DoH-only config for multiple resolvers could look like this::

  "DNS": {
    "Resolvers": {
      "eth.": "https://different-ens.example.net/dns-query",
      "crypto.": "https://unstoppablesomething.example.com/dns-query",
      "libre.": "https://ns1.iriseden.fr/dns-query", 
      ".": "https://doh-ch.blahdns.com:4443/dns-query"
    }
  }

Idea here is to closely follow the format of zone files, which should make things easier to understand. (The DNS root is unnamed, expressed as the empty label terminated by the dot.)

We should enforce keys are explicit FQDNs by validating them with dns.IsFqdn – removes surface for DNS ambiguity.

Copy link
Contributor Author

@vyzo vyzo Apr 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok fair enough; we can call the field just Resolvers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will also make some minor changes in the madns Resolver to normalize to fqdns.

@vyzo
Copy link
Contributor Author

vyzo commented Apr 12, 2021 via email

@vyzo
Copy link
Contributor Author

vyzo commented Apr 12, 2021 via email

@Stebalien
Copy link
Member

Both SGTM.

Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some asks in comment inline.

Rationale: I'd like to avoid inventing custom syntax in keys and concepts, if we can.
DNS ecosystem and tooling already has pre-existing concepts like FQDN and configuration in form of Zone files, we should follow what exists where possible to improve onboarding.

dns.go Outdated
Comment on lines 7 to 9
DefaultResolver string `json:",omitempty"`
// CustomResolvers is a map of domains to URLs for custom DoH resolution.
CustomResolvers map[string]string `json:",omitempty"`
Copy link
Member

@lidel lidel Apr 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on removing DefaultResolver and renaming CustomResolvers to simple Resolvers

Don't skip in JSON

We should avoid json:",omitempty" here.
It is better for discoverability to have empty DNS.Resolvers (ok to have {}) – that is what we already do in Pinning.RemoteServices.

Values

We could support multiaddrs and URLs, but for DoH URL will be what people want to copy&paste while setting it up, so ok with saying this needs to be https:// URL with DoH endpoint.

Keys

I was thinking about interop with wider DNS ecosystem here and suggest we don't invent any new notation with * as I initially syggested, but follow the existing DNS convention of using the explicit FQDN syntax in our config files.

To illustrate, a custom DoH-only config for multiple resolvers could look like this::

  "DNS": {
    "Resolvers": {
      "eth.": "https://different-ens.example.net/dns-query",
      "crypto.": "https://unstoppablesomething.example.com/dns-query",
      "libre.": "https://ns1.iriseden.fr/dns-query", 
      ".": "https://doh-ch.blahdns.com:4443/dns-query"
    }
  }

Idea here is to closely follow the format of zone files, which should make things easier to understand. (The DNS root is unnamed, expressed as the empty label terminated by the dot.)

We should enforce keys are explicit FQDNs by validating them with dns.IsFqdn – removes surface for DNS ambiguity.

@vyzo vyzo requested a review from lidel April 13, 2021 14:33
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but please update the comment.
It is a good opportunity to explain the purpose of this field to a drive-by contributor
(devs don't read docs, but they do read comments :))

dns.go Outdated Show resolved Hide resolved
@vyzo vyzo merged commit d75a8c6 into master Apr 15, 2021
@vyzo vyzo deleted the feat/custom-resolver branch April 15, 2021 09:17
@aschmahmann aschmahmann mentioned this pull request May 14, 2021
71 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants