Files
revsuit/internal/qqwry/wry.go
T
Li4n0 3559894acc feat: complete basic functions
Support http,dns and mysql connection. Support custom http, dns response. Support dns rebinding.
Support mysql load local files and jdbc deserialize exploit.
2021-04-21 18:55:16 +08:00

48 lines
944 B
Go

package qqwry
import (
"os"
"sync"
"time"
"github.com/sinlov/qqwry-golang/qqwry"
log "unknwon.dev/clog/v2"
)
var wry *qqwry.QQwry
var once sync.Once
func init() {
info, err := os.Stat("qqwry.dat")
if err != nil {
if os.IsNotExist(err) {
err := download()
if err != nil {
log.Error("Download qqwry.dat failed, caused by:%v, recommend to download it by yourself otherwise the `IpArea` will be null", err.Error())
}
}
} else if info.ModTime().Sub(time.Now()) > 5*24*time.Hour {
log.Info("Updating qqwry.dat...")
err := download()
if err != nil {
log.Warn("Update qqwry.dat failed, please download qqwry.dat by yourself")
}
}
}
func GetQQWry() *qqwry.QQwry {
once.Do(func() {
qqwry.DatData.FilePath = "qqwry.dat"
init := qqwry.DatData.InitDatFile()
if v, ok := init.(error); ok {
if v != nil {
log.Error("qqwry init failed")
wry = nil
}
}
wry = qqwry.NewQQwry()
})
return wry
}