Skip to content

Commit

Permalink
[ssh-gateway] add track for ssh channel open
Browse files Browse the repository at this point in the history
  • Loading branch information
iQQBot committed Jun 28, 2022
1 parent 2dd0a29 commit f8d4182
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions components/ws-proxy/pkg/sshproxy/forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func (s *Server) ChannelForward(ctx context.Context, session *Session, targetCon
log.WithFields(log.OWI("", session.WorkspaceID, session.InstanceID)).Error("accept origin channel failed")
return
}
TrackSSHConnectionChannel(session, originChannel.ChannelType())
if originChannel.ChannelType() == "session" {
originChan = startHeartbeatingChannel(originChan, s.Heartbeater, session)
}
Expand Down Expand Up @@ -104,6 +105,18 @@ func TrackIDECloseSignal(session *Session) {
})
}

func TrackSSHConnectionChannel(session *Session, channel string) {
propertics := make(map[string]interface{})
propertics["workspaceId"] = session.WorkspaceID
propertics["instanceId"] = session.InstanceID
propertics["channel"] = channel
tracker.Track(analytics.TrackMessage{
Identity: analytics.Identity{UserID: session.OwnerUserId},
Event: "ssh_connection_channel",
Properties: propertics,
})
}

func startHeartbeatingChannel(c ssh.Channel, heartbeat Heartbeat, session *Session) ssh.Channel {
ctx, cancel := context.WithCancel(context.Background())
res := &heartbeatingChannel{
Expand Down

0 comments on commit f8d4182

Please sign in to comment.