rio/dns.go

26 lines
379 B
Go

package main
import (
"net"
"time"
"github.com/patrickmn/go-cache"
)
var (
cnameCache = cache.New(1 * time.Hour, 1 * time.Hour)
)
func lookupCNAME(domain string) (string, error) {
cname, found := cnameCache.Get(domain)
if found {
return cname.(string), nil
}
cname, err := net.LookupCNAME(domain)
if err == nil {
return cname.(string), nil
}
return "", err
}