See IngestionAwareTransport.
(conn net.Conn, addr net.Addr, now time.Time, shouldClose bool)
| 212 | |
| 213 | // See IngestionAwareTransport. |
| 214 | func (t *NetTransport) IngestPacket(conn net.Conn, addr net.Addr, now time.Time, shouldClose bool) error { |
| 215 | if shouldClose { |
| 216 | defer func() { |
| 217 | _ = conn.Close() |
| 218 | }() |
| 219 | } |
| 220 | |
| 221 | // Copy everything from the stream into packet buffer. |
| 222 | var buf bytes.Buffer |
| 223 | if _, err := io.Copy(&buf, conn); err != nil { |
| 224 | return fmt.Errorf("failed to read packet: %v", err) |
| 225 | } |
| 226 | |
| 227 | // Check the length - it needs to have at least one byte to be a proper |
| 228 | // message. This is checked elsewhere for writes coming in directly from |
| 229 | // the UDP socket. |
| 230 | if n := buf.Len(); n < 1 { |
| 231 | return fmt.Errorf("packet too short (%d bytes) %s", n, LogAddress(addr)) |
| 232 | } |
| 233 | |
| 234 | // Inject the packet. |
| 235 | t.packetCh <- &Packet{ |
| 236 | Buf: buf.Bytes(), |
| 237 | From: addr, |
| 238 | Timestamp: now, |
| 239 | } |
| 240 | return nil |
| 241 | } |
| 242 | |
| 243 | // See Transport. |
| 244 | func (t *NetTransport) DialTimeout(addr string, timeout time.Duration) (net.Conn, error) { |
nothing calls this directly
no test coverage detected