Skip to content

Conversation

@xinze-zheng
Copy link
Member

@xinze-zheng xinze-zheng commented Nov 8, 2025

Description

Expose a handler func(candidate Candidate) int handler that will be called upon addCandidate. The handler will set the mappedPort private field. During unmarshal, if mappedPort is not 0, it will replace the port in ICE candidate string.

Reference issue

pion/webrtc#3155

@codecov
Copy link

codecov bot commented Nov 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.01%. Comparing base (e1b445c) to head (460350f).

Additional details and impacted files
@@ Coverage Diff @@ ## master #831 +/- ## ========================================== - Coverage 87.27% 87.01% -0.27%  ========================================== Files 43 43 Lines 4819 4836 +17 ========================================== + Hits 4206 4208 +2  - Misses 438 453 +15  Partials 175 175 
Flag Coverage Δ
go 87.01% <100.00%> (-0.27%) ⬇️

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.
Copy link
Member

@JoeTurki JoeTurki left a comment

Choose a reason for hiding this comment

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

Thank you so much, I like this direction let me know when it's ready for test and review.

agent_config.go Outdated
EnableUseCandidateCheckPriority bool

// MapPortHanlder is the handler used to compute mapped port for host candidate.
MapPortHanlder func(candidate Candidate) int
Copy link
Member

Choose a reason for hiding this comment

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

We've stopped adding new configurations to the AgentConfig struct since it's planned for deprecation in favor of a more Pion-aligned API. this feature should instead be exposed as an option, WithMapPortHandler, and used with the new NewAgentWithConfig API. Users who want to use this should migrate to the new API.

we did the same thing recently with the renomination API: #822 (comment)

@xinze-zheng xinze-zheng marked this pull request as ready for review November 9, 2025 01:19
candidate.go Outdated
Port() int

// Port mapping support for containers
MappedPort() int
Copy link
Member

Choose a reason for hiding this comment

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

question, do we have to make this public?

Copy link
Member Author

Choose a reason for hiding this comment

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

Should we? Will webrtc care about this? I was thinking for design of separted ICE (maybe the future ion) this will be somehow used. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

I think we should keep it private for now, unless we need it, or someone requests that we expose it later.

@JoeTurki
Copy link
Member

JoeTurki commented Nov 9, 2025

@xinze-zheng I'm sorry about the internal API change, we had to fix the options so we can upgrade webrtc to use them.

@JoeTurki
Copy link
Member

JoeTurki commented Nov 9, 2025

I think it would be better if we can change the test to use the new Public api instead, NewAgentWithOptions, so it doesn't break if we change the internal API in the future, and so it matches the user contract.
But this is up to you.

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

Labels

None yet

3 participants