Skip to content

Commit

Permalink
more fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
omrikiei committed Dec 29, 2024
1 parent 93f35b9 commit f7bf3c9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
4 changes: 4 additions & 0 deletions cmd/expose.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ ktunnel expose redis 6379

// Kube Service
kubeService, err := k8s.NewKubeService(KubeContext, Namespace)
if err != nil {
log.Fatalf("Failed to start k8s clients: %v", err)
os.Exit(1)
}
// port-Forward
strPort := strconv.FormatInt(int64(port), 10)
stopChan := make(chan struct{}, 1)
Expand Down
4 changes: 2 additions & 2 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ ktunnel server -p 8181
// Run tunnel client and establish connection

sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM, syscall.SIGKILL, syscall.SIGQUIT)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
go func() {
o.Do(func() {
_ = <-sigs
<-sigs
log.Info("Got exit signal, closing client tunnels")
cancel()
})
Expand Down
12 changes: 4 additions & 8 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package client implements the ktunnel client
package client

import (
Expand All @@ -18,11 +19,6 @@ import (
"google.golang.org/grpc/credentials/insecure"
)

type Message struct {
c *net.Conn
d *[]byte
}

func ReceiveData(conf *Config, st pb.Tunnel_InitTunnelClient, sessionsOut chan<- *common.Session, host string, port int32, scheme string) {
loop:
for {
Expand All @@ -39,15 +35,15 @@ loop:
break loop
}

requestId, err := uuid.Parse(m.RequestId)
requestId, err := uuid.Parse(m.RequestID)

Check failure on line 38 in pkg/client/client.go

View workflow job for this annotation

GitHub Actions / Run Tests and Analysis

var requestId should be requestID (ST1003)
if err != nil {
conf.log.WithError(err).WithField("session", m.RequestId).Errorf("failed parsing session uuid from stream, skipping")
conf.log.WithError(err).WithField("session", m.RequestID).Errorf("failed parsing session uuid from stream, skipping")
}

session, exists := common.GetSession(requestId)
if exists == false {

Check failure on line 44 in pkg/client/client.go

View workflow job for this annotation

GitHub Actions / Run Tests and Analysis

should omit comparison to bool constant, can be simplified to !exists (S1002)
conf.log.WithFields(log.Fields{
"session": m.RequestId,
"session": m.RequestID,
"host": host,
"port": port,
}).Infof("new connection")
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func SendData(conf *Config, stream pb.Tunnel_InitTunnelServer, sessions <-chan *
HasErr: false,
LogMessage: nil,
Data: bytes,
RequestId: session.Id.String(),
RequestID: session.Id.String(),
ShouldClose: !session.Open,
}
session.Unlock()
Expand Down
8 changes: 4 additions & 4 deletions tunnel_pb/tunnel.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f7bf3c9

Please sign in to comment.