Skip to content

Commit 64ea05d

Browse files
committed
Rename channel watcher to be specific to Jetbrains
1 parent 978de9a commit 64ea05d

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

agent/agentssh/agentssh.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ func NewServer(ctx context.Context, logger slog.Logger, prometheusRegistry *prom
112112
srv := &ssh.Server{
113113
ChannelHandlers: map[string]ssh.ChannelHandler{
114114
"direct-tcpip": func(srv *ssh.Server, conn *gossh.ServerConn, newChan gossh.NewChannel, ctx ssh.Context) {
115-
// wrapper is designed to find and track jetbrains gateway connections.
116-
wrapped := NewChannelAcceptWatcher(ctx, s.logger, newChan, &s.connCountJetBrains)
115+
// Wrapper is designed to find and track JetBrains Gateway connections.
116+
wrapped := NewJetbrainsChannelWatcher(ctx, s.logger, newChan, &s.connCountJetBrains)
117117
ssh.DirectTCPIPHandler(srv, conn, wrapped, ctx)
118118
},
119119
"direct-streamlocal@openssh.com": directStreamLocalHandler,
@@ -295,8 +295,8 @@ func (s *Server) sessionStart(logger slog.Logger, session ssh.Session, extraEnv
295295
s.connCountVSCode.Add(1)
296296
defer s.connCountVSCode.Add(-1)
297297
case MagicSessionTypeJetBrains:
298-
// Do nothing here because jetbrains launches hundreds of ssh sessions.
299-
// We instead track jetbrains in the single persistent tcp forwarding channel.
298+
// Do nothing here because JetBrains launches hundreds of ssh sessions.
299+
// We instead track JetBrains in the single persistent tcp forwarding channel.
300300
case "":
301301
s.connCountSSHSession.Add(1)
302302
defer s.connCountSSHSession.Add(-1)

agent/agentssh/jetbrainstrack.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ type localForwardChannelData struct {
1919
OriginPort uint32
2020
}
2121

22-
// ChannelAcceptWatcher is used to track jetbrains port forwarding (gateway)
23-
// connections. If the port forward is something other than jetbrains, this
24-
// struct is a noop.
25-
type ChannelAcceptWatcher struct {
22+
// JetbrainsChannelWatcher is used to track JetBrains port forwarded (Gateway)
23+
// channels. If the port forward is something other than JetBrains, this struct
24+
// is a noop.
25+
type JetbrainsChannelWatcher struct {
2626
gossh.NewChannel
2727
jetbrainsCounter *atomic.Int64
2828
}
2929

30-
func NewChannelAcceptWatcher(ctx ssh.Context, logger slog.Logger, newChannel gossh.NewChannel, counter *atomic.Int64) gossh.NewChannel {
30+
func NewJetbrainsChannelWatcher(ctx ssh.Context, logger slog.Logger, newChannel gossh.NewChannel, counter *atomic.Int64) gossh.NewChannel {
3131
d := localForwardChannelData{}
3232
if err := gossh.Unmarshal(newChannel.ExtraData(), &d); err != nil {
3333
// If the data fails to unmarshal, do nothing.
@@ -58,13 +58,13 @@ func NewChannelAcceptWatcher(ctx ssh.Context, logger slog.Logger, newChannel gos
5858
logger.Debug(ctx, "discovered forwarded JetBrains process",
5959
slog.F("destination_port", d.DestPort))
6060

61-
return &ChannelAcceptWatcher{
61+
return &JetbrainsChannelWatcher{
6262
NewChannel: newChannel,
6363
jetbrainsCounter: counter,
6464
}
6565
}
6666

67-
func (w *ChannelAcceptWatcher) Accept() (gossh.Channel, <-chan *gossh.Request, error) {
67+
func (w *JetbrainsChannelWatcher) Accept() (gossh.Channel, <-chan *gossh.Request, error) {
6868
c, r, err := w.NewChannel.Accept()
6969
if err != nil {
7070
return c, r, err

0 commit comments

Comments
 (0)