-
Notifications
You must be signed in to change notification settings - Fork 88
Open
Description
Instead of using the default resolver to lookup the MX record. I recommend using a custom resolver with a context timeout to prevent long-lived connections.
https://github.com/badoux/checkmail/blob/master/checkmail.go#L49
const timeout = 10 * time.Millisecond
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
defer cancel() // important to avoid a resource leak
var r net.Resolver
names, err := r.LookupMX(ctx, "127.0.0.1")
if err == nil && len(names) > 0 {
fmt.Println(names[0]) // "localhost"
}
Metadata
Metadata
Assignees
Labels
No labels