mirror of
https://github.com/m13253/dns-over-https.git
synced 2026-07-28 23:19:21 +00:00
Resolve (some) linter warnings
This commit is contained in:
@@ -39,7 +39,7 @@ import (
|
||||
|
||||
"github.com/m13253/dns-over-https/doh-client/config"
|
||||
"github.com/m13253/dns-over-https/doh-client/selector"
|
||||
jsonDNS "github.com/m13253/dns-over-https/json-dns"
|
||||
jsondns "github.com/m13253/dns-over-https/json-dns"
|
||||
"github.com/miekg/dns"
|
||||
"golang.org/x/net/http2"
|
||||
"golang.org/x/net/idna"
|
||||
@@ -305,7 +305,7 @@ func (c *Client) handlerFunc(w dns.ResponseWriter, r *dns.Msg, isTCP bool) {
|
||||
|
||||
if len(r.Question) != 1 {
|
||||
log.Println("Number of questions is not 1")
|
||||
reply := jsonDNS.PrepareReply(r)
|
||||
reply := jsondns.PrepareReply(r)
|
||||
reply.Rcode = dns.RcodeFormatError
|
||||
w.WriteMsg(reply)
|
||||
return
|
||||
@@ -356,7 +356,7 @@ func (c *Client) handlerFunc(w dns.ResponseWriter, r *dns.Msg, isTCP bool) {
|
||||
return
|
||||
}
|
||||
log.Println(err)
|
||||
reply = jsonDNS.PrepareReply(r)
|
||||
reply = jsondns.PrepareReply(r)
|
||||
reply.Rcode = dns.RcodeServerFailure
|
||||
w.WriteMsg(reply)
|
||||
return
|
||||
@@ -471,7 +471,7 @@ func (c *Client) findClientIP(w dns.ResponseWriter, r *dns.Msg) (ednsClientAddre
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if ip := remoteAddr.IP; jsonDNS.IsGlobalIP(ip) {
|
||||
if ip := remoteAddr.IP; jsondns.IsGlobalIP(ip) {
|
||||
if ipv4 := ip.To4(); ipv4 != nil {
|
||||
ednsClientAddress = ipv4.Mask(ipv4Mask24)
|
||||
ednsClientNetmask = 24
|
||||
|
||||
@@ -44,7 +44,7 @@ func (c *Client) generateRequestGoogle(ctx context.Context, w dns.ResponseWriter
|
||||
questionName := question.Name
|
||||
questionClass := question.Qclass
|
||||
if questionClass != dns.ClassINET {
|
||||
reply := jsonDNS.PrepareReply(r)
|
||||
reply := jsondns.PrepareReply(r)
|
||||
reply.Rcode = dns.RcodeRefused
|
||||
w.WriteMsg(reply)
|
||||
return &DNSRequest{
|
||||
@@ -80,7 +80,7 @@ func (c *Client) generateRequestGoogle(ctx context.Context, w dns.ResponseWriter
|
||||
req, err := http.NewRequest(http.MethodGet, requestURL, nil)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
reply := jsonDNS.PrepareReply(r)
|
||||
reply := jsondns.PrepareReply(r)
|
||||
reply.Rcode = dns.RcodeServerFailure
|
||||
w.WriteMsg(reply)
|
||||
return &DNSRequest{
|
||||
@@ -111,7 +111,7 @@ func (c *Client) generateRequestGoogle(ctx context.Context, w dns.ResponseWriter
|
||||
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
reply := jsonDNS.PrepareReply(r)
|
||||
reply := jsondns.PrepareReply(r)
|
||||
reply.Rcode = dns.RcodeServerFailure
|
||||
w.WriteMsg(reply)
|
||||
return &DNSRequest{
|
||||
@@ -121,7 +121,7 @@ func (c *Client) generateRequestGoogle(ctx context.Context, w dns.ResponseWriter
|
||||
|
||||
return &DNSRequest{
|
||||
response: resp,
|
||||
reply: jsonDNS.PrepareReply(r),
|
||||
reply: jsondns.PrepareReply(r),
|
||||
udpSize: udpSize,
|
||||
ednsClientAddress: ednsClientAddress,
|
||||
ednsClientNetmask: ednsClientNetmask,
|
||||
@@ -148,7 +148,7 @@ func (c *Client) parseResponseGoogle(ctx context.Context, w dns.ResponseWriter,
|
||||
return
|
||||
}
|
||||
|
||||
var respJSON jsonDNS.Response
|
||||
var respJSON jsondns.Response
|
||||
err = json.Unmarshal(body, &respJSON)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
@@ -162,7 +162,7 @@ func (c *Client) parseResponseGoogle(ctx context.Context, w dns.ResponseWriter,
|
||||
}
|
||||
fixEmptyNames(&respJSON)
|
||||
|
||||
fullReply := jsonDNS.Unmarshal(req.reply, &respJSON, req.udpSize, req.ednsClientNetmask)
|
||||
fullReply := jsondns.Unmarshal(req.reply, &respJSON, req.udpSize, req.ednsClientNetmask)
|
||||
buf, err := fullReply.Pack()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
@@ -185,7 +185,7 @@ func (c *Client) parseResponseGoogle(ctx context.Context, w dns.ResponseWriter,
|
||||
// Fix DNS response empty []RR.Name
|
||||
// Additional section won't be rectified
|
||||
// see: https://stackoverflow.com/questions/52136176/what-is-additional-section-in-dns-and-how-it-works
|
||||
func fixEmptyNames(respJSON *jsonDNS.Response) {
|
||||
func fixEmptyNames(respJSON *jsondns.Response) {
|
||||
for i := range respJSON.Answer {
|
||||
if respJSON.Answer[i].Name == "" {
|
||||
respJSON.Answer[i].Name = "."
|
||||
|
||||
+6
-6
@@ -36,7 +36,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/m13253/dns-over-https/doh-client/selector"
|
||||
jsonDNS "github.com/m13253/dns-over-https/json-dns"
|
||||
jsondns "github.com/m13253/dns-over-https/json-dns"
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
@@ -90,7 +90,7 @@ func (c *Client) generateRequestIETF(ctx context.Context, w dns.ResponseWriter,
|
||||
requestBinary, err := r.Pack()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
reply := jsonDNS.PrepareReply(r)
|
||||
reply := jsondns.PrepareReply(r)
|
||||
reply.Rcode = dns.RcodeFormatError
|
||||
w.WriteMsg(reply)
|
||||
return &DNSRequest{
|
||||
@@ -107,7 +107,7 @@ func (c *Client) generateRequestIETF(ctx context.Context, w dns.ResponseWriter,
|
||||
req, err = http.NewRequest(http.MethodGet, requestURL, nil)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
reply := jsonDNS.PrepareReply(r)
|
||||
reply := jsondns.PrepareReply(r)
|
||||
reply.Rcode = dns.RcodeServerFailure
|
||||
w.WriteMsg(reply)
|
||||
return &DNSRequest{
|
||||
@@ -118,7 +118,7 @@ func (c *Client) generateRequestIETF(ctx context.Context, w dns.ResponseWriter,
|
||||
req, err = http.NewRequest(http.MethodPost, upstream.URL, bytes.NewReader(requestBinary))
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
reply := jsonDNS.PrepareReply(r)
|
||||
reply := jsondns.PrepareReply(r)
|
||||
reply.Rcode = dns.RcodeServerFailure
|
||||
w.WriteMsg(reply)
|
||||
return &DNSRequest{
|
||||
@@ -149,7 +149,7 @@ func (c *Client) generateRequestIETF(ctx context.Context, w dns.ResponseWriter,
|
||||
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
reply := jsonDNS.PrepareReply(r)
|
||||
reply := jsondns.PrepareReply(r)
|
||||
reply.Rcode = dns.RcodeServerFailure
|
||||
w.WriteMsg(reply)
|
||||
return &DNSRequest{
|
||||
@@ -159,7 +159,7 @@ func (c *Client) generateRequestIETF(ctx context.Context, w dns.ResponseWriter,
|
||||
|
||||
return &DNSRequest{
|
||||
response: resp,
|
||||
reply: jsonDNS.PrepareReply(r),
|
||||
reply: jsondns.PrepareReply(r),
|
||||
udpSize: udpSize,
|
||||
ednsClientAddress: ednsClientAddress,
|
||||
ednsClientNetmask: ednsClientNetmask,
|
||||
|
||||
Reference in New Issue
Block a user