| 71 | } |
| 72 | |
| 73 | func (w *JetbrainsChannelWatcher) Accept() (gossh.Channel, <-chan *gossh.Request, error) { |
| 74 | disconnected := w.reportConnection(uuid.New(), MagicSessionTypeJetBrains, w.originAddr) |
| 75 | |
| 76 | c, r, err := w.NewChannel.Accept() |
| 77 | if err != nil { |
| 78 | disconnected(1, err.Error()) |
| 79 | return c, r, err |
| 80 | } |
| 81 | w.jetbrainsCounter.Add(1) |
| 82 | // nolint: gocritic // JetBrains is a proper noun and should be capitalized |
| 83 | w.logger.Debug(context.Background(), "JetBrains watcher accepted channel") |
| 84 | |
| 85 | return &ChannelOnClose{ |
| 86 | Channel: c, |
| 87 | done: func() { |
| 88 | w.jetbrainsCounter.Add(-1) |
| 89 | disconnected(0, "normal close") |
| 90 | // nolint: gocritic // JetBrains is a proper noun and should be capitalized |
| 91 | w.logger.Debug(context.Background(), "JetBrains channel closed", |
| 92 | codersdk.ConnectionDirectionAgentToClient.SlogField(), |
| 93 | codersdk.DisconnectReasonGraceful.SlogField(), |
| 94 | codersdk.DisconnectReasonGraceful.SlogExpectedField(), |
| 95 | ) |
| 96 | }, |
| 97 | }, r, err |
| 98 | } |
| 99 | |
| 100 | type ChannelOnClose struct { |
| 101 | gossh.Channel |