зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1569183: Add some much-needed logging to this function. r=mjf
Differential Revision: https://phabricator.services.mozilla.com/D45096 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
b8226cf581
Коммит
663351b2eb
|
@ -583,18 +583,24 @@ int nr_stun_client_process_response(nr_stun_client_ctx *ctx, UCHAR *msg, int len
|
||||||
* TODO: !nn! usage (ctx->mode?) */
|
* TODO: !nn! usage (ctx->mode?) */
|
||||||
if (password) {
|
if (password) {
|
||||||
if (nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_NONCE, 0)) {
|
if (nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_NONCE, 0)) {
|
||||||
if ((r=nr_stun_receive_response_long_term_auth(ctx->response, ctx)))
|
if ((r=nr_stun_receive_response_long_term_auth(ctx->response, ctx))) {
|
||||||
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): long term auth failed",ctx->label);
|
||||||
ABORT(r);
|
ABORT(r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ((r=nr_stun_receive_response_short_term_auth(ctx->response)))
|
if ((r=nr_stun_receive_response_short_term_auth(ctx->response))) {
|
||||||
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): short term auth failed",ctx->label);
|
||||||
ABORT(r);
|
ABORT(r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NR_STUN_GET_TYPE_CLASS(ctx->response->header.type) == NR_CLASS_RESPONSE) {
|
if (NR_STUN_GET_TYPE_CLASS(ctx->response->header.type) == NR_CLASS_RESPONSE) {
|
||||||
if ((r=nr_stun_process_success_response(ctx->response)))
|
if ((r=nr_stun_process_success_response(ctx->response))) {
|
||||||
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): nr_stun_process_success_response failed",ctx->label);
|
||||||
ABORT(r);
|
ABORT(r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (fail_on_error) {
|
if (fail_on_error) {
|
||||||
|
@ -606,11 +612,13 @@ int nr_stun_client_process_response(nr_stun_client_ctx *ctx, UCHAR *msg, int len
|
||||||
the error code, and just keep going.
|
the error code, and just keep going.
|
||||||
*/
|
*/
|
||||||
if ((r=nr_stun_process_error_response(ctx->response, &ctx->error_code))) {
|
if ((r=nr_stun_process_error_response(ctx->response, &ctx->error_code))) {
|
||||||
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): nr_stun_process_error_response failed",ctx->label);
|
||||||
ABORT(r);
|
ABORT(r);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ctx->error_code = 0xffff;
|
ctx->error_code = 0xffff;
|
||||||
/* drop the error on the floor */
|
/* drop the error on the floor */
|
||||||
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): processed error response",ctx->label);
|
||||||
ABORT(R_FAILED);
|
ABORT(R_FAILED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -621,10 +629,14 @@ int nr_stun_client_process_response(nr_stun_client_ctx *ctx, UCHAR *msg, int len
|
||||||
switch (ctx->mode) {
|
switch (ctx->mode) {
|
||||||
case NR_STUN_CLIENT_MODE_BINDING_REQUEST_LONG_TERM_AUTH:
|
case NR_STUN_CLIENT_MODE_BINDING_REQUEST_LONG_TERM_AUTH:
|
||||||
case NR_STUN_CLIENT_MODE_BINDING_REQUEST_SHORT_TERM_AUTH:
|
case NR_STUN_CLIENT_MODE_BINDING_REQUEST_SHORT_TERM_AUTH:
|
||||||
if (! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_XOR_MAPPED_ADDRESS, 0))
|
if (! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_XOR_MAPPED_ADDRESS, 0)) {
|
||||||
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): No XOR-MAPPED-ADDRESS",ctx->label);
|
||||||
ABORT(R_BAD_DATA);
|
ABORT(R_BAD_DATA);
|
||||||
if (! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_MESSAGE_INTEGRITY, 0))
|
}
|
||||||
|
if (! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_MESSAGE_INTEGRITY, 0)) {
|
||||||
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): No MESSAGE-INTEGRITY",ctx->label);
|
||||||
ABORT(R_BAD_DATA);
|
ABORT(R_BAD_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
mapped_addr = &ctx->results.stun_binding_response.mapped_addr;
|
mapped_addr = &ctx->results.stun_binding_response.mapped_addr;
|
||||||
break;
|
break;
|
||||||
|
@ -636,6 +648,7 @@ int nr_stun_client_process_response(nr_stun_client_ctx *ctx, UCHAR *msg, int len
|
||||||
r_log(NR_LOG_STUN,LOG_INFO,"STUN-CLIENT(%s): No XOR-MAPPED-ADDRESS but MAPPED-ADDRESS. Falling back (though server is wrong).", ctx->label);
|
r_log(NR_LOG_STUN,LOG_INFO,"STUN-CLIENT(%s): No XOR-MAPPED-ADDRESS but MAPPED-ADDRESS. Falling back (though server is wrong).", ctx->label);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): No XOR-MAPPED-ADDRESS or MAPPED-ADDRESS",ctx->label);
|
||||||
ABORT(R_BAD_DATA);
|
ABORT(R_BAD_DATA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -644,26 +657,36 @@ int nr_stun_client_process_response(nr_stun_client_ctx *ctx, UCHAR *msg, int len
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NR_STUN_CLIENT_MODE_BINDING_REQUEST_STUND_0_96:
|
case NR_STUN_CLIENT_MODE_BINDING_REQUEST_STUND_0_96:
|
||||||
if (! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_MAPPED_ADDRESS, 0) && ! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_XOR_MAPPED_ADDRESS, 0))
|
if (! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_MAPPED_ADDRESS, 0) && ! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_XOR_MAPPED_ADDRESS, 0)) {
|
||||||
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): No MAPPED-ADDRESS",ctx->label);
|
||||||
ABORT(R_BAD_DATA);
|
ABORT(R_BAD_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
mapped_addr = &ctx->results.stun_binding_response_stund_0_96.mapped_addr;
|
mapped_addr = &ctx->results.stun_binding_response_stund_0_96.mapped_addr;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef USE_ICE
|
#ifdef USE_ICE
|
||||||
case NR_ICE_CLIENT_MODE_BINDING_REQUEST:
|
case NR_ICE_CLIENT_MODE_BINDING_REQUEST:
|
||||||
if (! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_XOR_MAPPED_ADDRESS, 0))
|
if (! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_XOR_MAPPED_ADDRESS, 0)) {
|
||||||
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): No XOR-MAPPED-ADDRESS",ctx->label);
|
||||||
ABORT(R_BAD_DATA);
|
ABORT(R_BAD_DATA);
|
||||||
if (! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_MESSAGE_INTEGRITY, 0))
|
}
|
||||||
|
if (! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_MESSAGE_INTEGRITY, 0)) {
|
||||||
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): No MESSAGE-INTEGRITY",ctx->label);
|
||||||
ABORT(R_BAD_DATA);
|
ABORT(R_BAD_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
mapped_addr = &ctx->results.stun_binding_response.mapped_addr;
|
mapped_addr = &ctx->results.stun_binding_response.mapped_addr;
|
||||||
break;
|
break;
|
||||||
case NR_ICE_CLIENT_MODE_USE_CANDIDATE:
|
case NR_ICE_CLIENT_MODE_USE_CANDIDATE:
|
||||||
if (! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_XOR_MAPPED_ADDRESS, 0))
|
if (! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_XOR_MAPPED_ADDRESS, 0)) {
|
||||||
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): No XOR-MAPPED-ADDRESS",ctx->label);
|
||||||
ABORT(R_BAD_DATA);
|
ABORT(R_BAD_DATA);
|
||||||
if (! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_MESSAGE_INTEGRITY, 0))
|
}
|
||||||
|
if (! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_MESSAGE_INTEGRITY, 0)) {
|
||||||
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): No MESSAGE-INTEGRITY",ctx->label);
|
||||||
ABORT(R_BAD_DATA);
|
ABORT(R_BAD_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
mapped_addr = &ctx->results.stun_binding_response.mapped_addr;
|
mapped_addr = &ctx->results.stun_binding_response.mapped_addr;
|
||||||
break;
|
break;
|
||||||
|
@ -671,25 +694,37 @@ int nr_stun_client_process_response(nr_stun_client_ctx *ctx, UCHAR *msg, int len
|
||||||
|
|
||||||
#ifdef USE_TURN
|
#ifdef USE_TURN
|
||||||
case NR_TURN_CLIENT_MODE_ALLOCATE_REQUEST:
|
case NR_TURN_CLIENT_MODE_ALLOCATE_REQUEST:
|
||||||
if (! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_XOR_MAPPED_ADDRESS, 0))
|
if (! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_XOR_MAPPED_ADDRESS, 0)) {
|
||||||
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): No XOR-MAPPED-ADDRESS",ctx->label);
|
||||||
ABORT(R_BAD_DATA);
|
ABORT(R_BAD_DATA);
|
||||||
if (! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_MESSAGE_INTEGRITY, 0))
|
}
|
||||||
|
if (! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_MESSAGE_INTEGRITY, 0)) {
|
||||||
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): No MESSAGE-INTEGRITY",ctx->label);
|
||||||
ABORT(R_BAD_DATA);
|
ABORT(R_BAD_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
if (!nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_XOR_RELAY_ADDRESS, &attr))
|
if (!nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_XOR_RELAY_ADDRESS, &attr)) {
|
||||||
ABORT(R_BAD_DATA);
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): No XOR-RELAYED-ADDRESS",ctx->label);
|
||||||
|
ABORT(R_BAD_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
if ((r=nr_stun_transport_addr_check(&attr->u.relay_address.unmasked,
|
if ((r=nr_stun_transport_addr_check(&attr->u.relay_address.unmasked,
|
||||||
ctx->mapped_addr_check_mask)))
|
ctx->mapped_addr_check_mask))) {
|
||||||
ABORT(r);
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): nr_stun_transport_addr_check failed",ctx->label);
|
||||||
|
ABORT(r);
|
||||||
|
}
|
||||||
|
|
||||||
if ((r=nr_transport_addr_copy(
|
if ((r=nr_transport_addr_copy(
|
||||||
&ctx->results.allocate_response.relay_addr,
|
&ctx->results.allocate_response.relay_addr,
|
||||||
&attr->u.relay_address.unmasked)))
|
&attr->u.relay_address.unmasked))) {
|
||||||
ABORT(r);
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): nr_transport_addr_copy failed",ctx->label);
|
||||||
|
ABORT(r);
|
||||||
|
}
|
||||||
|
|
||||||
if (!nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_LIFETIME, &attr))
|
if (!nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_LIFETIME, &attr)) {
|
||||||
ABORT(R_BAD_DATA);
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): No LIFETIME",ctx->label);
|
||||||
|
ABORT(R_BAD_DATA);
|
||||||
|
}
|
||||||
ctx->results.allocate_response.lifetime_secs=attr->u.lifetime_secs;
|
ctx->results.allocate_response.lifetime_secs=attr->u.lifetime_secs;
|
||||||
|
|
||||||
r_log(NR_LOG_STUN,LOG_DEBUG,"STUN-CLIENT(%s): Received relay address: %s", ctx->label, ctx->results.allocate_response.relay_addr.as_string);
|
r_log(NR_LOG_STUN,LOG_DEBUG,"STUN-CLIENT(%s): Received relay address: %s", ctx->label, ctx->results.allocate_response.relay_addr.as_string);
|
||||||
|
@ -698,15 +733,21 @@ int nr_stun_client_process_response(nr_stun_client_ctx *ctx, UCHAR *msg, int len
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NR_TURN_CLIENT_MODE_REFRESH_REQUEST:
|
case NR_TURN_CLIENT_MODE_REFRESH_REQUEST:
|
||||||
if (! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_MESSAGE_INTEGRITY, 0))
|
if (! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_MESSAGE_INTEGRITY, 0)) {
|
||||||
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): No MESSAGE-INTEGRITY",ctx->label);
|
||||||
ABORT(R_BAD_DATA);
|
ABORT(R_BAD_DATA);
|
||||||
if (!nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_LIFETIME, &attr))
|
}
|
||||||
ABORT(R_BAD_DATA);
|
if (!nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_LIFETIME, &attr)) {
|
||||||
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): No LIFETIME",ctx->label);
|
||||||
|
ABORT(R_BAD_DATA);
|
||||||
|
}
|
||||||
ctx->results.refresh_response.lifetime_secs=attr->u.lifetime_secs;
|
ctx->results.refresh_response.lifetime_secs=attr->u.lifetime_secs;
|
||||||
break;
|
break;
|
||||||
case NR_TURN_CLIENT_MODE_PERMISSION_REQUEST:
|
case NR_TURN_CLIENT_MODE_PERMISSION_REQUEST:
|
||||||
if (! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_MESSAGE_INTEGRITY, 0))
|
if (! nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_MESSAGE_INTEGRITY, 0)) {
|
||||||
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): No MESSAGE-INTEGRITY",ctx->label);
|
||||||
ABORT(R_BAD_DATA);
|
ABORT(R_BAD_DATA);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#endif /* USE_TURN */
|
#endif /* USE_TURN */
|
||||||
|
|
||||||
|
@ -725,22 +766,32 @@ int nr_stun_client_process_response(nr_stun_client_ctx *ctx, UCHAR *msg, int len
|
||||||
if (mapped_addr) {
|
if (mapped_addr) {
|
||||||
if (nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_XOR_MAPPED_ADDRESS, &attr)) {
|
if (nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_XOR_MAPPED_ADDRESS, &attr)) {
|
||||||
if ((r=nr_stun_transport_addr_check(&attr->u.xor_mapped_address.unmasked,
|
if ((r=nr_stun_transport_addr_check(&attr->u.xor_mapped_address.unmasked,
|
||||||
ctx->mapped_addr_check_mask)))
|
ctx->mapped_addr_check_mask))) {
|
||||||
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): XOR-MAPPED-ADDRESS is bogus",ctx->label);
|
||||||
ABORT(r);
|
ABORT(r);
|
||||||
|
}
|
||||||
|
|
||||||
if ((r=nr_transport_addr_copy(mapped_addr, &attr->u.xor_mapped_address.unmasked)))
|
if ((r=nr_transport_addr_copy(mapped_addr, &attr->u.xor_mapped_address.unmasked))) {
|
||||||
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): nr_transport_addr_copy failed",ctx->label);
|
||||||
ABORT(r);
|
ABORT(r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_MAPPED_ADDRESS, &attr)) {
|
else if (nr_stun_message_has_attribute(ctx->response, NR_STUN_ATTR_MAPPED_ADDRESS, &attr)) {
|
||||||
if ((r=nr_stun_transport_addr_check(&attr->u.mapped_address,
|
if ((r=nr_stun_transport_addr_check(&attr->u.mapped_address,
|
||||||
ctx->mapped_addr_check_mask)))
|
ctx->mapped_addr_check_mask))) {
|
||||||
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): MAPPED-ADDRESS is bogus",ctx->label);
|
||||||
ABORT(r);
|
ABORT(r);
|
||||||
|
}
|
||||||
|
|
||||||
if ((r=nr_transport_addr_copy(mapped_addr, &attr->u.mapped_address)))
|
if ((r=nr_transport_addr_copy(mapped_addr, &attr->u.mapped_address))) {
|
||||||
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): nr_transport_addr_copy failed",ctx->label);
|
||||||
ABORT(r);
|
ABORT(r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
|
r_log(NR_LOG_STUN,LOG_WARNING,"STUN-CLIENT(%s): No mapped address!",ctx->label);
|
||||||
ABORT(R_BAD_DATA);
|
ABORT(R_BAD_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
// STUN doesn't distinguish protocol in mapped address, therefore
|
// STUN doesn't distinguish protocol in mapped address, therefore
|
||||||
// assign used protocol from peer_addr
|
// assign used protocol from peer_addr
|
||||||
|
|
Загрузка…
Ссылка в новой задаче