Skip to content

Commit

Permalink
fix: respond to requests even if local is not responding
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredallard committed Sep 26, 2020
1 parent 577c274 commit ca23aa5
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ loop:
conn, err := net.DialTimeout(strings.ToLower(scheme), fmt.Sprintf("localhost:%d", port), time.Millisecond*500)
if err != nil {
log.WithError(err).Errorf("failed connecting to localhost on port %d scheme %s", port, scheme)
break loop
session = &common.Session{
Open: false,
}
} else {
session = common.NewSessionFromStream(requestId, conn)
go ReadFromSession(session, sessionsOut)
}
session = common.NewSessionFromStream(requestId, conn)
go ReadFromSession(session, sessionsOut)
} else if m.ShouldClose {
session.Open = false
}
Expand Down Expand Up @@ -208,12 +211,13 @@ func RunClient(ctx context.Context, host *string, port *int, scheme string, tls
err := stream.Send(req)
if err != nil {
log.WithError(err).Errorf("Failed to send initial tunnel request to server")
} else {
sessions := make(chan *common.Session)
go ReceiveData(ctx, stream, sessions, tunnelData.Target, scheme)
go SendData(ctx, stream, sessions)
<-ctx.Done()
return
}

sessions := make(chan *common.Session)
go ReceiveData(ctx, stream, sessions, tunnelData.Target, scheme)
go SendData(ctx, stream, sessions)
<-ctx.Done()
}

}()
Expand Down

0 comments on commit ca23aa5

Please sign in to comment.