HFish/view/api/view.go

66 lines
1.3 KiB
Go
Raw Normal View History

2019-08-07 13:16:23 +08:00
package api
import (
"github.com/gin-gonic/gin"
"HFish/core/report"
"net/http"
"HFish/error"
"HFish/utils/conf"
"HFish/core/dbUtil"
2019-08-10 18:26:43 +08:00
"HFish/core/rpc/client"
"HFish/utils/is"
2019-08-07 13:16:23 +08:00
)
func ReportWeb(c *gin.Context) {
name := c.PostForm("name")
info := c.PostForm("info")
secKey := c.PostForm("sec_key")
ip := c.ClientIP()
apiSecKey := conf.Get("api", "sec_key")
if secKey != apiSecKey {
c.JSON(http.StatusOK, error.ErrFailApiKey())
} else {
2019-08-10 18:26:43 +08:00
// 判断是否为 RPC 客户端
if is.Rpc() {
go client.ReportResult("WEB", name, ip, info, "0")
} else {
go report.ReportWeb(name, "本机", ip, info)
}
c.JSON(http.StatusOK, error.ErrSuccessNull())
}
}
func ReportDeepWeb(c *gin.Context) {
name := c.PostForm("name")
info := c.PostForm("info")
secKey := c.PostForm("sec_key")
ip := c.ClientIP()
apiSecKey := conf.Get("api", "sec_key")
if secKey != apiSecKey {
c.JSON(http.StatusOK, error.ErrFailApiKey())
} else {
// 判断是否为 RPC 客户端
if is.Rpc() {
go client.ReportResult("DEEP", name, ip, info, "0")
} else {
2019-08-11 20:14:28 +08:00
go report.ReportDeepWeb(name, "本机", ip, info)
2019-08-10 18:26:43 +08:00
}
2019-08-07 13:16:23 +08:00
c.JSON(http.StatusOK, error.ErrSuccessNull())
}
}
// 获取记录黑客IP
func GetIpList(c *gin.Context) {
sql := `select ip from hfish_info GROUP BY ip;`
result := dbUtil.Query(sql)
c.JSON(http.StatusOK, error.ErrSuccess(result))
}