More paste fixes

This commit is contained in:
Andy Dixon
2026-06-02 11:56:18 +01:00
parent 74f16bfd0d
commit fb230ee35d
4 changed files with 262 additions and 33 deletions
+24 -15
View File
@@ -14,6 +14,7 @@ import (
"time"
"github.com/andydixon/nexus/internal/models"
"github.com/andydixon/nexus/internal/terminalenv"
"github.com/pquerna/otp/totp"
"golang.org/x/crypto/ssh"
"golang.org/x/net/proxy"
@@ -23,21 +24,21 @@ import (
// It handles connection establishment, authentication, PTY allocation,
// terminal resize propagation, port forwarding, and clean shutdown.
type Client struct {
mu sync.Mutex
config *models.Profile
sshClient *ssh.Client
session *ssh.Session
stdin io.WriteCloser
stdout io.Reader
stderr io.Reader
connected bool
onData func(data []byte)
onError func(err error)
onClose func()
ctx context.Context
cancel context.CancelFunc
forwards *ForwardManager // port forwarding tunnels
agentCleanup func() // closes agent socket connection
mu sync.Mutex
config *models.Profile
sshClient *ssh.Client
session *ssh.Session
stdin io.WriteCloser
stdout io.Reader
stderr io.Reader
connected bool
onData func(data []byte)
onError func(err error)
onClose func()
ctx context.Context
cancel context.CancelFunc
forwards *ForwardManager // port forwarding tunnels
agentCleanup func() // closes agent socket connection
}
// NewClient creates a new SSH client bound to the given profile.
@@ -164,6 +165,14 @@ func (c *Client) connectInternal(
ssh.IUTF8: 1,
}
sessionEnv := terminalenv.SSHEnvVars(sc.EnvVars)
for _, key := range terminalenv.SortedEnvKeys(sessionEnv) {
// Servers may reject env requests unless AcceptEnv permits them. Locale
// requests improve Unicode input when accepted, but rejection should not
// prevent the terminal session from starting.
_ = session.Setenv(key, sessionEnv[key])
}
if err := session.RequestPty(termType, rows, cols, modes); err != nil {
session.Close()
sshConn.Close()