本文整理汇总了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)
}
}