diff options
author | Olivier CrĂȘte <olivier.crete@collabora.com> | 2016-02-07 19:48:07 -0500 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2016-05-26 15:28:30 -0400 |
commit | c129b05a469b59b576f4700fe9bfe3adca0a48dc (patch) | |
tree | 7259ca22332e699f50763129430710d9c73ea536 /stun/usages | |
parent | 501f9a82e47076cda0deab8cf54758b608e899aa (diff) | |
download | libnice-c129b05a469b59b576f4700fe9bfe3adca0a48dc.tar.gz |
stun turn usage: Only send the username if short term creds or nonce present
This is recommended by the STUN RFC 5389.
Diffstat (limited to 'stun/usages')
-rw-r--r-- | stun/usages/turn.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/stun/usages/turn.c b/stun/usages/turn.c index f242650..3b94959 100644 --- a/stun/usages/turn.c +++ b/stun/usages/turn.c @@ -152,7 +152,9 @@ size_t stun_usage_turn_create (StunAgent *agent, StunMessage *msg, } } - if (username != NULL && username_len > 0) { + if (username != NULL && username_len > 0 && + (agent->usage_flags & STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS || + previous_response)) { if (stun_message_append_bytes (msg, STUN_ATTRIBUTE_USERNAME, username, username_len) != STUN_MESSAGE_RETURN_SUCCESS) return 0; @@ -205,7 +207,9 @@ size_t stun_usage_turn_create_refresh (StunAgent *agent, StunMessage *msg, } - if (username != NULL && username_len > 0) { + if (username != NULL && username_len > 0 && + (agent->usage_flags & STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS || + previous_response)) { if (stun_message_append_bytes (msg, STUN_ATTRIBUTE_USERNAME, username, username_len) != STUN_MESSAGE_RETURN_SUCCESS) return 0; @@ -251,7 +255,9 @@ size_t stun_usage_turn_create_permission (StunAgent *agent, StunMessage *msg, } /* username */ - if (username != NULL) { + if (username != NULL && + (agent->usage_flags & STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS || + (nonce != NULL && realm != NULL))) { if (stun_message_append_bytes (msg, STUN_ATTRIBUTE_USERNAME, username, username_len) != STUN_MESSAGE_RETURN_SUCCESS) return 0; |