From 8a8b161da461c8e340f7a37178df3e1ea882fad9 Mon Sep 17 00:00:00 2001 From: vyzo Date: Mon, 12 Apr 2021 13:53:19 +0300 Subject: [PATCH 1/4] go-ipfs-config: add custom DNS Resolver configuration --- config/config.go | 1 + config/dns.go | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 config/dns.go diff --git a/config/config.go b/config/config.go index 7d44316ab..d9b060e64 100644 --- a/config/config.go +++ b/config/config.go @@ -28,6 +28,7 @@ type Config struct { AutoNAT AutoNATConfig Pubsub PubsubConfig Peering Peering + DNS DNSConfig Provider Provider Reprovider Reprovider diff --git a/config/dns.go b/config/dns.go new file mode 100644 index 000000000..5f18a9c69 --- /dev/null +++ b/config/dns.go @@ -0,0 +1,10 @@ +package config + +// DNSConfig specifies custom resolvers using DoH +type DNSConfig struct { + // DefaultResolver, if present, is a URL for the default DoH resolver. + // If empty, DNS resolution will use the system resolver. + DefaultResolver string `json:",omitempty"` + // CustomResolvers is a map of domains to URLs for custom DoH resolution. + CustomResolvers map[string]string `json:",omitempty"` +} From 28553d793ad0e52129102d094b249a0893ee96c5 Mon Sep 17 00:00:00 2001 From: vyzo Date: Tue, 13 Apr 2021 17:32:15 +0300 Subject: [PATCH 2/4] go-ipfs-config: simplify DNS config --- config/dns.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/config/dns.go b/config/dns.go index 5f18a9c69..ae390d91c 100644 --- a/config/dns.go +++ b/config/dns.go @@ -1,10 +1,7 @@ package config -// DNSConfig specifies custom resolvers using DoH +// DNSConfig specifies DNS resolution rules using custom resolvers type DNSConfig struct { - // DefaultResolver, if present, is a URL for the default DoH resolver. - // If empty, DNS resolution will use the system resolver. - DefaultResolver string `json:",omitempty"` - // CustomResolvers is a map of domains to URLs for custom DoH resolution. - CustomResolvers map[string]string `json:",omitempty"` + // CustomResolvers is a map of FQDNs to URLs for custom DNS resolution. + Resolvers map[string]string } From f264de41392227173da5ec44d929831d37d60161 Mon Sep 17 00:00:00 2001 From: vyzo Date: Tue, 13 Apr 2021 17:53:47 +0300 Subject: [PATCH 3/4] go-ipfs-config: update comments Co-authored-by: Marcin Rataj --- config/dns.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/config/dns.go b/config/dns.go index ae390d91c..aadea8904 100644 --- a/config/dns.go +++ b/config/dns.go @@ -2,6 +2,14 @@ package config // DNSConfig specifies DNS resolution rules using custom resolvers type DNSConfig struct { - // CustomResolvers is a map of FQDNs to URLs for custom DNS resolution. + // Resolvers is a map of FQDNs to URLs for custom DNS resolution. + // URLs starting with `https://` indicate DoH endpoints. + // Support for other resolver types can be added in the future. + // https://en.wikipedia.org/wiki/Fully_qualified_domain_name + // https://en.wikipedia.org/wiki/DNS_over_HTTPS + // + // Example: + // - Custom resolver for ENS: `eth.` → `https://eth.link/dns-query` + // - Override the default OS resolver: `.` → `https://doh.applied-privacy.net/query` Resolvers map[string]string } From c932e6b7008901e2dea8e8dd4e4bafa9fb2fe77d Mon Sep 17 00:00:00 2001 From: vyzo Date: Wed, 14 Apr 2021 18:46:35 +0300 Subject: [PATCH 4/4] go-ipfs-config: add default empty config for DNS, rename struct from DNSConfig to DNS --- config/config.go | 2 +- config/dns.go | 10 +++++----- config/init.go | 3 +++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/config/config.go b/config/config.go index d9b060e64..b593e7a7e 100644 --- a/config/config.go +++ b/config/config.go @@ -28,7 +28,7 @@ type Config struct { AutoNAT AutoNATConfig Pubsub PubsubConfig Peering Peering - DNS DNSConfig + DNS DNS Provider Provider Reprovider Reprovider diff --git a/config/dns.go b/config/dns.go index aadea8904..5c4e62da0 100644 --- a/config/dns.go +++ b/config/dns.go @@ -1,13 +1,13 @@ package config -// DNSConfig specifies DNS resolution rules using custom resolvers -type DNSConfig struct { - // Resolvers is a map of FQDNs to URLs for custom DNS resolution. +// DNS specifies DNS resolution rules using custom resolvers +type DNS struct { + // Resolvers is a map of FQDNs to URLs for custom DNS resolution. // URLs starting with `https://` indicate DoH endpoints. // Support for other resolver types can be added in the future. // https://en.wikipedia.org/wiki/Fully_qualified_domain_name - // https://en.wikipedia.org/wiki/DNS_over_HTTPS - // + // https://en.wikipedia.org/wiki/DNS_over_HTTPS + // // Example: // - Custom resolver for ENS: `eth.` → `https://eth.link/dns-query` // - Override the default OS resolver: `.` → `https://doh.applied-privacy.net/query` diff --git a/config/init.go b/config/init.go index ecda3047d..56a99884f 100644 --- a/config/init.go +++ b/config/init.go @@ -89,6 +89,9 @@ func InitWithIdentity(identity Identity) (*Config, error) { Pinning: Pinning{ RemoteServices: map[string]RemotePinningService{}, }, + DNS: DNS{ + Resolvers: map[string]string{}, + }, } return conf, nil