mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-20 01:32:40 +00:00
WIP
This commit is contained in:
@@ -4,12 +4,21 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"k8s.io/kubectl/pkg/proxy"
|
||||
"time"
|
||||
)
|
||||
|
||||
func StartProxy(ctx context.Context, kubernetesProvider *Provider, mizuPort uint16, mizuNamespace string, mizuServiceName string) error {
|
||||
server, err := proxy.NewServer("", "/", "", nil, &kubernetesProvider.clientConfig, 0)
|
||||
//o := cmdProxy.NewProxyOptions(genericclioptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr})
|
||||
filter := &proxy.FilterServer{
|
||||
AcceptPaths: proxy.MakeRegexpArrayOrDie(proxy.DefaultPathAcceptRE),
|
||||
RejectPaths: proxy.MakeRegexpArrayOrDie(proxy.DefaultPathRejectRE),
|
||||
AcceptHosts: proxy.MakeRegexpArrayOrDie(proxy.DefaultHostAcceptRE),
|
||||
RejectMethods: proxy.MakeRegexpArrayOrDie(proxy.DefaultMethodRejectRE),
|
||||
}
|
||||
|
||||
l, err := server.Listen("0.0.0.0", int(mizuPort))
|
||||
server, err := proxy.NewServer("", "/", "/static/", filter, &kubernetesProvider.clientConfig, time.Second * 1)
|
||||
|
||||
l, err := server.Listen("127.0.0.1", int(mizuPort))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -18,6 +27,7 @@ func StartProxy(ctx context.Context, kubernetesProvider *Provider, mizuPort uint
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
fmt.Printf("Closing connection due to context done")
|
||||
err := l.Close()
|
||||
if err != nil {
|
||||
fmt.Printf("Error stopping proxy network handler %v", err)
|
||||
@@ -26,6 +36,6 @@ func StartProxy(ctx context.Context, kubernetesProvider *Provider, mizuPort uint
|
||||
}
|
||||
}
|
||||
}()
|
||||
fmt.Printf("Mizu is available at http://localhost:%d/api/v1/namespaces/%s/services/%s:80/proxy", mizuPort, mizuNamespace, mizuServiceName)
|
||||
fmt.Printf("Mizu is available at http://localhost:%d/api/v1/namespaces/%s/services/%s:80/proxy\n", mizuPort, mizuNamespace, mizuServiceName)
|
||||
return server.ServeOnListener(l)
|
||||
}
|
||||
|
Reference in New Issue
Block a user