MapPortHandler Callback for container support#831
MapPortHandler Callback for container support#831xinze-zheng wants to merge 22 commits intomasterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #831 +/- ##
==========================================
+ Coverage 88.27% 88.33% +0.06%
==========================================
Files 43 43
Lines 5509 5538 +29
==========================================
+ Hits 4863 4892 +29
Misses 451 451
Partials 195 195
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
JoTurk
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)
candidate.go
Outdated
| Port() int | ||
|
|
||
| // Port mapping support for containers | ||
| MappedPort() int |
There was a problem hiding this comment.
question, do we have to make this public?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
I think we should keep it private for now, unless we need it, or someone requests that we expose it later.
|
@xinze-zheng I'm sorry about the internal API change, we had to fix the options so we can upgrade webrtc to use them. |
|
I think it would be better if we can change the test to use the new Public api instead, |
|
@xinze-zheng hello, we merged the options API and added the new Address rewrite API if you want to continue working on this. |
|
@xinze-zheng I'll try to test and review this today or by tomorrow, thank you a lot :) |
|
@JoTurk Hi I've been looking into integrating this feature with webrtc. Seems we need to replace we just need to make GetMappedPort public in |
|
@xinze-zheng I think the only clean path if we go this route is to make a custom extension for mapped ports but i think it's maybe too much. I changed webrtc's candidates so it keeps ICE extensions when converting. Not sure about exposing mapped ports as a helper (but we can do this if no other solution). I'm maybe missing something, but why we can't overwrite candidates the same we do with addresses? |
|
@JoTurk Hello, I've changed the behavior of mapPort to overwrite the port field of a potential ice candidate. |
agent_options.go
Outdated
|
|
||
| func WithMapPortHandler(handler func(cand Candidate) int, candTyp CandidateType) AgentOption { | ||
| return func(a *Agent) error { | ||
| a.mapPort = func(candidate Candidate) int { | ||
| if candidate.Type() == candTyp { |
There was a problem hiding this comment.
I think we'll either need to remove the candidate type filter or make it possible to add multiple filters for different candidates types.
I think removing is better because the user filter have access to the candidate type.
Description
Expose a handler
func(candidate Candidate) inthandler that will be called uponaddCandidate. The handler will set themappedPortprivate field. During unmarshal, ifmappedPortis not 0, it will replace the port in ICE candidate string.Reference issue
pion/webrtc#3155