-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 SRTP for remote publishers #3449
Add SRTP for remote publishers #3449
Conversation
88bf274
to
dc307e9
Compare
@spscream thanks! So you got it working with the same SRTP crypto context for all streams, correct? |
no, for each sender on source side rtp forwarder helper is created, so each helper have its own srtp context, and on receiving side we have srtp context per publisher stream |
071ca8b
to
78951f2
Compare
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 just did a first review of the code: it looks mostly fine to me, and in fact you'll see that most comments are editorial and nitpicking. I did add a note on SRTP error logging that could be problematic the way it's done now.
I also have a doubt on just setting a stream to disabled = TRUE
in case SRTP creation failed, considering there may be other things that re-enable that same stream, e.g., by subsequent API calls that set disabled
back to TRUE
on a stream that has a broken SRTP context at that point. Not sure if that could cause the code to crash, but it's worth investigating what could happen in that case.
guint32 timestamp = ntohl(rtp->timestamp); | ||
guint16 seq = ntohs(rtp->seq_number); | ||
JANUS_LOG(LOG_ERR, "[%s] Publisher stream (#%d) SRTP unprotect error: %s (len=%d-->%d, ts=%"SCNu32", seq=%"SCNu16")\n", | ||
publisher->user_id_str, ps->mindex, janus_srtp_error_str(res), bytes, buflen, timestamp, seq); |
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.
This will flood your logs in case you start getting traffic that's inconsistent with your SRTP context, since it will print a log line for every incoming RTP packet, and there may be a lot of them. In the core we try to limit that by showing an error summary every couple of seconds or so to limit the damage. An alternative might be having some sort of toggle: the first time you get an SRTP error you print the error, and then you don't anymore until you get a proper error (SRTP decoding succeeded) that resets the toggle (but this could still cause log flooding if success/error alternate often).
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.
Do you have any example from core, where you summarize logs? I copied this part from streaming plugin.
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 found it in ice.c, I'll make the same - write to debug log on every packet and write summary periodically.
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.
If it's there too then nevermind, I can look into this later on and fix it on both. I just noticed that a few of the nits I mentioned were actually in that code too (e.g., the &policy->rtp
no parenthesis thing).
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 found it in ice.c, I'll make the same - write to debug log on every packet and write summary periodically.
No need, don't worry: I'll take care of that in both plugins myself so that it's done in a consistent way (I'll have to check if the same happens in SIP and NoSIP plugins too).
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 think about disabled, maybe we should add new flag for stream? like srtp_init_failed or similar and set it to true and add required checks in logic.
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.
so, what will be suitable decision for this?
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 think that, to keep things simple, besides setting disabled
to FALSE
it may be enough to simply set the stream is_srtp
to FALSE
as well. This way, even if a stream disabled
is forcibly set to TRUE
later on, there will be no SRTP code involved that may find broken SRTP structures: of course audio/video would not work at all, because we'd be relaying encoded packets, but that's to be expected, since configuring that stream failed in the first place. I only want to ensure there's not a crash when that state changes.
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.
ok, updated pr
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.
btw it was is_rtp=FALSE by default, I set it to be more explicit.
9e86ead
to
47d63bb
Compare
Just as a side note, please notice that this will be merged only after #3359 is merged too (also considering I asked @fancycode to do rebases more than once already 😅 ). You may want to have a look at/review that PR as well, since it's aimed at addressing some memory leaks that apparently remote publishers cause (and since you've started using them, you'll probably be interested in that). |
Thanks 😆 happy to do more rebases if necessary - the change in my PR is not very large, so rebases are not too difficult. But even better if it would get merged at some point 👍 |
so what is the plan? I could rebase myself, this is not the problem |
I'm out of office today, there's a few PRs (including this one) that I plan to review one last time and then merge early next week. |
@spscream I wanted to merge this too, but I think merging your metadata PR introduced a new conflict here: could you fix this? |
835776a
to
22d3dd0
Compare
22d3dd0
to
23c3a93
Compare
sure, updated |
This PR contains the following updates: | Package | Update | Change | |---|---|---| | [meetecho/janus-gateway](https://github.com/meetecho/janus-gateway) | minor | `v1.2.4` -> `v1.3.0` | --- ### Release Notes <details> <summary>meetecho/janus-gateway (meetecho/janus-gateway)</summary> ### [`v1.3.0`](https://github.com/meetecho/janus-gateway/blob/HEAD/CHANGELOG.md#v130---2024-11-25) [Compare Source](meetecho/janus-gateway@v1.2.4...v1.3.0) - Refactored logging internals \[[PR-3428](meetecho/janus-gateway#3428)] - Use strtok to parse SDPs \[[PR-3424](meetecho/janus-gateway#3424)] - Fixed rare condition that could lead to a deadlock in the VideoRoom \[[PR-3446](meetecho/janus-gateway#3446)] - Fixed broken switch when using remote publishers in VideoRoom \[[PR-3447](meetecho/janus-gateway#3447)] - Added SRTP support to VideoRoom remote publishers (thanks [@​spscream](https://github.com/spscream)!) \[[PR-3449](meetecho/janus-gateway#3449)] - Added support for generic JSON metadata to VideoRoom publishers (thanks [@​spscream](https://github.com/spscream)!) \[[PR-3467](meetecho/janus-gateway#3467)] - Fixed deadlock in VideoRoom when failing to open a socket for a new RTP forwarder (thanks [@​spscream](https://github.com/spscream)!) \[[PR-3468](meetecho/janus-gateway#3468)] - Fixed deadlock in VideoRoom caused by reverse ordering of mutex locks \[[PR-3474](meetecho/janus-gateway#3474)] - Fixed memory leaks when using remote publishers in VideoRoom \[[PR-3475](meetecho/janus-gateway#3475)] - Diluted frequency of PLI in the VideoRoom (thanks [@​natikaltura](https://github.com/natikaltura)!) \[[PR-3423](meetecho/janus-gateway#3423)] - Better cleanup after failed mountpoint creations in Streaming plugin \[[PR-3465](meetecho/janus-gateway#3465)] - Fixed compilation of AudioBridge in case libogg isn't available (thanks [@​tmatth](https://github.com/tmatth)!) \[[PR-3438](meetecho/janus-gateway#3438)] - Better management of call cleanup in SIP plugin \[[Issue-3430](meetecho/janus-gateway#3430)] - Change the way call-IDs are tracked in the SIP plugin (thanks WebTrit!) \[[PR-3443](meetecho/janus-gateway#3443)] - Increased maximum size of custom SIP headers \[[Issue-3459](meetecho/janus-gateway#3459)] - Other smaller fixes and improvements (thanks to all who contributed pull requests and reported issues!) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yOC4wIiwidXBkYXRlZEluVmVyIjoiMzkuMjguMCIsInRhcmdldEJyYW5jaCI6Im1hc3RlciIsImxhYmVscyI6W119--> Reviewed-on: https://git.walbeck.it/walbeck-it/docker-janus-gateway/pulls/157 Co-authored-by: renovate-bot <[email protected]> Co-committed-by: renovate-bot <[email protected]>
hi, I got working SRTP encryption for remote publishers, tested and worked in our environment