(packet *Packet)
| 188 | } |
| 189 | |
| 190 | func (c *ForwardCtx) handleData(packet *Packet) { |
| 191 | c.connMapMu.RLock() |
| 192 | conn, ok := c.connMap[packet.ConnectionId] |
| 193 | c.connMapMu.RUnlock() |
| 194 | if !ok { |
| 195 | c.logger.Info( |
| 196 | message.NewMessage( |
| 197 | message.EAgentUnknownConnection, |
| 198 | "Received data packet with unknown connection id %d", |
| 199 | packet.ConnectionId, |
| 200 | ), |
| 201 | ) |
| 202 | return |
| 203 | } |
| 204 | conn.lock.Lock() |
| 205 | defer conn.lock.Unlock() |
| 206 | if conn.state != CONNECTION_STATE_STARTED { |
| 207 | c.logger.Info( |
| 208 | message.NewMessage( |
| 209 | message.EAgentConnectionInvalidState, |
| 210 | "Received data packet for a connection in a non-started state", |
| 211 | ), |
| 212 | ) |
| 213 | return |
| 214 | } |
| 215 | nByte, err := conn.bufferWriter.Write(packet.Payload) |
| 216 | if err != nil { |
| 217 | c.logger.Error(message.Wrap( |
| 218 | err, |
| 219 | message.MSSHConnected, |
| 220 | "Error handling data packet", |
| 221 | )) |
| 222 | return |
| 223 | } |
| 224 | if nByte != len(packet.Payload) { |
| 225 | c.logger.Warning( |
| 226 | message.NewMessage( |
| 227 | message.EAgentWriteFailed, |
| 228 | "Failed to write connection packet to agent", |
| 229 | ), |
| 230 | ) |
| 231 | return |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | func (c *ForwardCtx) handleClose(packet *Packet) { |
| 236 | c.connMapMu.Lock() |
no test coverage detected