- auto check domain regist status
- auto update domain expiry time
- notice by email when a high value can be registed
require | version |
---|---|
go | 1.11 |
GameEngine_go | v1.0.0 |
go-sql-driver/mysql | v1.4.1 |
git clone git@github.com:coderguang/domainCheck_go.git domainCheck_go
{
"Dburl":"localhost", //your mysql database url
"Dbport":"3306", //database port
"Dbuser":"test", //database user
"Dbpwd":"test", //database password
"Dbname":"domain", //database name
"DoroutinesNum":5, //how many coroutine to check domain(only first run use)
"EmailFrom":"", //notice email from,empty mean wouldn't notice by email
"EmailPwd":"", //notice email password
"EmailTo":"royalchen@royalchen.com", //receiver
"Smtp":"smtps://smtp.exmail.qq.com", //smtp addr
"SmtpPort":"465" //smtp port
}
go run main.go config/config.json
enter any key ,it would show command,if first run,enter ["StartGenDataAndCheck"] to create domain file and start run,if not first run,just enter ["StartCheckByDb"] for scanner by database data. after enter ["StartGenDataAndCheck"],output message should like this
you can also get domain info in you database,like below:
status means:
const SG_WHOIS_STATUS_CHECK_FAILD int = -1 //receive domain server failed,will recheck in next time
const SG_WHOIS_STATUS_CAN_REGIST_NOW int = 0 //can registed now
const SG_WHOIS_STATUS_HAD_REGIST int = 1 //had been registed
const SG_WHOIS_STATUS_LIMIT_BY_GOVERNMENT int = 2 //govenment forbidden,if you search cn ,you will get this
1. now only will gen com、cn、net and pure num domains,if you want to change it ,you should modify code in src/genTxt/genTxt.go
unc CreateDominFile(fileName string) {
path, err := sgfile.GetPath(fileName)
if err != nil {
sglog.Error("get path error,err=%s", err)
sgthread.DelayExit(2)
}
sgfile.AutoMkDir(path)
file, err := os.OpenFile(fileName, os.O_RDWR|os.O_CREATE, 0766)
if err != nil {
sglog.Error("open file error,err=%s", err)
sgthread.DelayExit(2)
}
allList := []string{}
allList = append(allList, numlist...)
allList = append(allList, charlist...)
//create all
sum := 0
tmpSum := createDomainFileAndWrite(allList, 1, file)
sum += tmpSum
tmpSum = createDomainFileAndWrite(allList, 2, file)
sum += tmpSum
tmpSum = createDomainFileAndWrite(allList, 3, file)
sum += tmpSum
//create only num
tmpSum = createDomainFileAndWrite(numlist, 4, file)
sum += tmpSum
tmpSum = createDomainFileAndWrite(numlist, 5, file)
sum += tmpSum
//create only char
tmpSum = createDomainFileAndWrite(charlist, 4, file)
sum += tmpSum
defer file.Close()
sglog.Info("sum is %d", sum)
}
func createDomainFileAndWrite(srcList []string, num int, file *os.File) (sum int) {
sglog.Info("now gen %s,num=%d", srcList, num)
sum = 0
result := []string{}
sgalgorithm.GenPermutation(srcList, num, &result)
zonelist := []string{"com", "cn", "net"} //modify domain
for _, n := range result {
for _, k := range zonelist {
str := n + "." + k + "\n"
file.Write([]byte(str))
sum++
}
}
sglog.Info("gen success total num=%d", sum)
return
}
func HightValueNotice(result *sgwhois.Whois) {
if sgwhois.IsHightValueDomainByName(result.Domain) {
time_now := sgtime.New()
if sgwhois.SG_WHOIS_STATUS_CAN_REGIST_NOW == result.IsRegist {
domainCheckMail.SendMailNotice(result.Domain, " can regist now")
sglog.Info("luck domain ", result.Domain, " can regist now")
} else if sgwhois.SG_WHOIS_STATUS_LIMIT_BY_GOVERNMENT != result.IsRegist && result.ExpiryDt.Before(time_now) {
//SendMailNotice( domain, config, " can regist "+result.ExpiryDtStr)
sglog.Info("luck domain %s can regist at %s", result.Domain, result.ExpiryDtStr)
}
}
}
Author | royalchen |
---|---|
royalchen@royalchen.com | |
royalchen@royalchen.com | |
website | www.royalchen.com |