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

Function applyAddressRewriteMapping

agent.go:403–436  ·  view source on GitHub ↗
(agent *Agent)

Source from the content-addressed store, hash-verified

401}
402
403func applyAddressRewriteMapping(agent *Agent) error {
404 mapper, err := newAddressRewriteMapper(agent.addressRewriteRules)
405 if err != nil {
406 return err
407 }
408
409 agent.addressRewriteMapper = mapper
410 if agent.addressRewriteMapper == nil {
411 return nil
412 }
413
414 if agent.addressRewriteMapper.hasCandidateType(CandidateTypeHost) {
415 // for mDNS QueryAndGather we never advertise rewritten host IPs to avoid
416 // leaking local addresses, this matches the legacy NAT1:1 behavior.
417 if agent.mDNSMode == MulticastDNSModeQueryAndGather {
418 return ErrMulticastDNSWithNAT1To1IPMapping
419 }
420 // surface misconfiguration when host candidates are disabled but a host
421 // rewrite rule was provided.
422 if !containsCandidateType(CandidateTypeHost, agent.candidateTypes) {
423 return ErrIneffectiveNAT1To1IPMappingHost
424 }
425 }
426
427 if agent.addressRewriteMapper.hasCandidateType(CandidateTypeServerReflexive) {
428 // surface misconfiguration when srflx candidates are disabled but a srflx
429 // rewrite rule was provided.
430 if !containsCandidateType(CandidateTypeServerReflexive, agent.candidateTypes) {
431 return ErrIneffectiveNAT1To1IPMappingSrflx
432 }
433 }
434
435 return nil
436}
437
438// setupMDNSConfig validates and returns mDNS configuration.
439func setupMDNSConfig(config *AgentConfig) (string, MulticastDNSMode, error) {

Calls 3

newAddressRewriteMapperFunction · 0.85
containsCandidateTypeFunction · 0.85
hasCandidateTypeMethod · 0.80

Used in the wild real call sites across dependent graphs

searching dependent graphs…