mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: fix jetbrains toolbox connection tracking (#19348)
Fixes https://github.com/coder/coder/issues/18350 I attempted the route of relying on just the session env vars, in hopes that this issue was fixed in Toolbox and the process name matching was no longer need, but it was not a fruitful endeavor and it seems to be using the same connection logic as it did in gateway, just with new binary and flag names.
This commit is contained in:
@@ -46,6 +46,8 @@ const (
|
||||
// MagicProcessCmdlineJetBrains is a string in a process's command line that
|
||||
// uniquely identifies it as JetBrains software.
|
||||
MagicProcessCmdlineJetBrains = "idea.vendor.name=JetBrains"
|
||||
MagicProcessCmdlineToolbox = "com.jetbrains.toolbox"
|
||||
MagicProcessCmdlineGateway = "remote-dev-server"
|
||||
|
||||
// BlockedFileTransferErrorCode indicates that SSH server restricted the raw command from performing
|
||||
// the file transfer.
|
||||
|
||||
@@ -53,7 +53,7 @@ func NewJetbrainsChannelWatcher(ctx ssh.Context, logger slog.Logger, reportConne
|
||||
|
||||
// If this is not JetBrains, then we do not need to do anything special. We
|
||||
// attempt to match on something that appears unique to JetBrains software.
|
||||
if !strings.Contains(strings.ToLower(cmdline), strings.ToLower(MagicProcessCmdlineJetBrains)) {
|
||||
if !isJetbrainsProcess(cmdline) {
|
||||
return newChannel
|
||||
}
|
||||
|
||||
@@ -104,3 +104,18 @@ func (c *ChannelOnClose) Close() error {
|
||||
c.once.Do(c.done)
|
||||
return c.Channel.Close()
|
||||
}
|
||||
|
||||
func isJetbrainsProcess(cmdline string) bool {
|
||||
opts := []string{
|
||||
MagicProcessCmdlineJetBrains,
|
||||
MagicProcessCmdlineToolbox,
|
||||
MagicProcessCmdlineGateway,
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
if strings.Contains(strings.ToLower(cmdline), strings.ToLower(opt)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user