Skip to content

Latest commit

 

History

History
164 lines (131 loc) · 3.33 KB

README.md

File metadata and controls

164 lines (131 loc) · 3.33 KB

vulfocus-go

GitHub (pre-)release stars license

中文文档

Vulfocus API

Vulfocus API is the RESUFul API interface provided by Vulfocus for development, allowing Developers integrate Vulfocus in their own projects.

Vulfocus SDK

The GO version of SDK written based on the Vulfocus API makes it easy for Golang developers to quickly integrate Vulfocus into their projects.

Add dependency

go get github.com/fofapro/vulfocus-go

Use

field description
addr Vulfocus URL
username User login Vulfocus userbox username
licence Please go to the personal center to view API licence

Pull Images

package main

import (
    "fmt"
    "github.com/fofapro/vulfocus-go"
)

const (
    addr     = "http://vulfocus.fofa.so"
    username = ""
    licence  = ""
)

func main() {
    client := vulfocus.NewClient(addr, username, licence)
    err, images := client.GetImages()
    if err != nil {
        return
    }
    fmt.Printf("get %d images", len(images))
    if len(images) == 0 {
        return
    }
}

Start

package main

import (
	"fmt"
	"github.com/fofapro/vulfocus-go"
)

const (
    addr     = "http://vulfocus.fofa.so"
    username = ""
    licence  = ""
)

func main() {
    client := vulfocus.NewClient(addr, username, licence)
    err, images := client.GetImages()
    if err != nil {
        return
    }
    fmt.Printf("get %d images", len(images))
    if len(images) == 0 {
        return
    }
    err, exposed := client.Start(images[0].Name)
    if err != nil {
        return
    }
    println(exposed.Host, exposed.Port)
}

Stop

package main

import (
    "fmt"
    "github.com/fofapro/vulfocus-go"
)

const (
	addr     = "http://vulfocus.fofa.so"
	username = ""
	licence  = ""
)

func main() {
    client := vulfocus.NewClient(addr, username, licence)
    err, images := client.GetImages()
    if err != nil {
        return
    }
    fmt.Printf("get %d images", len(images))
    if len(images) == 0 {
        return
    }
    err = client.Stop(images[0].Name)
    if err != nil {
        return
    }
}

Delete

package main

import (
    "fmt"
    "github.com/fofapro/vulfocus-go"
)

const (
    addr     = "http://vulfocus.fofa.so"
    username = ""
    licence  = ""
)

func main() {
    client := vulfocus.NewClient(addr, username, licence)
    err, images := client.GetImages()
    if err != nil {
        return
    }
    fmt.Printf("get %d images", len(images))
    if len(images) == 0 {
        return
    }
    err = client.Delete(images[0].Name)
    if err != nil {
        return
    }
}

Update Log

2021-11-25

- Version release