Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: removal of deprecated flag support. #388

Merged
merged 2 commits into from
Aug 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,9 @@ bin/ecapture --help
```


## Stargazers over time

[![Stargazers over time](https://starchart.cc/gojue/ecapture.svg)](https://starchart.cc/gojue/ecapture)

# Contributing
See [CONTRIBUTING](./CONTRIBUTING.md) for details on submitting patches and the contribution workflow.
6 changes: 6 additions & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,11 @@ cd ecapture
make nocore
bin/ecapture
```

## Stargazers over time

[![Stargazers over time](https://starchart.cc/gojue/ecapture.svg)](https://starchart.cc/gojue/ecapture)


# 贡献
参考 [CONTRIBUTING](./CONTRIBUTING.md)的介绍,提交issue、PR等,非常感谢。
4 changes: 4 additions & 0 deletions README_JA.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ make nocore
bin/ecapture --help
```

## Stargazers over time

[![Stargazers over time](https://starchart.cc/gojue/ecapture.svg)](https://starchart.cc/gojue/ecapture)


# コントリビュート
パッチの投稿やコントリビューションのワークフローの詳細は [CONTRIBUTING](./CONTRIBUTING.md) を参照してください。
2 changes: 1 addition & 1 deletion cli/cmd/gotls.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func goTLSCommandFunc(command *cobra.Command, args []string) {
conf.SetUid(gConf.Uid)
conf.SetDebug(gConf.Debug)
conf.SetHex(gConf.IsHex)
conf.SetNoSearch(gConf.NoSearch)
//conf.SetNoSearch(gConf.NoSearch)

err = conf.Check()

Expand Down
7 changes: 3 additions & 4 deletions cli/cmd/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ ecapture tls -w save_android.pcapng -i wlan0 --libssl=/apex/com.android.conscryp
}

func init() {
opensslCmd.PersistentFlags().StringVar(&oc.Curlpath, "curl", "", "curl or wget file path, use to dectet openssl.so path, default:/usr/bin/curl. (Deprecated)")
//opensslCmd.PersistentFlags().StringVar(&oc.Curlpath, "curl", "", "curl or wget file path, use to dectet openssl.so path, default:/usr/bin/curl. (Deprecated)")
opensslCmd.PersistentFlags().StringVar(&oc.Openssl, "libssl", "", "libssl.so file path, will automatically find it from curl default.")
opensslCmd.PersistentFlags().StringVar(&oc.CGroupPath, "cgroup_path", "/sys/fs/cgroup", "cgroup path, default: /sys/fs/cgroup.")
opensslCmd.PersistentFlags().StringVar(&gc.Gnutls, "gnutls", "", "libgnutls.so file path, will automatically find it from curl default.")
opensslCmd.PersistentFlags().StringVar(&gc.Curlpath, "wget", "", "wget file path, default: /usr/bin/wget. (Deprecated)")
opensslCmd.PersistentFlags().StringVar(&nc.Firefoxpath, "firefox", "", "firefox file path, default: /usr/lib/firefox/firefox. (Deprecated)")
//opensslCmd.PersistentFlags().StringVar(&gc.Curlpath, "wget", "", "wget file path, default: /usr/bin/wget. (Deprecated)")
//opensslCmd.PersistentFlags().StringVar(&nc.Firefoxpath, "firefox", "", "firefox file path, default: /usr/lib/firefox/firefox. (Deprecated)")
opensslCmd.PersistentFlags().StringVar(&nc.Nsprpath, "nspr", "", "libnspr44.so file path, will automatically find it from curl default.")
opensslCmd.PersistentFlags().StringVarP(&oc.Write, "write", "w", "", "write the raw packets to file as pcapng format.")
opensslCmd.PersistentFlags().StringVarP(&oc.Ifname, "ifname", "i", "", "(TC Classifier) Interface name on which the probe will be attached.")
Expand Down Expand Up @@ -130,7 +130,6 @@ func openSSLCommandFunc(command *cobra.Command, args []string) {
conf.SetUid(gConf.Uid)
conf.SetDebug(gConf.Debug)
conf.SetHex(gConf.IsHex)
conf.SetNoSearch(gConf.NoSearch)

err = conf.Check()

Expand Down
6 changes: 3 additions & 3 deletions user/config/config_gnutls.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ package config
// 最终使用openssl参数
type GnutlsConfig struct {
eConfig
Curlpath string `json:"curlpath"` //curl的文件路径
Gnutls string `json:"gnutls"`
ElfType uint8 //
//Curlpath string `json:"curlpath"` //curl的文件路径
Gnutls string `json:"gnutls"`
ElfType uint8 //
}

func NewGnutlsConfig() *GnutlsConfig {
Expand Down
60 changes: 28 additions & 32 deletions user/config/config_gnutls_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ package config

import (
"os"
"path/filepath"
"strings"

"errors"
)

const DefaultGnutlsPath = "/lib/x86_64-linux-gnu/libgnutls.so.30"

func (gc *GnutlsConfig) Check() error {

// 如果readline 配置,且存在,则直接返回。
Expand All @@ -37,39 +36,36 @@ func (gc *GnutlsConfig) Check() error {
return nil
}

if gc.NoSearch {
return errors.New("NoSearch requires specifying lib path")
}

//如果配置 Curlpath的地址,判断文件是否存在,不存在则直接返回
if gc.Curlpath != "" || len(strings.TrimSpace(gc.Curlpath)) > 0 {
_, e := os.Stat(gc.Curlpath)
if e != nil {
return e
/*
//如果配置 Curlpath的地址,判断文件是否存在,不存在则直接返回
if gc.Curlpath != "" || len(strings.TrimSpace(gc.Curlpath)) > 0 {
_, e := os.Stat(gc.Curlpath)
if e != nil {
return e
}
} else {
//如果没配置,则直接指定。
gc.Curlpath = "/usr/bin/wget"
}
} else {
//如果没配置,则直接指定。
gc.Curlpath = "/usr/bin/wget"
}

soPath, e := getDynPathByElf(gc.Curlpath, "libgnutls.so")
if e != nil {
//gc.logger.Printf("get bash:%s dynamic library error:%v.\n", bash, e)
_, e = os.Stat(X86BinaryPrefix)
prefix := X86BinaryPrefix
soPath, e := getDynPathByElf(gc.Curlpath, "libgnutls.so")
if e != nil {
prefix = OthersBinaryPrefix
//gc.logger.Printf("get bash:%s dynamic library error:%v.\n", bash, e)
_, e = os.Stat(X86BinaryPrefix)
prefix := X86BinaryPrefix
if e != nil {
prefix = OthersBinaryPrefix
}
gc.Gnutls = filepath.Join(prefix, "libgnutls.so.30")
gc.ElfType = ElfTypeSo
_, e = os.Stat(gc.Gnutls)
if e != nil {
return e
}
return nil
}
gc.Gnutls = filepath.Join(prefix, "libgnutls.so.30")
gc.ElfType = ElfTypeSo
_, e = os.Stat(gc.Gnutls)
if e != nil {
return e
}
return nil
}

gc.Gnutls = soPath
*/
gc.Gnutls = DefaultGnutlsPath
gc.ElfType = ElfTypeSo

return nil
Expand Down
6 changes: 3 additions & 3 deletions user/config/config_nspr.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ package config
// 最终使用openssl参数
type NsprConfig struct {
eConfig
Firefoxpath string `json:"firefoxpath"` //curl的文件路径
Nsprpath string `json:"nsprpath"`
ElfType uint8 //
//Firefoxpath string `json:"firefoxpath"` //curl的文件路径
Nsprpath string `json:"nsprpath"`
ElfType uint8 //
}

func NewNsprConfig() *NsprConfig {
Expand Down
66 changes: 33 additions & 33 deletions user/config/config_nspr_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ package config

import (
"os"
"path/filepath"
"strings"

"errors"
)

const DefaultNsprNssPath = "/usr/lib/firefox/libnspr4.so"

func (nc *NsprConfig) Check() error {

// 如果readline 配置,且存在,则直接返回。
Expand All @@ -36,43 +35,44 @@ func (nc *NsprConfig) Check() error {
nc.ElfType = ElfTypeSo
return nil
}
/*
if nc.NoSearch {
return errors.New("NoSearch requires specifying lib path")
}

if nc.NoSearch {
return errors.New("NoSearch requires specifying lib path")
}

//如果配置 Curlpath的地址,判断文件是否存在,不存在则直接返回
if nc.Firefoxpath != "" || len(strings.TrimSpace(nc.Firefoxpath)) > 0 {
_, e := os.Stat(nc.Firefoxpath)
if e != nil {
return e
//如果配置 Curlpath的地址,判断文件是否存在,不存在则直接返回
if nc.Firefoxpath != "" || len(strings.TrimSpace(nc.Firefoxpath)) > 0 {
_, e := os.Stat(nc.Firefoxpath)
if e != nil {
return e
}
} else {
//如果没配置,则直接指定。
nc.Firefoxpath = "/usr/lib/firefox/firefox"
}
} else {
//如果没配置,则直接指定。
nc.Firefoxpath = "/usr/lib/firefox/firefox"
}

soPath, e := getDynPathByElf(nc.Firefoxpath, "libnspr4.so")
if e != nil {
//nc.logger.Printf("get bash:%s dynamic library error:%v.\n", bash, e)
_, e = os.Stat(X86BinaryPrefix)
prefix := X86BinaryPrefix
soPath, e := getDynPathByElf(nc.Firefoxpath, "libnspr4.so")
if e != nil {
prefix = OthersBinaryPrefix
//nc.logger.Printf("get bash:%s dynamic library error:%v.\n", bash, e)
_, e = os.Stat(X86BinaryPrefix)
prefix := X86BinaryPrefix
if e != nil {
prefix = OthersBinaryPrefix
}
nc.Nsprpath = filepath.Join(prefix, "libnspr4.so")
//nc.Gnutls = "/usr/lib/firefox/libnss3.so"
//"/usr/lib/firefox/libnspr4.so"
nc.ElfType = ElfTypeSo
_, e = os.Stat(nc.Nsprpath)
if e != nil {
return e
}
return nil
}
nc.Nsprpath = filepath.Join(prefix, "libnspr4.so")
//nc.Gnutls = "/usr/lib/firefox/libnss3.so"
//"/usr/lib/firefox/libnspr4.so"
nc.ElfType = ElfTypeSo
_, e = os.Stat(nc.Nsprpath)
if e != nil {
return e
}
return nil
}
*/

nc.Nsprpath = soPath
nc.Nsprpath = DefaultNsprNssPath
nc.ElfType = ElfTypeSo

return nil
}
4 changes: 2 additions & 2 deletions user/config/config_openssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const cgroupPathCentos = "/mnt/ecapture_cgroupv2" // centos
// 最终使用openssl参数
type OpensslConfig struct {
eConfig
Curlpath string `json:"curlPath"` //curl的文件路径
Openssl string `json:"openssl"`
//Curlpath string `json:"curlPath"` //curl的文件路径
Openssl string `json:"openssl"`
//Pthread string `json:"pThread"` // /lib/x86_64-linux-gnu/libpthread.so.0
Write string `json:"write"` // Write the raw packets to file rather than parsing and printing them out.
Ifname string `json:"ifName"` // (TC Classifier) Interface name on which the probe will be attached.
Expand Down
70 changes: 30 additions & 40 deletions user/config/config_openssl_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,30 @@
package config

import (
"errors"
"os"
"path/filepath"
"strings"
)

const (
DefaultIfname = "eth0"
DefaultIfname = "eth0"
DefaultOpensslPath = "/apex/com.android.conscrypt/lib64/libssl.so"
)

func (oc *OpensslConfig) checkOpenssl() error {
soPath, e := getDynPathByElf(oc.Curlpath, "libssl.so")
var e error
_, e = os.Stat(X86BinaryPrefix)
prefix := X86BinaryPrefix
if e != nil {
//oc.logger.Printf("get bash:%s dynamic library error:%v.\n", bash, e)
_, e = os.Stat(X86BinaryPrefix)
prefix := X86BinaryPrefix
if e != nil {
prefix = OthersBinaryPrefix
}
prefix = OthersBinaryPrefix
}

// ubuntu 21.04 libssl.so.1.1 default
oc.Openssl = filepath.Join(prefix, "libssl.so.1.1")
oc.ElfType = ElfTypeSo
_, e = os.Stat(oc.Openssl)
if e != nil {
return e
}
} else {
oc.Openssl = soPath
oc.ElfType = ElfTypeSo
// ubuntu 21.04 libssl.so.1.1 default
oc.Openssl = filepath.Join(prefix, "libssl.so.1.1")
oc.ElfType = ElfTypeSo
_, e = os.Stat(oc.Openssl)
if e != nil {
return e
}
return nil
}
Expand All @@ -64,30 +58,26 @@ func (oc *OpensslConfig) Check() error {
oc.ElfType = ElfTypeSo
checkedOpenssl = true
}

//如果配置 Curlpath的地址,判断文件是否存在,不存在则直接返回
if oc.Curlpath != "" || len(strings.TrimSpace(oc.Curlpath)) > 0 {
_, e := os.Stat(oc.Curlpath)
if e != nil {
return e
/*
//如果配置 Curlpath的地址,判断文件是否存在,不存在则直接返回
if oc.Curlpath != "" || len(strings.TrimSpace(oc.Curlpath)) > 0 {
_, e := os.Stat(oc.Curlpath)
if e != nil {
return e
}
} else {
//如果没配置,则直接指定。
oc.Curlpath = "/usr/bin/curl"
}
} else {
//如果没配置,则直接指定。
oc.Curlpath = "/usr/bin/curl"
}

if oc.Ifname == "" || len(strings.TrimSpace(oc.Ifname)) == 0 {
oc.Ifname = DefaultIfname
}

if checkedOpenssl {
return nil
}

if oc.NoSearch {
return errors.New("NoSearch requires specifying lib path")
}
if oc.Ifname == "" || len(strings.TrimSpace(oc.Ifname)) == 0 {
oc.Ifname = DefaultIfname
}

if checkedOpenssl {
return nil
}
*/
if !checkedOpenssl {
e := oc.checkOpenssl()
if e != nil {
Expand Down
Loading