-
Notifications
You must be signed in to change notification settings - Fork 323
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 3103 +184
==========================================
+ Hits 1945 2133 +188
+ Misses 807 803 -4
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. |
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. |
7c98ff3
to
c7d5354
Compare
While working with the lifecycle event handler API it came to our attention that we never report the allocation's relay address in the callbacks. This makes it difficult to track server port allocation status, open firewalls, etc. The last patch updates the relevant callbacks to also pass the relay address to the caller. The changed event handler signatures are as follows:
|
6eefa1c
to
37ba0b5
Compare
37ba0b5
to
bd0b543
Compare
Further evolving the PR based on operational experience: It seems the
|
We have been deploying this PR into production for a while now, so far all goes as expected. If there are no objections, I'd like to merge this ASAP. Please speak up now if you have concerns. |
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.