mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-07-31 16:25:22 +00:00
This reverts commit 50c0062db4
.
This commit is contained in:
parent
50c0062db4
commit
94dfa68858
@ -4,14 +4,13 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/elastic/go-elasticsearch/v7"
|
"github.com/elastic/go-elasticsearch/v7"
|
||||||
"github.com/up9inc/mizu/shared"
|
"github.com/up9inc/mizu/shared"
|
||||||
"github.com/up9inc/mizu/shared/logger"
|
"github.com/up9inc/mizu/shared/logger"
|
||||||
"github.com/up9inc/mizu/tap/api"
|
"github.com/up9inc/mizu/tap/api"
|
||||||
|
"net/http"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type client struct {
|
type client struct {
|
||||||
@ -32,9 +31,6 @@ func GetInstance() *client {
|
|||||||
|
|
||||||
func (client *client) Configure(config shared.ElasticConfig) {
|
func (client *client) Configure(config shared.ElasticConfig) {
|
||||||
if config.Url == "" || config.User == "" || config.Password == "" {
|
if config.Url == "" || config.User == "" || config.Password == "" {
|
||||||
if client.es != nil {
|
|
||||||
client.es = nil
|
|
||||||
}
|
|
||||||
logger.Log.Infof("No elastic configuration was supplied, elastic exporter disabled")
|
logger.Log.Infof("No elastic configuration was supplied, elastic exporter disabled")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -50,13 +46,13 @@ func (client *client) Configure(config shared.ElasticConfig) {
|
|||||||
|
|
||||||
es, err := elasticsearch.NewClient(cfg)
|
es, err := elasticsearch.NewClient(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Log.Errorf("Failed to initialize elastic client %v", err)
|
logger.Log.Fatalf("Failed to initialize elastic client %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Have the client instance return a response
|
// Have the client instance return a response
|
||||||
res, err := es.Info()
|
res, err := es.Info()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Log.Errorf("Elastic client.Info() ERROR: %v", err)
|
logger.Log.Fatalf("Elastic client.Info() ERROR: %v", err)
|
||||||
} else {
|
} else {
|
||||||
client.es = es
|
client.es = es
|
||||||
client.index = "mizu_traffic_http_" + time.Now().Format("2006_01_02_15_04")
|
client.index = "mizu_traffic_http_" + time.Now().Format("2006_01_02_15_04")
|
||||||
|
@ -33,23 +33,10 @@ func (g *oasGenerator) Start() {
|
|||||||
g.entriesChan = make(chan EntryWithSource, 100) // buffer up to 100 entries for OAS processing
|
g.entriesChan = make(chan EntryWithSource, 100) // buffer up to 100 entries for OAS processing
|
||||||
g.ServiceSpecs = &sync.Map{}
|
g.ServiceSpecs = &sync.Map{}
|
||||||
g.started = true
|
g.started = true
|
||||||
go instance.runGenerator()
|
go instance.runGeneretor()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *oasGenerator) Stop() {
|
func (g *oasGenerator) runGeneretor() {
|
||||||
if !g.started {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
g.cancel()
|
|
||||||
g.Reset()
|
|
||||||
g.started = false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *oasGenerator) IsStarted() bool {
|
|
||||||
return g.started
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *oasGenerator) runGenerator() {
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-g.ctx.Done():
|
case <-g.ctx.Done():
|
||||||
|
@ -32,7 +32,6 @@ type serviceMap struct {
|
|||||||
|
|
||||||
type ServiceMap interface {
|
type ServiceMap interface {
|
||||||
Enable()
|
Enable()
|
||||||
Disable()
|
|
||||||
IsEnabled() bool
|
IsEnabled() bool
|
||||||
NewTCPEntry(source *tapApi.TCP, destination *tapApi.TCP, protocol *tapApi.Protocol)
|
NewTCPEntry(source *tapApi.TCP, destination *tapApi.TCP, protocol *tapApi.Protocol)
|
||||||
GetStatus() ServiceMapStatus
|
GetStatus() ServiceMapStatus
|
||||||
@ -160,11 +159,6 @@ func (s *serviceMap) Enable() {
|
|||||||
s.enabled = true
|
s.enabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *serviceMap) Disable() {
|
|
||||||
s.Reset()
|
|
||||||
s.enabled = false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *serviceMap) IsEnabled() bool {
|
func (s *serviceMap) IsEnabled() bool {
|
||||||
return s.enabled
|
return s.enabled
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user