mirror of
https://github.com/xvzc/SpoofDPI.git
synced 2024-12-22 14:26:31 +00:00
enhance logging for dns
This commit is contained in:
parent
378b980301
commit
10a3860fad
10
dns/dns.go
10
dns/dns.go
@ -4,8 +4,8 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"regexp"
|
||||
"time"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/likexian/doh"
|
||||
dohDns "github.com/likexian/doh/dns"
|
||||
@ -53,12 +53,12 @@ func (d *DnsResolver) Lookup(domain string) (string, error) {
|
||||
|
||||
for _, answer := range response.Answer {
|
||||
if record, ok := answer.(*dns.A); ok {
|
||||
log.Debug("[DNS] resolved dns for "+domain+": ", record.A.String())
|
||||
log.Debug("[DNS] resolved ", domain, ": ", record.A.String())
|
||||
return record.A.String(), nil
|
||||
}
|
||||
}
|
||||
|
||||
return "", errors.New("couldn not resolve the domain")
|
||||
return "", errors.New("no record found")
|
||||
}
|
||||
|
||||
func dohLookup(domain string) (string, error) {
|
||||
@ -79,12 +79,12 @@ func dohLookup(domain string) (string, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
log.Debug("[DOH] resolved dns for "+domain+": ", a.Data)
|
||||
log.Debug("[DOH] resolved ", domain, ": ", a.Data)
|
||||
return a.Data, nil
|
||||
}
|
||||
|
||||
// close the client
|
||||
c.Close()
|
||||
|
||||
return "", errors.New("couldn not resolve the domain")
|
||||
return "", errors.New("no record found")
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ func (pxy *Proxy) Start() {
|
||||
|
||||
ip, err := pxy.resolver.Lookup(pkt.Domain())
|
||||
if err != nil {
|
||||
log.Error("[PROXY] Error looking up for domain with ", pkt.Domain(), " ", err)
|
||||
log.Error("[PROXY] Error while dns lookup: ", pkt.Domain(), " ", err)
|
||||
conn.Write([]byte(pkt.Version() + " 502 Bad Gateway\r\n\r\n"))
|
||||
conn.Close()
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user