mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
res_rtp_asterisk: Automatically refresh stunaddr from DNS
This allows the STUN server to change its IP address without having to reload the res_rtp_asterisk module. The refresh of the name resolution occurs first when the module is loaded, then recurringly, slightly after the previous DNS answer TTL expires. ASTERISK-29508 #close Change-Id: I7955a046293f913ba121bbd82153b04439e3465f
This commit is contained in:
committed by
George Joseph
parent
f01a0398f8
commit
6fbf55ac11
@@ -39,6 +39,11 @@
|
||||
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
/* \brief Delay between TTL expiration and the next DNS query, to make sure the
|
||||
resolver cache really expired. */
|
||||
#define EXTRA_TTL 2
|
||||
#define MAX_TTL ((INT_MAX - EXTRA_TTL) / 1000)
|
||||
|
||||
/*! \brief Destructor for a DNS query */
|
||||
static void dns_query_recurring_destroy(void *data)
|
||||
{
|
||||
@@ -91,10 +96,10 @@ static void dns_query_recurring_resolution_callback(const struct ast_dns_query *
|
||||
/* So.. if something has not externally cancelled this we can reschedule based on the TTL */
|
||||
if (!recurring->cancelled) {
|
||||
const struct ast_dns_result *result = ast_dns_query_get_result(query);
|
||||
int ttl = MIN(ast_dns_result_get_lowest_ttl(result), INT_MAX / 1000);
|
||||
int ttl = MIN(ast_dns_result_get_lowest_ttl(result), MAX_TTL);
|
||||
|
||||
if (ttl) {
|
||||
recurring->timer = ast_sched_add(ast_dns_get_sched(), ttl * 1000, dns_query_recurring_scheduled_callback, ao2_bump(recurring));
|
||||
recurring->timer = ast_sched_add(ast_dns_get_sched(), (ttl + EXTRA_TTL) * 1000, dns_query_recurring_scheduled_callback, ao2_bump(recurring));
|
||||
if (recurring->timer < 0) {
|
||||
/* It is impossible for this to be the last reference as the query has a reference to it */
|
||||
ao2_ref(recurring, -1);
|
||||
|
Reference in New Issue
Block a user