本文整理匯總了Golang中github.com/williballenthin/govt.Client.GetIpReport方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.GetIpReport方法的具體用法?Golang Client.GetIpReport怎麽用?Golang Client.GetIpReport使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/williballenthin/govt.Client
的用法示例。
在下文中一共展示了Client.GetIpReport方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
flag.Parse()
if ip == "" {
fmt.Println("-ip=<ip> fehlt!")
os.Exit(1)
}
c := govt.Client{Apikey: apikey, Url: apiurl}
// get a file report
r, err := c.GetIpReport(ip)
check(err)
j, err := json.MarshalIndent(r, "", " ")
fmt.Printf("IP Report: ")
os.Stdout.Write(j)
}
示例2: fetch
func fetch(url string, mode bool) {
fmt.Println("inside of fetch")
var ip string
file := "report.txt"
if mode {
fmt.Print("Analyzing URL(s):\n")
}
ip_addr, err := net.LookupIP(url)
if mode {
fmt.Print("Finished Domain Lookup\n")
}
if err != nil {
fmt.Sprintf("ip lookup failed %s %v", ip_addr, err)
}
for i := 0; i < len(ip_addr); i++ {
ip = ip_addr[i].String()
}
if mode {
fmt.Print("Sending to VirusTotal: Awaiting Results\n")
}
if ip == "" {
fmt.Println("-ip=<ip> fehlt!")
os.Exit(1)
}
c := govt.Client{Apikey: apikey, Url: apiurl}
// get a file report
r, err := c.GetIpReport(ip)
check(err)
j, err := json.MarshalIndent(r, "", " ")
if _, err := os.Stat(file); err == nil {
fmt.Println("File Exists")
ioutil.WriteFile("test.txt", j, 0664)
}
ioutil.WriteFile("report.txt", j, 0664)
check(err)
if mode {
fmt.Print("Report Generated\n")
fmt.Println("IP Report:")
}
}
示例3: fetch
func fetch(url string, mode bool) {
var ip string
file := "report.txt"
if mode {
fmt.Print("Analyzing URL(s):\n")
fmt.Print("Resolving URL:")
}
if govalidator.IsURL(url) {
ipAddr, err := net.LookupIP(url)
if mode {
fmt.Print("Finished Domain Lookup\n")
}
if err != nil {
fmt.Sprintf("ip lookup failed %s %v", ipAddr, err)
}
for i := 0; i < len(ipAddr); i++ {
ip = ipAddr[i].String()
}
if mode {
fmt.Print("Sending to VirusTotal: Awaiting Results\n")
}
if ip == "" {
fmt.Println("-ip=<ip> fehlt!")
os.Exit(0)
}
c := govt.Client{Apikey: apikey, Url: apiurl}
// get a file report
r, err := c.GetIpReport(ip)
check(err)
j, err := json.MarshalIndent(r, "", " ")
if err != nil {
fmt.Println("Formatting Error")
return
}
// currDir, err := os.Getwd()
if _, err := os.Stat(file); err == nil {
if mode {
fmt.Println("File Exists Moving to Reports Directory")
}
os.Mkdir("report", 0760)
ioutil.WriteFile("report/"+url+"-report", j, 0664)
} else {
ioutil.WriteFile("report.txt", j, 0664)
}
check(err)
if mode {
fmt.Print("Report Generated\n")
fmt.Println("IP Report:")
}
} else {
fmt.Println("Invalid URL")
os.Exit(-1)
}
}