xiecat / fofax

FOFAX是一个基于fofa.info的API命令行查询工具
https://fofax.xiecat.fun/
GNU General Public License v3.0
719 stars 74 forks source link

Mac m1 运行报错 #29

Closed alchu4n closed 1 year ago

alchu4n commented 1 year ago
fofax -q 'app="APACHE-Solr"'

      ____        ____       _  __
     / __/____   / __/____ _| |/ /
    / /_ / __ \ / /_ / __ `/|   /
   / __// /_/ // __// /_/ //   |
  /_/   \____//_/   \__,_//_/|_|
                    v0.1.43
            https://fofax.xiecat.fun

2023/04/15 15:58:13 [INFO] No new updates found for fofax engine!
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x104c41150]

goroutine 1 [running]:
github.com/xiecat/fofax/internal/cli.updateTips({0x104c48c23?, 0x14?})
    /Users/ksc/go/pkg/mod/github.com/xiecat/fofax@v0.1.43/internal/cli/update.go:29 +0xe0
github.com/xiecat/fofax/internal/cli.checkUpdateInfo()
    /Users/ksc/go/pkg/mod/github.com/xiecat/fofax@v0.1.43/internal/cli/parser.go:427 +0x248
github.com/xiecat/fofax/internal/cli.ParseOptions()
    /Users/ksc/go/pkg/mod/github.com/xiecat/fofax@v0.1.43/internal/cli/parser.go:330 +0x37c
main.main()
    /Users/ksc/go/pkg/mod/github.com/xiecat/fofax@v0.1.43/cmd/fofax/fofax.go:11 +0x1c
alchu4n commented 1 year ago
image
0xf4n9x commented 1 year ago

我在M1的macOS上,并没有复现出来。大概率应该是网络环境的原因,请切换下代理,然后再次尝试。

➜  ~  system_profiler SPHardwareDataType
Hardware:

    Hardware Overview:

      Model Name: MacBook Pro
      Model Identifier: MacBookPro18,3
      Chip: Apple M1 Pro
      ...

➜  ~  fofax -q 'app="APACHE-Solr"'

      ____        ____       _  __
     / __/____   / __/____ _| |/ /
    / /_ / __ \ / /_ / __ `/|   /
   / __// /_/ // __// /_/ //   |
  /_/   \____//_/   \__,_//_/|_|
                    v0.1.43
            https://fofax.xiecat.fun

2023/04/15 18:04:49 [SUCC] Fetch Data From FoFa: [100/978764]
47.111.49.40:30001
47.113.156.29:8087
...

这个问题我已经定位到相关存在Bug的代码了,下个小版本会修复这个Bug。

Becivells commented 1 year ago

目前来说应该是第一更新网络有问题才会出现。后续使用没影响。修复内容随下个版本发布

alchu4n commented 1 year ago

我定位到updateTips函数中的latest, err := updateFoFaXVersionToLatest() 这行需要添加 if latest == nil { return errors.New("latest version is nil") }

整体函数代码如下: func updateTips(tagName string) error { tagName = fmt.Sprintf("v%s", strings.TrimPrefix(tagName, "v")) if strings.HasSuffix(tagName, "-next") { printer.Debug("Self-compiled versions do not check for updates") return nil } latest, err := updateFoFaXVersionToLatest() if latest == nil { return errors.New("latest version is nil") } if err != nil { return err } if !args.Update { bannerSite(fmt.Sprintf("New:\n\nVersion:%s\n\n%s\n", latest.Version, latest.Notes)) bannerSite("Please Use [./fofax -update] to download\n\n") } return nil }

0xf4n9x commented 1 year ago

Thx!