From 14b3cccabfd9fc4813afd6f7e6cd57507522ca10 Mon Sep 17 00:00:00 2001 From: philipch07 Date: Sun, 14 Sep 2025 01:25:42 -0400 Subject: [PATCH] Replace verbose check with slices.Contains --- agent_config.go | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/agent_config.go b/agent_config.go index 708aab5..f8aa97e 100644 --- a/agent_config.go +++ b/agent_config.go @@ -5,6 +5,7 @@ package ice import ( "net" + "slices" "time" "github.com/pion/logging" @@ -297,26 +298,12 @@ func (config *AgentConfig) initExtIPMapping(agent *Agent) error { //nolint:cyclo if agent.mDNSMode == MulticastDNSModeQueryAndGather { return ErrMulticastDNSWithNAT1To1IPMapping } - candiHostEnabled := false - for _, candiType := range agent.candidateTypes { - if candiType == CandidateTypeHost { - candiHostEnabled = true - - break - } - } + candiHostEnabled := slices.Contains(agent.candidateTypes, CandidateTypeHost) if !candiHostEnabled { return ErrIneffectiveNAT1To1IPMappingHost } } else if agent.extIPMapper.candidateType == CandidateTypeServerReflexive { - candiSrflxEnabled := false - for _, candiType := range agent.candidateTypes { - if candiType == CandidateTypeServerReflexive { - candiSrflxEnabled = true - - break - } - } + candiSrflxEnabled := slices.Contains(agent.candidateTypes, CandidateTypeServerReflexive) if !candiSrflxEnabled { return ErrIneffectiveNAT1To1IPMappingSrflx }