()
| 133 | } |
| 134 | |
| 135 | func (conn *SSHConn) DeriveConnStatus() wshrpc.ConnStatus { |
| 136 | conn.lock.Lock() |
| 137 | defer conn.lock.Unlock() |
| 138 | var lastActivityBeforeStalledTime int64 |
| 139 | var keepAliveSentTime int64 |
| 140 | monitor := conn.Monitor |
| 141 | if conn.ConnHealthStatus == ConnHealthStatus_Stalled && monitor != nil { |
| 142 | lastActivityBeforeStalledTime = monitor.LastActivityTime.Load() |
| 143 | keepAliveSentTime = monitor.KeepAliveSentTime.Load() |
| 144 | } |
| 145 | return wshrpc.ConnStatus{ |
| 146 | Status: conn.Status, |
| 147 | Connected: conn.Status == Status_Connected, |
| 148 | Connection: conn.Opts.String(), |
| 149 | HasConnected: (conn.LastConnectTime > 0), |
| 150 | ActiveConnNum: conn.ActiveConnNum, |
| 151 | Error: conn.Error, |
| 152 | WshEnabled: conn.WshEnabled.Load(), |
| 153 | WshError: conn.WshError, |
| 154 | NoWshReason: conn.NoWshReason, |
| 155 | WshVersion: conn.WshVersion, |
| 156 | ConnHealthStatus: conn.ConnHealthStatus, |
| 157 | LastActivityBeforeStalledTime: lastActivityBeforeStalledTime, |
| 158 | KeepAliveSentTime: keepAliveSentTime, |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | func (conn *SSHConn) Infof(ctx context.Context, format string, args ...any) { |
| 163 | log.Print(fmt.Sprintf("[conn:%s] ", conn.GetName()) + fmt.Sprintf(format, args...)) |
no test coverage detected