(initializedCh <-chan struct{})
| 255 | } |
| 256 | |
| 257 | func (c *candidateBase) recvLoop(initializedCh <-chan struct{}) { |
| 258 | agent := c.agent() |
| 259 | |
| 260 | defer close(c.closedCh) |
| 261 | |
| 262 | select { |
| 263 | case <-initializedCh: |
| 264 | case <-c.closeCh: |
| 265 | return |
| 266 | } |
| 267 | |
| 268 | bufPtr, ok := bufferPool.Get().(*[]byte) |
| 269 | if !ok { |
| 270 | return |
| 271 | } |
| 272 | defer bufferPool.Put(bufPtr) |
| 273 | buf := *bufPtr |
| 274 | |
| 275 | for { |
| 276 | n, srcAddr, err := c.conn.ReadFrom(buf) |
| 277 | if err != nil { |
| 278 | if !errors.Is(err, io.EOF) && !errors.Is(err, net.ErrClosed) { |
| 279 | agent.log.Warnf("Failed to read from candidate %s: %v", c, err) |
| 280 | } |
| 281 | |
| 282 | return |
| 283 | } |
| 284 | |
| 285 | c.handleInboundPacket(buf[:n], srcAddr) |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | func (c *candidateBase) validateSTUNTrafficCache(addr net.Addr) bool { |
| 290 | if candidate, ok := c.remoteCandidateCaches.Load(toAddrPort(addr)); ok { |
no test coverage detected