Add support for DNS stamps and for DNSCrypt servers
This allows connections to DoH servers using their stamp, and adds support for DNSCrypt servers by the way.
This commit is contained in:
parent
48fd5bb792
commit
6d2eae4f58
9 changed files with 139 additions and 12 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"net"
|
||||
"net/url"
|
||||
|
||||
"github.com/ameshkov/dnsstamps"
|
||||
"github.com/mr-karan/doggo/pkg/config"
|
||||
"github.com/mr-karan/doggo/pkg/models"
|
||||
)
|
||||
|
@ -60,6 +61,23 @@ func initNameserver(n string) (models.Nameserver, error) {
|
|||
if err != nil {
|
||||
return ns, err
|
||||
}
|
||||
if u.Scheme == "sdns" {
|
||||
stamp, err := dnsstamps.NewServerStampFromString(n)
|
||||
if err != nil {
|
||||
return ns, err
|
||||
}
|
||||
switch stamp.Proto {
|
||||
case dnsstamps.StampProtoTypeDoH:
|
||||
ns.Type = models.DOHResolver
|
||||
address := url.URL{Scheme: "https", Host: stamp.ProviderName, Path: stamp.Path}
|
||||
ns.Address = address.String()
|
||||
case dnsstamps.StampProtoTypeDNSCrypt:
|
||||
ns.Type = models.DNSCryptResolver
|
||||
ns.Address = n
|
||||
default:
|
||||
return ns, fmt.Errorf("unsupported protocol: %v", stamp.Proto.String())
|
||||
}
|
||||
}
|
||||
if u.Scheme == "https" {
|
||||
ns.Type = models.DOHResolver
|
||||
ns.Address = u.String()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue