Skip to content

Commit

Permalink
Add single-mode to trace only one TLS type connection
Browse files Browse the repository at this point in the history
When run ecapture in Kubernetes pod, ecapture is given
--libssl, --pthread to specific lib location, but ecapture
continues to auto detect gnutls lib and result in error

2022/06/05 16:46:48 pid info :3305486
2022/06/05 16:46:48 start to run EBPFProbeOPENSSL module
2022/06/05 16:46:48 start to run EBPFProbeGNUTLS module <====
2022/06/05 16:46:48 lstat /etc/ld.so.conf: no such file or directory <===
2022/06/05 16:46:48 invalid argument <====

see #69

add single-mode to stop the auto detection of gnutls lib when
we only want to trace libssl connection

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
  • Loading branch information
vincentmli committed Jun 7, 2022
1 parent ed5ebf1 commit 2607155
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cli/cmd/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import (
// GlobalFlags are flags that defined globally
// and are inherited to all sub-commands.
type GlobalFlags struct {
IsHex bool
Debug bool
Pid uint64 // PID
IsHex bool
Debug bool
Pid uint64 // PID
IsSingleMode bool // only trace one TLS type connection
}

func getGlobalConf(command *cobra.Command) (conf GlobalFlags, err error) {
Expand All @@ -31,5 +32,10 @@ func getGlobalConf(command *cobra.Command) (conf GlobalFlags, err error) {
if err != nil {
return
}

conf.IsSingleMode, err = command.Flags().GetBool("single-mode")
if err != nil {
return
}
return
}
1 change: 1 addition & 0 deletions cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,6 @@ func init() {
//rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
rootCmd.PersistentFlags().BoolVarP(&globalFlags.Debug, "debug", "d", false, "enable debug logging")
rootCmd.PersistentFlags().BoolVar(&globalFlags.IsHex, "hex", false, "print byte strings as hex encoded strings")
rootCmd.PersistentFlags().BoolVar(&globalFlags.IsSingleMode, "single-mode", false, "single tls mode trace")
rootCmd.PersistentFlags().Uint64VarP(&globalFlags.Pid, "pid", "p", defaultPid, "if pid is 0 then we target all pids")
}
3 changes: 3 additions & 0 deletions cli/cmd/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ func openSSLCommandFunc(command *cobra.Command, args []string) {
}
}(mod)
runMods++
if gConf.IsSingleMode {
break
}
}

// needs runmods > 0
Expand Down

0 comments on commit 2607155

Please sign in to comment.