Skip to content

Conversation

@JoeTurki
Copy link
Member

Description

Currently, we don't have a way to limit which candidates we gather beyond lite-mode (host candidates only) and relay mode (relay only). As a result, users end up relying on hacky workarounds like #3176 to limit to srflx only, which aren't reliable due to how ICE actually works.
Added many tests to make sure that it actually works.
based on #3303.
this resolves #3176

@codecov
Copy link

codecov bot commented Dec 14, 2025

Codecov Report

❌ Patch coverage is 95.17241% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.68%. Comparing base (1519afa) to head (0d2c610).

Files with missing lines Patch % Lines
icegatherer.go 96.85% 3 Missing and 1 partial ⚠️
settingengine.go 80.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3305      +/-   ##
==========================================
+ Coverage   84.47%   84.68%   +0.21%     
==========================================
  Files          80       80              
  Lines        9279     9370      +91     
==========================================
+ Hits         7838     7935      +97     
+ Misses       1020     1010      -10     
- Partials      421      425       +4     
Flag Coverage Δ
go 84.68% <95.17%> (+0.21%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JoeTurki JoeTurki force-pushed the with-candidates-types branch from 984e744 to a76805f Compare December 14, 2025 01:10
@JoeTurki JoeTurki changed the title Add WithCandidatesTypes to control what candidates to gather Add SetCandidatesTypes to control what candidates to gather Dec 14, 2025
@JoeTurki JoeTurki force-pushed the with-candidates-types branch from a76805f to 68b7823 Compare December 14, 2025 01:11
@JoeTurki JoeTurki changed the title Add SetCandidatesTypes to control what candidates to gather Add SetCandidateTypes to control what candidates to gather Dec 14, 2025
@JoeTurki JoeTurki added this to the V4.2.0 milestone Dec 14, 2025
@JoeTurki JoeTurki force-pushed the with-candidates-types branch from 68b7823 to c018a20 Compare December 14, 2025 19:27
Comment on lines +125 to +143
if g.gatherPolicy == ICETransportPolicyRelay {
for _, candidate := range candidateTypes {
if candidate != ice.CandidateTypeRelay {
g.log.Warnf("ICETransportPolicyRelay is set. gathering is limited to relay candidates")

break
}
}

return []ice.CandidateType{ice.CandidateTypeRelay}
}

g.agent = agent
if g.api.settingEngine.candidates.ICELite {
return []ice.CandidateType{ice.CandidateTypeHost}
}

if len(candidateTypes) > 0 {
return candidateTypes
}
Copy link
Member Author

@JoeTurki JoeTurki Dec 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if relay mode and ice lite are enabled at the same time, we return []ice.CandidateType{ice.CandidateTypeRelay} which isn't spec compliant, but safer so we don't leak IPs if the user didn't intended to do that, we should log a warning tho.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth commenting it in the function so it's written in the code that we intentionally "break" the spec?

Copy link
Member Author

@JoeTurki JoeTurki Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't break the spec, If a user turns on relay-only-mode and ice-lite at the same time, they are breaking the ice-lite spec, We should log an error when that happens, It's not a new behavior, it's how it works currently if you set both.

Copy link
Contributor

@philipch07 philipch07 Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I'm in favor of logging if the user accidentally breaks the spec by setting both at the same time.

@JoeTurki JoeTurki force-pushed the with-candidates-types branch from c018a20 to 466b458 Compare December 15, 2025 13:49
@JoeTurki JoeTurki force-pushed the with-candidates-types branch from 466b458 to 0d2c610 Compare December 15, 2025 13:58
Comment on lines +125 to +143
if g.gatherPolicy == ICETransportPolicyRelay {
for _, candidate := range candidateTypes {
if candidate != ice.CandidateTypeRelay {
g.log.Warnf("ICETransportPolicyRelay is set. gathering is limited to relay candidates")

break
}
}

return []ice.CandidateType{ice.CandidateTypeRelay}
}

g.agent = agent
if g.api.settingEngine.candidates.ICELite {
return []ice.CandidateType{ice.CandidateTypeHost}
}

if len(candidateTypes) > 0 {
return candidateTypes
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth commenting it in the function so it's written in the code that we intentionally "break" the spec?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

SCTP fails when using SetInterfaceFilter and pion is an answerer

2 participants