Skip to content

Commit

Permalink
因 FOFA 会员机制问题尽可能移除 lastupdatetime 字段。让普通用户也可以方便使用
Browse files Browse the repository at this point in the history
  • Loading branch information
Becivells committed Apr 12, 2023
1 parent 330eb75 commit 0f5ff6e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 29 deletions.
2 changes: 1 addition & 1 deletion internal/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

var (
FoFaXVersion = "0.1.42"
FoFaXVersion = "0.1.43"
Commit = "unknown"
Date = "2022-01-01T01:01:01Z"
Branch = "unknown"
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ func checkUpdateInfo() {
printer.Error(err)
return
}
if -time.Until(lasTime) > 24*time.Hour || args.Update {
if -time.Until(lasTime) > 7*24*time.Hour || args.Update {
err := updateTips(FoFaXVersion)
if err != nil {
printer.Error(err.Error())
Expand Down
32 changes: 5 additions & 27 deletions internal/fofa/fofa_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ func (f *FoFa) fetchByFields(fields string, queryStr string) bool {
printer.Errorf("Json Unmarshal Failed: %s", string(body))
return false
}
if len(apiResult.ErrMsg) != 0 {
printer.Errorf("FoFa Response ErrMsg: %s", getApiErrInfo(apiResult.ErrMsg))
if len(apiResult.ErrMsg) != 0 && apiResult.Error == true {
printer.Errorf("FoFa Response ErrMsg: %s", apiResult.ErrMsg)
return false
}
if f.option.Debug {
Expand Down Expand Up @@ -183,36 +183,14 @@ func (f *FoFa) FetchField(field, queryStr string) bool {

// FetchTitlesOfDomain 提取 title
func (f *FoFa) FetchTitlesOfDomain(queryStr string) bool {
return f.fetchByFields("protocol,ip,port,host,type,title,lastupdatetime", queryStr)
return f.fetchByFields("protocol,ip,port,host,type,title,country", queryStr)
}

// FetchJarmOfDomain 提取 title
func (f *FoFa) FetchJarmOfDomain(queryStr string) bool {
return f.fetchByFields("protocol,ip,port,host,type,jarm,lastupdatetime", queryStr)
return f.fetchByFields("protocol,ip,port,host,type,jarm,country", queryStr)
}

func (f *FoFa) Fetch(queryStr string) bool {
return f.fetchByFields("host,port,ip,lastupdatetime", queryStr)
}

//func (f *FoFa) fetchFn(fields []string, allSize int32) bool {
// hostInfo := utils.NewFixUrl(
// fmt.Sprintf("%s://%s:%s",
// fields[0], fields[1], fields[2]))
// return f.FetchCallBack(hostInfo, allSize)
//}

func getApiErrInfo(code string) string {
// {errmsg: "Request overrun on the day, restrict access, try again tomorrow", error: true}
if strings.Contains(code, "try again tomorrow") {
printer.Fatal(code)
}
switch code {
case "820000":
return "查询语法错误"
case "820005":
return "查询没有权限"
default:
return code
}
return f.fetchByFields("host,port,ip,country", queryStr)
}

0 comments on commit 0f5ff6e

Please sign in to comment.