MCPcopy Create free account
hub / github.com/pion/ice / HandleSuccessResponse

Method HandleSuccessResponse

selection.go:371–424  ·  view source on GitHub ↗
(m *stun.Message, local, remote Candidate, remoteAddr net.Addr)

Source from the content-addressed store, hash-verified

369}
370
371func (s *controlledSelector) HandleSuccessResponse(m *stun.Message, local, remote Candidate, remoteAddr net.Addr) {
372 //nolint:godox
373 // TODO according to the standard we should specifically answer a failed nomination:
374 // https://tools.ietf.org/html/rfc8445#section-7.3.1.5
375 // If the controlled agent does not accept the request from the
376 // controlling agent, the controlled agent MUST reject the nomination
377 // request with an appropriate error code response (e.g., 400)
378 // [RFC5389].
379
380 ok, pendingRequest, rtt := s.agent.handleInboundBindingSuccess(m.TransactionID)
381 if !ok {
382 s.log.Warnf("Discard message from (%s), unknown TransactionID 0x%x", remote, m.TransactionID)
383
384 return
385 }
386
387 transactionAddr := pendingRequest.destination
388
389 // Assert that NAT is not symmetric
390 // https://tools.ietf.org/html/rfc8445#section-7.2.5.2.1
391 if !addrEqual(transactionAddr, remoteAddr) {
392 s.log.Debugf(
393 "Discard message: transaction source and destination does not match expected(%s), actual(%s)",
394 transactionAddr,
395 remote,
396 )
397
398 return
399 }
400
401 s.log.Tracef("Inbound STUN (SuccessResponse) from %s to %s", remote, local)
402
403 pair := s.agent.findPair(local, remote)
404 if pair == nil {
405 // This shouldn't happen
406 s.log.Error("Success response from invalid candidate pair")
407
408 return
409 }
410
411 pair.state = CandidatePairStateSucceeded
412 s.log.Tracef("Found valid candidate pair: %s", pair)
413 if pair.nominateOnBindingSuccess {
414 if selectedPair := s.agent.getSelectedPair(); selectedPair == nil ||
415 (selectedPair != pair &&
416 (!s.agent.needsToCheckPriorityOnNominated() || selectedPair.priority() <= pair.priority())) {
417 s.agent.setSelectedPair(pair)
418 } else if selectedPair != pair {
419 s.log.Tracef("Ignore nominate new pair %s, already nominated pair %s", pair, selectedPair)
420 }
421 }
422
423 pair.UpdateRoundTripTime(rtt)
424}
425
426func (s *controlledSelector) HandleBindingRequest(message *stun.Message, local, remote Candidate) { //nolint:cyclop
427 pair := s.agent.findPair(local, remote)

Calls 12

addrEqualFunction · 0.85
findPairMethod · 0.80
getSelectedPairMethod · 0.80
priorityMethod · 0.80
setSelectedPairMethod · 0.80
UpdateRoundTripTimeMethod · 0.80
WarnfMethod · 0.45
DebugfMethod · 0.45
TracefMethod · 0.45
ErrorMethod · 0.45