Skip to content

Instantly share code, notes, and snippets.

@yuxiaokui
Created September 26, 2019 06:44
Show Gist options
  • Save yuxiaokui/9cd382b3bcab1f70551e8eac42874137 to your computer and use it in GitHub Desktop.
Save yuxiaokui/9cd382b3bcab1f70551e8eac42874137 to your computer and use it in GitHub Desktop.
package main
import (
"bufio"
"fmt"
"io"
"net"
"os"
"strings"
)
func dns(domain string) {
ns, err := net.LookupHost(domain)
if err != nil {
//fmt.Fprintf(os.Stderr, "Err: %s", err.Error())
} else {
fmt.Print(domain)
}
for _, n := range ns {
fmt.Fprintf(os.Stdout, "--%s\n", n)
}
}
func main() {
f, err := os.Open("dns.txt")
if err != nil {
fmt.Print(err)
}
defer f.Close()
buf := bufio.NewReader(f)
for {
line, err := buf.ReadString('\n')
line = strings.TrimSpace(line)
if err != nil {
if err == io.EOF {
break
}
fmt.Print(err)
}
domain := line + "lenovo.com.cn"
go dns(domain)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment