feat: add latency indicator and broadcast target selection
- Added a latency indicator to the status bar, displaying round-trip time for SSH sessions. - Implemented functionality to select specific sessions for broadcasting input, allowing users to manage broadcast targets. - Enhanced SFTP functionality with bookmark management, enabling users to bookmark directories and navigate to them easily. - Introduced a modal for user-defined snippet variables, allowing dynamic command execution with placeholders. - Added port forwarding management for SSH sessions, including the ability to start and stop port forwards. - Improved terminal output export functionality, allowing users to download or copy terminal output to clipboard.
This commit is contained in:
@@ -931,6 +931,11 @@ func (s *Service) StopPortForward(sessionID string, forwardID string) error {
|
||||
return s.sessions.StopPortForward(sessionID, forwardID)
|
||||
}
|
||||
|
||||
// PingSession sends a keepalive request and returns the round-trip time in milliseconds.
|
||||
func (s *Service) PingSession(sessionID string) (int64, error) {
|
||||
return s.sessions.PingSession(sessionID)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Session recording
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -1205,6 +1205,22 @@ func (m *Manager) StopPortForward(sessionID string, forwardID string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// PingSession sends a keepalive request to the server and returns the RTT in milliseconds.
|
||||
func (m *Manager) PingSession(sessionID string) (int64, error) {
|
||||
m.mu.RLock()
|
||||
sess, ok := m.sessions[sessionID]
|
||||
m.mu.RUnlock()
|
||||
|
||||
if !ok {
|
||||
return 0, fmt.Errorf("sessions: session %q not found", sessionID)
|
||||
}
|
||||
if sess.sshClient == nil {
|
||||
return 0, fmt.Errorf("sessions: session %q is not an SSH connection", sessionID)
|
||||
}
|
||||
|
||||
return sess.sshClient.Ping()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Internal: helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -262,6 +262,24 @@ func (c *Client) Resize(cols, rows int) error {
|
||||
return session.WindowChange(rows, cols)
|
||||
}
|
||||
|
||||
// Ping sends a keepalive request and returns the round-trip time in milliseconds.
|
||||
func (c *Client) Ping() (int64, error) {
|
||||
c.mu.Lock()
|
||||
if !c.connected || c.sshClient == nil {
|
||||
c.mu.Unlock()
|
||||
return 0, fmt.Errorf("not connected")
|
||||
}
|
||||
client := c.sshClient
|
||||
c.mu.Unlock()
|
||||
|
||||
start := time.Now()
|
||||
_, _, err := client.SendRequest("keepalive@openssh.com", true, nil)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return time.Since(start).Milliseconds(), nil
|
||||
}
|
||||
|
||||
// RunCommand executes a single command using a new SSH session.
|
||||
func (c *Client) RunCommand(command string) (string, error) {
|
||||
c.mu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user