-
-
Save mzimmerman/9188457 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" | |
"log" | |
"net" | |
"net/http" | |
"os" | |
) | |
var ( | |
filename = "domains.txt" | |
) | |
type timedResponse struct { | |
*http.Response | |
} | |
func getMXRecord(domain string) { | |
mx, err := net.LookupMX(domain) | |
if err != nil { | |
fmt.Printf("Error looking up mx for %s - %v\n", domain, err) | |
} else { | |
for m := range mx { | |
fmt.Printf("%s: %s\n", domain, mx[m].Host) | |
} | |
} | |
} | |
func processDomains(file io.Reader) { | |
scanner := bufio.NewScanner(file) | |
for scanner.Scan() { | |
getMXRecord(scanner.Text()) | |
} | |
} | |
func main() { | |
file, err := os.Open(filename) | |
if err != nil { | |
log.Fatal(err) | |
} | |
defer file.Close() | |
processDomains(file) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment