mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-08-09 04:19:22 +00:00
Add an environment variable to test Golang locally
This commit is contained in:
parent
be1a572f35
commit
e0a7a04543
@ -14,9 +14,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/cpu"
|
"github.com/shirou/gopsutil/cpu"
|
||||||
"github.com/struCoder/pidusage"
|
"github.com/struCoder/pidusage"
|
||||||
@ -278,7 +278,16 @@ func startTlsTapper(extension *api.Extension, outputItems chan *api.OutputChanne
|
|||||||
// A quick way to instrument libssl.so without PID filtering - used for debuging and troubleshooting
|
// A quick way to instrument libssl.so without PID filtering - used for debuging and troubleshooting
|
||||||
//
|
//
|
||||||
if os.Getenv("MIZU_GLOBAL_SSL_LIBRARY") != "" {
|
if os.Getenv("MIZU_GLOBAL_SSL_LIBRARY") != "" {
|
||||||
if err := tls.GlobalTap(os.Getenv("MIZU_GLOBAL_SSL_LIBRARY")); err != nil {
|
if err := tls.GlobalSsllibTap(os.Getenv("MIZU_GLOBAL_SSL_LIBRARY")); err != nil {
|
||||||
|
tlstapper.LogError(err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// A quick way to instrument Go `crypto/tls` without PID filtering - used for debuging and troubleshooting
|
||||||
|
//
|
||||||
|
if os.Getenv("MIZU_GLOBAL_GOLANG_PID") != "" {
|
||||||
|
if err := tls.GlobalGolangTap(os.Getenv("MIZU_GLOBAL_GOLANG_PID")); err != nil {
|
||||||
tlstapper.LogError(err)
|
tlstapper.LogError(err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package tlstapper
|
package tlstapper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/cilium/ebpf/rlimit"
|
"github.com/cilium/ebpf/rlimit"
|
||||||
@ -67,10 +68,24 @@ func (t *TlsTapper) PollForLogging() {
|
|||||||
t.bpfLogger.poll()
|
t.bpfLogger.poll()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TlsTapper) GlobalTap(sslLibrary string) error {
|
func (t *TlsTapper) GlobalSsllibTap(sslLibrary string) error {
|
||||||
return t.tapLibsslPid(GLOABL_TAP_PID, sslLibrary, api.UNKNOWN_NAMESPACE)
|
return t.tapLibsslPid(GLOABL_TAP_PID, sslLibrary, api.UNKNOWN_NAMESPACE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *TlsTapper) GlobalGolangTap(_pid string) error {
|
||||||
|
pid, err := strconv.Atoi(_pid)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
p, err := ps.FindProcess(pid)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return t.tapGolangPid(uint32(pid), p.Executable(), api.UNKNOWN_NAMESPACE)
|
||||||
|
}
|
||||||
|
|
||||||
func (t *TlsTapper) AddSsllibPid(procfs string, pid uint32, namespace string) error {
|
func (t *TlsTapper) AddSsllibPid(procfs string, pid uint32, namespace string) error {
|
||||||
sslLibrary, err := findSsllib(procfs, pid)
|
sslLibrary, err := findSsllib(procfs, pid)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user