-
Notifications
You must be signed in to change notification settings - Fork 319
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
Add callback API to track allocation lifeycle #419
base: master
Are you sure you want to change the base?
Conversation
CC @renandincer |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #419 +/- ##
==========================================
+ Coverage 66.63% 68.73% +2.10%
==========================================
Files 43 43
Lines 2919 3106 +187
==========================================
+ Hits 1945 2135 +190
+ Misses 807 804 -3
Partials 167 167
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
a968c74
to
dae4d0c
Compare
I just looked at it briefly @rg0now! Thank you for PRing this in. I think it might be useful to get a handle to the PacketConn from OnAllocatedCreated as well. This might be useful for rate limiting. What do you think? |
I think a better way to handle rate limiting would be to provide a |
Agreed. Only issue is that would be a breaking API change. |
Fixes #324, #325, and #402
This PR adds a set of callbacks that can be used to track the lifecycle of TURN allocations in the server. This allows user code to be called whenever an authentication request has been processed (this can be used to mitigate DoS attacks against a server, see #402), when an allocation has been created/removed (e.g., to implement user tracking for adding quota support, see #324), when a permission has been created/removed (e.g., to log the peers a user tries to reach via the server), a channel has been created/removed (this will simplify integrating external TURN accelerators, see #360), or when an allocation ends with an error.
The implementation adds a new
EventHandlers
struct to theServerConfig
, defined as follows:It is OK to handle only a subset of the events.
Caveats:
Refresh
,CreatePermission
orChannelBind
message may use a different credential. Since this does not seem to be easy to implement with thePeerConnection
API, credential swaps are currently no tracked.