Commit c129b05a authored by Olivier Crête's avatar Olivier Crête

stun turn usage: Only send the username if short term creds or nonce present

This is recommended by the STUN RFC 5389.
parent 501f9a82
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment