diff options
-rw-r--r-- | res/res_pjsip.c | 3 | ||||
-rw-r--r-- | res/res_pjsip/pjsip_configuration.c | 22 |
2 files changed, 24 insertions, 1 deletions
diff --git a/res/res_pjsip.c b/res/res_pjsip.c index 4d9a19e2b..9718e6c43 100644 --- a/res/res_pjsip.c +++ b/res/res_pjsip.c @@ -254,7 +254,7 @@ <synopsis>Authentication object used for outbound requests</synopsis> </configOption> <configOption name="outbound_proxy"> - <synopsis>Proxy through which to send requests</synopsis> + <synopsis>Proxy through which to send requests, a full SIP URI must be provided</synopsis> </configOption> <configOption name="rewrite_contact"> <synopsis>Allow Contact header to be rewritten with the source IP address-port</synopsis> @@ -1401,6 +1401,7 @@ pjsip_dialog *ast_sip_create_dialog_uac(const struct ast_sip_endpoint *endpoint, pj_strdup2_with_null(dlg->pool, &tmp, outbound_proxy); if (!(route = pjsip_parse_hdr(dlg->pool, &ROUTE_HNAME, tmp.ptr, tmp.slen, NULL))) { + dlg->sess_count--; pjsip_dlg_terminate(dlg); return NULL; } diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c index 151ab1016..0f98a65ae 100644 --- a/res/res_pjsip/pjsip_configuration.c +++ b/res/res_pjsip/pjsip_configuration.c @@ -595,6 +595,28 @@ static int sip_endpoint_apply_handler(const struct ast_sorcery *sorcery, void *o return -1; } + if (!ast_strlen_zero(endpoint->outbound_proxy)) { + pj_pool_t *pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(), "Outbound Proxy Validation", 256, 256); + static const pj_str_t ROUTE_HNAME = { "Route", 5 }; + pj_str_t tmp; + + if (!pool) { + ast_log(LOG_ERROR, "Could not allocate pool for outbound proxy validation on '%s'\n", + ast_sorcery_object_get_id(endpoint)); + return -1; + } + + pj_strdup2_with_null(pool, &tmp, endpoint->outbound_proxy); + if (!pjsip_parse_hdr(pool, &ROUTE_HNAME, tmp.ptr, tmp.slen, NULL)) { + ast_log(LOG_ERROR, "Invalid outbound proxy '%s' specified on endpoint '%s'\n", + endpoint->outbound_proxy, ast_sorcery_object_get_id(endpoint)); + pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool); + return -1; + } + + pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool); + } + return 0; } |