-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use new pion/transport Net interface #471
Conversation
Codecov ReportBase: 78.28% // Head: 77.82% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #471 +/- ##
==========================================
- Coverage 78.28% 77.82% -0.46%
==========================================
Files 36 36
Lines 4273 4307 +34
==========================================
+ Hits 3345 3352 +7
- Misses 722 743 +21
- Partials 206 212 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
47468e2
to
1a11255
Compare
9cba962
to
d8dba3a
Compare
7ec3723
to
3fd03ff
Compare
This change adapts pion/ice to use a new interface for most network related operations. The interface was formerly a simple struct vnet.Net which was originally intended to facilicate testing. By replacing it with an interface we have greater flexibility and allow users to hook into the networking stack by providing their own implementation of the interface.
Fix linter warnings
udp_mux.go
Outdated
@@ -49,6 +50,7 @@ const maxAddrSize = 512 | |||
type UDPMuxParams struct { | |||
Logger logging.LeveledLogger | |||
UDPConn net.PacketConn | |||
Net transport.Net |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// For unspecified addresses, the correct behavior is to return errListenUnspecified, but // it will break the applications that are already using unspecified UDP connection // with UDPMuxDefault, so print a warn log and create a local address list for mux.
Seems be used only for the fallback to the wrong usage of NewUDPMuxDefault
.
If user want to specify transport.New
, they should use NewMultiUDPMuxFromPort
instead.
It would be better to add some comment to this field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stv0g
This is an API change beyond what this PR is aiming for. I think the reason why it uses vnet (or transport.Net) is just to reuse localInterfaces() that requires vnet/transport.Net. In fact, it only requires net.Interfaces, and
vnet.NewNet(nil) // <-- *NetConfig being nil
would return what you can get from the original net.Interfaces, so the code we have here did not intend to use "virtual interface" but to use localInterfaces just for convenience. Therefore, I think we don't need to add transport.Net field to this public struct. (Let's focus on introducing transport.Net for now with minimal impact to users)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually tried it without adding the field. However that breaks the tests as the integration will create a UDPMux
which attempts to listen on addresses of the real host rather than the virtual interfaces of the vnet.VNet
.
This will cause vnet/Net.ListenUDP
to fail as it can not bind to a non-existing local address.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For normal (non-test usage) the field will be initialized with nil
and hence use the stdnet.Net
implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@at-wat I added a comment to the new field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left one comment. (I will review again when it comes out of the draft state.)
udp_mux.go
Outdated
@@ -49,6 +50,7 @@ const maxAddrSize = 512 | |||
type UDPMuxParams struct { | |||
Logger logging.LeveledLogger | |||
UDPConn net.PacketConn | |||
Net transport.Net |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stv0g
This is an API change beyond what this PR is aiming for. I think the reason why it uses vnet (or transport.Net) is just to reuse localInterfaces() that requires vnet/transport.Net. In fact, it only requires net.Interfaces, and
vnet.NewNet(nil) // <-- *NetConfig being nil
would return what you can get from the original net.Interfaces, so the code we have here did not intend to use "virtual interface" but to use localInterfaces just for convenience. Therefore, I think we don't need to add transport.Net field to this public struct. (Let's focus on introducing transport.Net for now with minimal impact to users)
Remove duplicate package comment
To describe its purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! One actual change to make and one suggested.
Co-authored-by: Eric Daniels <[email protected]>
Thanks @edaniels, I committed your proposed changed 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Among other improvements, it fixes a memory leak with srfx conn channels not being closed it also make use of new pion/transport Net interface pion/ice#471
Among other improvements, it fixes a memory leak with srfx conn channels not being closed it also make use of new pion/transport Net interface pion/ice#471
Among other improvements, it fixes a memory leak with srfx conn channels not being closed it also make use of new pion/transport Net interface pion/ice#471
See pion/transport#204 for a detailed description
Also closes #509