Add 'q' a dig-like program (only 100 lines of code)
This commit is contained in:
parent
9d1d7444a3
commit
28f4189630
|
@ -7,6 +7,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Usage = func() {
|
var Usage = func() {
|
||||||
|
@ -35,14 +36,14 @@ FLAGS:
|
||||||
}
|
}
|
||||||
// If it looks like a class, it is a class
|
// If it looks like a class, it is a class
|
||||||
for k, v := range dns.Class_str {
|
for k, v := range dns.Class_str {
|
||||||
if v == flag.Arg(i) {
|
if v == strings.ToUpper(flag.Arg(i)) {
|
||||||
qclass = k
|
qclass = k
|
||||||
continue FLAGS
|
continue FLAGS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// And if it looks like type, it is a type
|
// And if it looks like type, it is a type
|
||||||
for k, v := range dns.Rr_str {
|
for k, v := range dns.Rr_str {
|
||||||
if v == flag.Arg(i) {
|
if v == strings.ToUpper(flag.Arg(i)) {
|
||||||
qtype = k
|
qtype = k
|
||||||
continue FLAGS
|
continue FLAGS
|
||||||
}
|
}
|
||||||
|
@ -57,7 +58,7 @@ FLAGS:
|
||||||
qr := resolver.NewQuerier(r)
|
qr := resolver.NewQuerier(r)
|
||||||
// @server may be a name, resolv that
|
// @server may be a name, resolv that
|
||||||
var err os.Error
|
var err os.Error
|
||||||
_, addr, err := net.LookupHost(nameserver)
|
_, addr, err := net.LookupHost(string([]byte(nameserver)[1:])) //chop off @
|
||||||
if err == nil {
|
if err == nil {
|
||||||
r.Servers = addr
|
r.Servers = addr
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue