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

Function newAgentFromConfig

agent.go:195–225  ·  view source on GitHub ↗
(config *AgentConfig, opts ...AgentOption)

Source from the content-addressed store, hash-verified

193}
194
195func newAgentFromConfig(config *AgentConfig, opts ...AgentOption) (*Agent, error) {
196 if config == nil {
197 config = &AgentConfig{}
198 }
199
200 agent, err := createAgentBase(config)
201 if err != nil {
202 return nil, err
203 }
204
205 agent.localUfrag = config.LocalUfrag
206 agent.localPwd = config.LocalPwd
207 if config.NAT1To1IPs != nil {
208 if err := validateLegacyNAT1To1IPs(config.NAT1To1IPs); err != nil {
209 return nil, err
210 }
211
212 typ := CandidateTypeHost
213 if config.NAT1To1IPCandidateType != CandidateTypeUnspecified {
214 typ = config.NAT1To1IPCandidateType
215 }
216
217 rules, err := legacyNAT1To1Rules(config.NAT1To1IPs, typ)
218 if err != nil {
219 return nil, err
220 }
221 agent.addressRewriteRules = rules
222 }
223
224 return newAgentWithConfig(agent, opts...)
225}
226
227func validateLegacyNAT1To1IPs(ips []string) error {
228 var hasIPv4CatchAll, hasIPv6CatchAll bool

Calls 4

createAgentBaseFunction · 0.85
validateLegacyNAT1To1IPsFunction · 0.85
legacyNAT1To1RulesFunction · 0.85
newAgentWithConfigFunction · 0.85

Used in the wild real call sites across dependent graphs

searching dependent graphs…