"encoding/hex"
"fmt"
"log"
- "strings"
"github.com/miekg/dns"
)
if DNSSrv == "" {
return false, false
}
- host := addr
- port := "443"
- cols := strings.Split(addr, ":")
- if len(cols) > 1 {
- host = cols[0]
- port = cols[1]
+ host, port, err := SplitHostPort(addr)
+ if err != nil {
+ log.Printf("can not split host+port: %s: %+v\n", addr, err)
+ return false, false
+ }
+ if port == "" {
+ port = "443"
}
m := new(dns.Msg)
m.SetQuestion(dns.Fqdn(fmt.Sprintf("_%s._tcp.%s", port, host)), dns.TypeTLSA)