diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 6d6965a82..7249d189f 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -39,7 +39,7 @@ jobs: steps: - uses: actions/setup-go@v3 with: - go-version: '1.18.10' + go-version: '1.21.0' - name: Checkout repository uses: actions/checkout@v2 diff --git a/.github/workflows/go-c-cpp.yml b/.github/workflows/go-c-cpp.yml index 425552fab..6ff2f7b00 100644 --- a/.github/workflows/go-c-cpp.yml +++ b/.github/workflows/go-c-cpp.yml @@ -13,7 +13,7 @@ jobs: steps: - uses: actions/setup-go@v3 with: - go-version: '1.18.10' + go-version: '1.21.0' - name: Install Compilers run: | sudo apt-get update @@ -68,7 +68,7 @@ jobs: steps: - uses: actions/setup-go@v3 with: - go-version: '1.18.10' + go-version: '1.21.0' - name: Install Compilers run: | sudo apt-get update @@ -177,12 +177,15 @@ jobs: install: | uname -a apt-get update - apt-get install --yes wget git golang build-essential pkgconf libelf-dev llvm-12 clang-12 linux-tools-generic linux-tools-common + apt-get install --yes wget git build-essential pkgconf libelf-dev llvm-12 clang-12 linux-tools-generic linux-tools-common + wget https://go.dev/dl/go1.21.0.linux-arm64.tar.gz + rm -rf /usr/local/go + tar -C /usr/local -xzf go1.21.0.linux-arm64.tar.gz # Produce a binary artifact and place it in the mounted volume run: | uname -a date - export PATH=$PATH:/usr/local/bin + export PATH=/usr/local/go/bin:$PATH:/usr/local/bin echo $PATH for tool in "clang" "llc" "llvm-strip" do diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e72336dee..3d2833fcb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: '1.18.10' + go-version: '1.21.0' - name: Install Compilers run: | sudo apt-get update @@ -126,12 +126,15 @@ jobs: install: | uname -a apt-get update - apt-get install --yes wget git build-essential golang pkgconf libelf-dev llvm-12 clang-12 linux-tools-generic linux-tools-common + apt-get install --yes wget git build-essential pkgconf libelf-dev llvm-12 clang-12 linux-tools-generic linux-tools-common + wget https://go.dev/dl/go1.21.0.linux-arm64.tar.gz + rm -rf /usr/local/go + tar -C /usr/local -xzf go1.21.0.linux-arm64.tar.gz # Produce a binary artifact and place it in the mounted volume run: | uname -a date - export PATH=$PATH:/usr/local/bin + export PATH=/usr/local/go/bin:$PATH:/usr/local/bin echo $PATH for tool in "clang" "llc" "llvm-strip" do diff --git a/Makefile b/Makefile index 06c787d3f..80235a2e2 100644 --- a/Makefile +++ b/Makefile @@ -106,12 +106,12 @@ GO_VERSION_MAJ = $(shell echo $(GO_VERSION) | $(CMD_CUT) -d'.' -f1) GO_VERSION_MIN = $(shell echo $(GO_VERSION) | $(CMD_CUT) -d'.' -f2) -# golang 版本检测 1.18 以上 +# golang 版本检测 1.21 以上 .checkver_$(CMD_GO): \ | .check_$(CMD_GO) @if [ ${GO_VERSION_MAJ} -eq 1 ]; then - if [ ${GO_VERSION_MIN} -lt 18 ]; then - echo -n "you MUST use golang 1.18 or newer, " + if [ ${GO_VERSION_MIN} -lt 21 ]; then + echo -n "you MUST use golang 1.21 or newer, " echo "your current golang version is ${GO_VERSION}" exit 1 fi diff --git a/README.md b/README.md index 40baaf6fe..77da58fab 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,7 @@ ps -ef | grep foo Linux Kernel: >= 4.18. ## Tools -* golang 1.18 or newer +* golang 1.21 or newer * clang 9.0 or newer * cmake 3.18.4 or newer * clang backend: llvm 9.0 or newer diff --git a/README_CN.md b/README_CN.md index 2f8a453c8..0750ce5ab 100644 --- a/README_CN.md +++ b/README_CN.md @@ -142,7 +142,7 @@ ps -ef | grep foo > Android版本编译方法见 [eCapture旁观者:Android HTTPS明文抓包](https://mp.weixin.qq.com/s/KWm5d0uuzOzReRtr9PmuWQ) ## 工具链版本 -* golang 1.18 以上 +* golang 1.21 以上 * clang 9.0 以上 * cmake 3.18.4 以上 * clang backend: llvm 9.0 以上 diff --git a/README_JA.md b/README_JA.md index 738e36bd3..2ae275588 100644 --- a/README_JA.md +++ b/README_JA.md @@ -122,7 +122,7 @@ ps -ef | grep foo Linux カーネル: >= 4.18. ## ツール -* golang 1.18 またはそれ以降 +* golang 1.21 またはそれ以降 * clang 9.0 またはそれ以降 * cmake 3.18.4 またはそれ以降 * clang バックエンド: llvm 9.0 またはそれ以降 diff --git a/builder/init_env.sh b/builder/init_env.sh index ff3538138..d339796bc 100644 --- a/builder/init_env.sh +++ b/builder/init_env.sh @@ -42,7 +42,7 @@ if [[ ${UNAME_M} =~ "x86_64" ]];then echo "unsupported arch ${UNAME_M}"; fi -GOBIN_ZIP="go1.18.8.linux-${ARCH}.tar.gz" +GOBIN_ZIP="go1.21.0.linux-${ARCH}.tar.gz" echo "GOBIN_ZIP:${GOBIN_ZIP}" diff --git a/go.mod b/go.mod index b568722fa..620257cf9 100644 --- a/go.mod +++ b/go.mod @@ -1,17 +1,17 @@ module ecapture -go 1.18 +go 1.21 require ( - github.com/cilium/ebpf v0.10.0 - github.com/gojue/ebpfmanager v0.4.3 + github.com/cilium/ebpf v0.12.3 + github.com/gojue/ebpfmanager v0.4.4 github.com/google/gopacket v1.1.19 github.com/shuLhan/go-bindata v4.0.0+incompatible github.com/spf13/cobra v1.4.0 github.com/spf13/pflag v1.0.5 golang.org/x/arch v0.3.0 golang.org/x/crypto v0.14.0 - golang.org/x/sys v0.13.0 + golang.org/x/sys v0.14.1-0.20231108175955-e4099bfacb8c ) require ( @@ -27,6 +27,7 @@ require ( github.com/stretchr/testify v1.7.0 // indirect github.com/vishvananda/netlink v1.1.0 // indirect github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f // indirect + golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 // indirect golang.org/x/net v0.17.0 // indirect golang.org/x/sync v0.1.0 // indirect ) diff --git a/go.sum b/go.sum index 4e976ae5c..04460a6e0 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,8 @@ github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevB github.com/cfc4n/gopacket v1.1.20 h1:jTdmP93F+wCvLaJPk9AhwVjY2F5J4BFkk9MhXzg+5dA= github.com/cfc4n/gopacket v1.1.20/go.mod h1:riddUzxTSBpJXk3qBHtYr4qOhFhT6k/1c0E3qkQjQpA= github.com/cilium/ebpf v0.5.0/go.mod h1:4tRaxcgiL706VnOzHOdBlY8IEAIdxINsQBcU4xJJXRs= -github.com/cilium/ebpf v0.10.0 h1:nk5HPMeoBXtOzbkZBWym+ZWq1GIiHUsBFXxwewXAHLQ= -github.com/cilium/ebpf v0.10.0/go.mod h1:DPiVdY/kT534dgc9ERmvP8mWA+9gvwgKfRvk4nNWnoE= +github.com/cilium/ebpf v0.12.3 h1:8ht6F9MquybnY97at+VDZb3eQQr8ev79RueWeVaEcG4= +github.com/cilium/ebpf v0.12.3/go.mod h1:TctK1ivibvI3znr66ljgi4hqOT8EYQjz1KWBfb1UVgM= github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -12,9 +12,9 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/florianl/go-tc v0.4.0 h1:/g8oCl4OUWt1H4pnThn4iz8SJqV78O5VxAh7ykBN09c= github.com/florianl/go-tc v0.4.0/go.mod h1:qt66GHXQ60ETsKP1qNg2KljTO28UMNLhfAaB/odORY8= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= -github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= -github.com/gojue/ebpfmanager v0.4.3 h1:uiGLdmf77j2T4PAoVj4rQSbKhBpTCPwHj4tV0HDS+uA= -github.com/gojue/ebpfmanager v0.4.3/go.mod h1:IbOQcGaeEvSPY6NtTtkG6xRQ93tNpGcbivMS0hODdA0= +github.com/frankban/quicktest v1.14.5 h1:dfYrrRyLtiqT9GyKXgdh+k4inNeTvmGbuSgZ3lx3GhA= +github.com/gojue/ebpfmanager v0.4.4 h1:avUR5QWTV3f4ju5YC5CzME5Pyi8YIRyIb6TIpCbcZLs= +github.com/gojue/ebpfmanager v0.4.4/go.mod h1:zeUM96/HnqCfZt14zAvT56kypr/M/pQnrvM+wZT/UAg= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -89,6 +89,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 h1:Jvc7gsqn21cJHCmAWx0LiimpP18LZmUxkT5Mp7EZ1mI= +golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -131,8 +133,8 @@ golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.14.1-0.20231108175955-e4099bfacb8c h1:3kC/TjQ+xzIblQv39bCOyRk8fbEeJcDHwbyxPUU2BpA= +golang.org/x/sys v0.14.1-0.20231108175955-e4099bfacb8c/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/main.go b/main.go index 97b0579a4..504635272 100644 --- a/main.go +++ b/main.go @@ -10,7 +10,7 @@ import ( ) const ( - BtfNotSupport = "You can compile a no BTF version by youeself with command `make nocore`,Please read Makefile for more info." + BtfNotSupport = "You can compile the BTF-free version by using the command `make nocore`, please read the Makefile for more information." ) var ( @@ -28,14 +28,14 @@ func main() { switch runtime.GOARCH { case "amd64": if kv < kernel.VersionCode(4, 18, 0) { - log.Fatalf("Linux/Android Kernel (x86_64) version %v is not supported. Need > 4.18 .", kv) + log.Fatalf("The Linux/Android Kernel version %v (x86_64) is not supported. Requires a version greater than 4.18.", kv) } case "arm64": if kv < kernel.VersionCode(5, 5, 0) { - log.Fatalf("Linux/Android Kernel (aarch64) version %v is not supported. Need > 5.5 .", kv) + log.Fatalf("The Linux/Android Kernel version %v (aarch64) is not supported. Requires a version greater than 5.5.", kv) } default: - log.Fatalf("unsupported CPU arch:%v. ", runtime.GOARCH) + log.Fatalf("Unsupported CPU arch:%v. ", runtime.GOARCH) } // 检测是否是容器 @@ -45,15 +45,15 @@ func main() { } if isContainer { - log.Printf("Your environment is a container. We will not detect the BTF config.") + log.Printf("Your environment is like a container. We won't be able to detect the BTF configuration.") } else { enable, e := ebpf.IsEnableBPF() if e != nil { - log.Fatalf("Kernel config read failed, error:%v", e) + log.Fatalf("Failed to read kernel configuration., error:%v", e) } if !enable { - log.Fatalf("Kernel not support, error:%v", e) + log.Fatalf("Unsupported kernel, error:%v", e) } // changed by go build '-ldflags X' @@ -61,10 +61,10 @@ func main() { // BTF支持情况检测 enable, e := ebpf.IsEnableBTF() if e != nil { - log.Fatalf("Can't found BTF config with error:%v.\n"+BtfNotSupport, e) + log.Fatalf("Unable to find BTF configuration due to an error:%v.\n"+BtfNotSupport, e) } if !enable { - log.Fatal("BTF not support, please check it. shell: cat /boot/config-`uname -r` | grep CONFIG_DEBUG_INFO_BTF \n " + + log.Fatal("BTF is not supported, please check it. shell: cat /boot/config-`uname -r` | grep CONFIG_DEBUG_INFO_BTF \n " + BtfNotSupport) } }