@@ -16,8 +16,6 @@ import (
16
16
// ParseMiscArgs parses the wildcard arguments, drill style.
17
17
// Only one command is supported at a time, so any extra information overrides previous.
18
18
func ParseMiscArgs (args []string , opts * util.Options ) error {
19
- var err error
20
-
21
19
for _ , arg := range args {
22
20
r , ok := dns .StringToType [strings .ToUpper (arg )]
23
21
@@ -31,15 +29,15 @@ func ParseMiscArgs(args []string, opts *util.Options) error {
31
29
switch {
32
30
case strings .HasPrefix (arg , "tls://" ):
33
31
opts .TLS = true
34
- opts .Request .Server = arg [ 6 :]
32
+ opts .Request .Server = strings . TrimPrefix ( opts . Request . Server , "tls://" )
35
33
opts .Logger .Info ("DNS-over-TLS implicitly set" )
36
34
case strings .HasPrefix (arg , "https://" ):
37
35
opts .HTTPS = true
38
36
opts .Request .Server = arg
39
37
opts .Logger .Info ("DNS-over-HTTPS implicitly set" )
40
38
case strings .HasPrefix (arg , "quic://" ):
41
39
opts .QUIC = true
42
- opts .Request .Server = arg [ 7 :]
40
+ opts .Request .Server = strings . TrimPrefix ( opts . Request . Server , "quic://" )
43
41
opts .Logger .Info ("DNS-over-QUIC implicitly set." )
44
42
case strings .HasPrefix (arg , "sdns://" ):
45
43
opts .DNSCrypt = true
@@ -52,14 +50,15 @@ func ParseMiscArgs(args []string, opts *util.Options) error {
52
50
// Dig-style +queries
53
51
case strings .HasPrefix (arg , "+" ):
54
52
opts .Logger .Info (arg , "detected as a dig query" )
55
- err = ParseDig (strings .ToLower (arg [1 :]), opts )
56
53
57
- if err != nil {
54
+ if err := ParseDig ( strings . ToLower ( arg [ 1 :]), opts ); err != nil {
58
55
return err
59
56
}
60
57
61
58
// Domain names
62
59
case strings .Contains (arg , "." ):
60
+ var err error
61
+
63
62
opts .Logger .Info (arg , "detected as a domain name" )
64
63
opts .Request .Name , err = idna .ToASCII (arg )
65
64
@@ -74,6 +73,8 @@ func ParseMiscArgs(args []string, opts *util.Options) error {
74
73
75
74
// Domain?
76
75
default :
76
+ var err error
77
+
77
78
opts .Logger .Info (arg , "is unknown. Assuming domain" )
78
79
opts .Request .Name , err = idna .ToASCII (arg )
79
80
@@ -89,16 +90,14 @@ func ParseMiscArgs(args []string, opts *util.Options) error {
89
90
opts .Request .Name = "."
90
91
91
92
if opts .Request .Type == 0 {
93
+ opts .Logger .Info ("Query not specified, making an \" NS\" query" )
92
94
opts .Request .Type = dns .StringToType ["NS" ]
93
95
}
94
- } else {
96
+ } else if opts . Request . Type == 0 {
95
97
opts .Logger .Info ("Query not specified, making an \" A\" query" )
96
-
97
- if opts .Request .Type == 0 {
98
- opts .Request .Type = dns .StringToType ["A" ]
99
- }
98
+ opts .Request .Type = dns .StringToType ["A" ]
100
99
}
101
- //
100
+
102
101
if opts .Request .Server == "" {
103
102
opts .Logger .Info ("Server not specified, selecting a default" )
104
103
// Set "defaults" for each if there is no input
@@ -113,7 +112,7 @@ func ParseMiscArgs(args []string, opts *util.Options) error {
113
112
case opts .QUIC :
114
113
opts .Request .Server = "dns.adguard.com"
115
114
default :
116
- //nolint:govet // This shadow is intentional
115
+ var err error
117
116
resolv , err := conf .GetDNSConfig ()
118
117
119
118
if err != nil {
@@ -150,8 +149,10 @@ func ParseMiscArgs(args []string, opts *util.Options) error {
150
149
151
150
opts .Logger .Info ("DNS server set to" , opts .Request .Server )
152
151
153
- // Make reverse adresses proper addresses
152
+ // Make reverse addresses proper addresses
154
153
if opts .Reverse {
154
+ var err error
155
+
155
156
opts .Logger .Info ("Making reverse DNS query proper *.arpa domain" )
156
157
157
158
if dns .TypeToString [opts .Request .Type ] == "A" {
@@ -168,7 +169,7 @@ func ParseMiscArgs(args []string, opts *util.Options) error {
168
169
if ! strings .HasSuffix (opts .Request .Name , "." ) {
169
170
opts .Request .Name = fmt .Sprintf ("%s." , opts .Request .Name )
170
171
171
- opts .Logger .Debug ("Domain made canonical" )
172
+ opts .Logger .Info ("Domain made canonical" )
172
173
}
173
174
174
175
return nil
0 commit comments