Created
June 13, 2015 08:23
-
-
Save lalyos/b8a4d03c028cc24be36e to your computer and use it in GitHub Desktop.
DNS SRV record test in golang
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 ( | |
"fmt" | |
"net" | |
"os" | |
) | |
func main() { | |
if len(os.Args) < 2 { | |
fmt.Fprintln(os.Stderr, "Usage: dnstest <SERVICE>") | |
os.Exit(1) | |
} | |
srv := os.Args[1] | |
fmt.Fprintln(os.Stderr, "service:", srv) | |
cname, addr, err := net.LookupSRV("", "", srv) | |
if err != nil { | |
fmt.Fprintln(os.Stderr, "[ERROR]", err) | |
} | |
fmt.Println("cname:", cname) | |
for _, a := range addr { | |
fmt.Printf(" %s %d\n", a.Target, a.Port) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment