package main
import (
"bufio"
"fmt"
"log"
"net"
"os"
"strings"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
fmt.Printf("domain,hasMX,hasSPF,spfRecord,hasDMARC,dmarcRecord\n")
for scanner.Scan() {
checkDomain(scanner.Text())
}
if err := scanner.Err(); err != nil {
log.Fatal("Error: could not read from input: %v\n", err)
}
}
func checkDomain(domain string) {
// DKIM、DMARC 和 SPF 是维护电子邮件安全的三种主要机制。
// 相关协议可让您防止未经授权的服务器作为您的域发送,并为收件人提供一种验证电子邮件确实来自您的方法。
var hasMX, hasSPF, hasDMARC bool
var spfRecord, dmarcRecord string
mxRecords, err := net.LookupMX(domain)
if err != nil {
log.Printf("error: %v\n", err)
}
if len(mxRecords) > 0 {
hasMX = true
}
txtRecords, err := net.LookupTXT(domain)
if err != nil {
log.Printf("error: %v\n", err)
}
for _, record := range txtRecords {
if strings.HasPrefix(record, "v=spf1") {
hasSPF = true
spfRecord = record
break
}
}
dmarctxt := "_dmarc." + domain
dmarcRecords, err := net.LookupTXT(dmarctxt)
if err != nil {
log.Printf("error: %v\n", err)
}
for _, record := range dmarcRecords {
if strings.HasPrefix(record, "v=DMARC1") {
hasDMARC = true
dmarcRecord = record
break
}
}
fmt.Printf("domain: %v\n hasMX: %v\n hasSPF: %v\n spfRecord: %v\n hasDMARC: %v\n dmarcRecord: %v\n",
domain, hasMX, hasSPF, spfRecord, hasDMARC, dmarcRecord)
}
上一篇
go使用fiber实现CRM
installgo get -u gorm.io/gorm
go get -u gorm.io/driver/sqlite
技术选型: gorm(sqlite),go-fiber
开发
database/database.gopack
2023-04-30
下一篇
go微服务网关 - 4.网络代理
网络代理大纲
代理!=转发
开发一个浏览器代理
package main
import (
"fmt"
"io"
"net"
"net/http"
"strings"
)
type Pxy
2023-04-30