diff --git a/internal/cli/cli.go b/internal/cli/cli.go index dab8d5c..48fda83 100644 --- a/internal/cli/cli.go +++ b/internal/cli/cli.go @@ -9,7 +9,7 @@ import ( ) var ( - FoFaXVersion = "0.1.42" + FoFaXVersion = "0.1.43" Commit = "unknown" Date = "2022-01-01T01:01:01Z" Branch = "unknown" diff --git a/internal/cli/parser.go b/internal/cli/parser.go index f2757d9..e8bb6ad 100644 --- a/internal/cli/parser.go +++ b/internal/cli/parser.go @@ -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()) diff --git a/internal/fofa/fofa_api.go b/internal/fofa/fofa_api.go index 166cd4c..e74ef0a 100644 --- a/internal/fofa/fofa_api.go +++ b/internal/fofa/fofa_api.go @@ -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 { @@ -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) }