Skip to content

Commit 0a853cd

Browse files
committed
Improve operator disconnection handling
1 parent a53c2f3 commit 0a853cd

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

cmd/client/tui/tui.go

+1
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ func (app *App) HandleOperatorEvents() {
444444
for {
445445
event, err := eventStream.Recv()
446446
if err != nil {
447+
app.operator.Disconnect()
447448
return
448449
}
449450

internal/operator/entity.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/ttpreport/ligolo-mp/internal/certificate"
1515
pb "github.com/ttpreport/ligolo-mp/protobuf"
1616
"google.golang.org/grpc"
17+
"google.golang.org/grpc/connectivity"
1718
"google.golang.org/grpc/credentials"
1819
)
1920

@@ -124,7 +125,7 @@ func (oper *Operator) Disconnect() error {
124125

125126
func (oper *Operator) IsConnected() bool {
126127
if oper.conn != nil {
127-
return true
128+
return oper.conn.GetState() != connectivity.Shutdown
128129
}
129130

130131
return false

0 commit comments

Comments
 (0)