gssh-agent 1.0.5 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/gssh +0 -0
- package/package.json +1 -1
- package/fix_manager.patch +0 -79
package/bin/gssh
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/fix_manager.patch
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
--- internal/session/manager.go
|
|
2
|
-
+++ internal/session/manager.go
|
|
3
|
-
@@ -100,16 +100,24 @@
|
|
4
|
-
// Check if session already exists
|
|
5
|
-
for _, s := range m.sessions {
|
|
6
|
-
if s.Host == host && s.User == user && s.Port == port {
|
|
7
|
-
- if s.Status == "connected" {
|
|
8
|
-
+ s.mu.RLock()
|
|
9
|
-
+ status := s.Status
|
|
10
|
-
+ s.mu.RUnlock()
|
|
11
|
-
+
|
|
12
|
-
+ if status == "connected" {
|
|
13
|
-
return toProtocolSession(s), fmt.Errorf("session already exists")
|
|
14
|
-
}
|
|
15
|
-
// Try to reconnect
|
|
16
|
-
sshClient, err := client.Connect(user, host, port, password, keyPath)
|
|
17
|
-
if err != nil {
|
|
18
|
-
return nil, err
|
|
19
|
-
}
|
|
20
|
-
+
|
|
21
|
-
+ s.mu.Lock()
|
|
22
|
-
s.SSHClient = sshClient
|
|
23
|
-
s.Status = "connected"
|
|
24
|
-
+ s.mu.Unlock()
|
|
25
|
-
+
|
|
26
|
-
return toProtocolSession(s), nil
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
@@ -159,10 +167,12 @@
|
|
30
|
-
return fmt.Errorf("session not found")
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
+ ms.mu.Lock()
|
|
34
|
-
if ms.SSHClient != nil {
|
|
35
|
-
ms.SSHClient.Close()
|
|
36
|
-
}
|
|
37
|
-
-
|
|
38
|
-
ms.Status = "disconnected"
|
|
39
|
-
+ ms.mu.Unlock()
|
|
40
|
-
|
|
41
|
-
// Clear default ID when disconnecting
|
|
42
|
-
if m.defaultID == sessionID {
|
|
43
|
-
@@ -188,10 +198,14 @@
|
|
44
|
-
return nil, fmt.Errorf("session not found")
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
+ ms.mu.RLock()
|
|
48
|
-
+ existingClient := ms.SSHClient
|
|
49
|
-
+ ms.mu.RUnlock()
|
|
50
|
-
+
|
|
51
|
-
// Close existing connection
|
|
52
|
-
- if ms.SSHClient != nil {
|
|
53
|
-
- ms.SSHClient.Close()
|
|
54
|
-
+ if existingClient != nil {
|
|
55
|
-
+ existingClient.Close()
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Create new connection
|
|
59
|
-
sshClient, err := client.Connect(ms.User, ms.Host, ms.Port, ms.Password, ms.KeyPath)
|
|
60
|
-
@@ -239,15 +253,16 @@
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
ms.mu.RLock()
|
|
64
|
-
- if ms.SSHClient == nil {
|
|
65
|
-
+ sshClient := ms.SSHClient
|
|
66
|
-
+ ms.mu.RUnlock()
|
|
67
|
-
+
|
|
68
|
-
+ if sshClient == nil {
|
|
69
|
-
- ms.mu.RUnlock()
|
|
70
|
-
return nil, fmt.Errorf("session not connected")
|
|
71
|
-
}
|
|
72
|
-
- ms.mu.RUnlock()
|
|
73
|
-
|
|
74
|
-
// 复用 SSH 连接,创建新的 session 执行命令
|
|
75
|
-
- session, err := ms.SSHClient.Client.NewSession()
|
|
76
|
-
+ session, err := sshClient.Client.NewSession()
|
|
77
|
-
if err != nil {
|
|
78
|
-
return nil, fmt.Errorf("failed to create session: %w", err)
|
|
79
|
-
}
|