Created
September 26, 2019 06:44
-
-
Save yuxiaokui/9cd382b3bcab1f70551e8eac42874137 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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