GO 利用net包获取域名的各种解析信息【dome】

删除回忆录丶 提交于 2020-03-05 14:57:26

代码如下:

package main

import (
    "fmt"
    "net"
    "strings"
)

func main() {
    datatest := string(`{"qq.com":["panshi.qq.com","qqgame.qq.com","njga.qq.com","xianchang.qq.com","tour.qq.com","acts.qq.com","mtrace.qq.com","nbam.qq.com","shuihu.qq.com","pal.qq.com","chuangshi.qq.com","a1yoy.qq.com","xxz.qq.com","wetoy.qq.com","rpg.qq.com","dance.qq.com","dnf.qq.com","jdgm.qq.com","ygmd.qq.com","tgclub.qq.com","show.qq.com","pingmid.qq.com","rs2.qq.com","byb.qq.com","yybh5report.qq.com","debugtbs.qq.com","ossweb-img.qq.com","weixin.qq.com","new.qq.com","zdzc.qq.com","gzhweb.qq.com","wxgc.qq.com","cmall.qq.com","baoxian.qq.com","3gimg.qq.com","arthub-test.qq.com","assetstore.qq.com","vipcard.qq.com","color.qq.com","gas-storage.qq.com","arthub-storage-mofang.qq.com","isdspeed.qq.com","vp.qq.com","ip.qq.com","upload_data.qq.com","pc.qq.com","games.qq.com","wpa.qq.com","stun-a1.qq.com","docs.qq.com","wx.qq.com","speed.qq.com","wb.qq.com","vip.qq.com","qzs.qq.com","quan.qq.com","jump.qq.com","wns.qq.com","xw.qq.com","e.qq.com","ac.qq.com","badjs2.qq.com","pingtcss.qq.com","dldl.qq.com","qt.qq.com","www.qq.com","007.qq.com","waibao.qq.com","mail.qq.com","17roco.qq.com","ke.qq.com","c.qq.com","djt.qq.com","qiandao.qq.com","shannon-lab.qq.com","imp.qq.com","clearsports.qq.com","ltsws.qq.com","tianshu.qq.com","captcha.qq.com","pdlxf_doctor.qq.com","ysdk.qq.com","btrace.qq.com","omgid.qq.com","dp3.qq.com","down.qq.com","v.qq.com","game.qq.com","weread.qq.com","change.qq.com","msdk.qq.com","wnskg.qq.com","adslvseed.qq.com","pingfore.qq.com","ied-tqos.qq.com","mta.qq.com","cwns.qq.com","imgcache.qq.com","minigame.qq.com","ptlogin2.qq.com"]}{"qq.com":["panshi.qq.com","qqgame.qq.com","njga.qq.com","xianchang.qq.com","tour.qq.com","acts.qq.com","mtrace.qq.com","nbam.qq.com","shuihu.qq.com","pal.qq.com","chuangshi.qq.com","a1yoy.qq.com","xxz.qq.com","wetoy.qq.com","rpg.qq.com","dance.qq.com","dnf.qq.com","jdgm.qq.com","ygmd.qq.com","tgclub.qq.com","show.qq.com","pingmid.qq.com","rs2.qq.com","byb.qq.com","yybh5report.qq.com","debugtbs.qq.com","ossweb-img.qq.com","weixin.qq.com","new.qq.com","zdzc.qq.com","gzhweb.qq.com","wxgc.qq.com","cmall.qq.com","baoxian.qq.com","3gimg.qq.com","arthub-test.qq.com","assetstore.qq.com","vipcard.qq.com","color.qq.com","gas-storage.qq.com","arthub-storage-mofang.qq.com","isdspeed.qq.com","vp.qq.com","ip.qq.com","upload_data.qq.com","pc.qq.com","games.qq.com","wpa.qq.com","stun-a1.qq.com","docs.qq.com","wx.qq.com","speed.qq.com","wb.qq.com","vip.qq.com","qzs.qq.com","quan.qq.com","jump.qq.com","wns.qq.com","xw.qq.com","e.qq.com","ac.qq.com","badjs2.qq.com","pingtcss.qq.com","dldl.qq.com","qt.qq.com","www.qq.com","007.qq.com","waibao.qq.com","mail.qq.com","17roco.qq.com","ke.qq.com","c.qq.com","djt.qq.com","qiandao.qq.com","shannon-lab.qq.com","imp.qq.com","clearsports.qq.com","ltsws.qq.com","tianshu.qq.com","captcha.qq.com","pdlxf_doctor.qq.com","ysdk.qq.com","btrace.qq.com","omgid.qq.com","dp3.qq.com","down.qq.com","v.qq.com","game.qq.com","weread.qq.com","change.qq.com","msdk.qq.com","wnskg.qq.com","adslvseed.qq.com","pingfore.qq.com","ied-tqos.qq.com","mta.qq.com","cwns.qq.com","imgcache.qq.com","minigame.qq.com","ptlogin2.qq.com"]}`)
    string_slice := strings.Split(datatest, `"`)
    for i := 3; i < len(string_slice)-1; i++ {
        if string_slice[i] == "," {
            continue
        }
        fmt.Println(string_slice[i])
        domain := string_slice[i]
        if cname, err := net.LookupCNAME(domain); err != nil {
            fmt.Printf("lookup failed:%q\n", err)
        } else {
            fmt.Printf("{CMAME:%s [%s]}\n", domain, cname)
        }
        if cname, err := net.LookupMX(domain); err != nil {
            fmt.Printf("lookup failed:%q}\n", err)
        } else {
            fmt.Printf("{MX:%s %s}\n", domain, cname)
        }
        if cname, err := net.LookupIP(domain); err != nil {
            fmt.Printf("lookup failed:%q\n", err)
        } else {
            fmt.Printf("{IP:%s %s}\n", domain, cname)
        }
        if cname, err := net.LookupNS(domain); err != nil {
            fmt.Printf("lookup failed:%q\n", err)
        } else {
            fmt.Printf("{NS:%s %s}\n", domain, cname)
        }
        if cname, err := net.LookupTXT(domain); err != nil {
            fmt.Printf("lookup failed: %q\n", err)
        } else {
            fmt.Printf("{TXT:%s %s}\n", domain, cname)
        }
    }
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!