mirror of
https://github.com/SamTherapy/dnscrypt.git
synced 2024-12-22 00:50:42 +00:00
Fix compatibility with the old dnscrypt-proxy version
This commit is contained in:
parent
27514f9fe6
commit
b7fd5d3700
2 changed files with 10 additions and 2 deletions
|
@ -47,4 +47,6 @@ func generate(args GenerateArgs) {
|
|||
|
||||
log.Info("Configuration has been written to %s", args.Out)
|
||||
log.Info("Go to https://dnscrypt.info/stamps to generate an SDNS stamp")
|
||||
log.Info("You can run a DNSCrypt server using the following command:")
|
||||
log.Info("dnscrypt server -c %s -f 8.8.8.8", args.Out)
|
||||
}
|
||||
|
|
10
server.go
10
server.go
|
@ -3,6 +3,7 @@ package dnscrypt
|
|||
import (
|
||||
"context"
|
||||
"net"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
@ -158,7 +159,7 @@ func (s *Server) isStarted() bool {
|
|||
return started
|
||||
}
|
||||
|
||||
// serveDNS serves DNS response
|
||||
// serveDNS serves a DNS response
|
||||
func (s *Server) serveDNS(rw ResponseWriter, r *dns.Msg) error {
|
||||
if r == nil || len(r.Question) != 1 || r.Response {
|
||||
return ErrInvalidQuery
|
||||
|
@ -240,7 +241,8 @@ func (s *Server) handleHandshake(b []byte, certTxt string) ([]byte, error) {
|
|||
|
||||
q := m.Question[0]
|
||||
providerName := dns.Fqdn(s.ProviderName)
|
||||
if q.Qtype != dns.TypeTXT || q.Name != providerName {
|
||||
qName := strings.ToLower(q.Name) // important, may be random case
|
||||
if q.Qtype != dns.TypeTXT || qName != providerName {
|
||||
// Invalid provider name or type, doing nothing
|
||||
return nil, ErrInvalidQuery
|
||||
}
|
||||
|
@ -259,6 +261,10 @@ func (s *Server) handleHandshake(b []byte, certTxt string) ([]byte, error) {
|
|||
},
|
||||
}
|
||||
reply.Answer = append(reply.Answer, txt)
|
||||
|
||||
// These bits are important for the old dnscrypt-proxy versions
|
||||
reply.Authoritative = true
|
||||
reply.RecursionAvailable = true
|
||||
return reply.Pack()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue