add 'rtignoreexpire' option to allow Realtime addresses to be used regardless of expiration time (bug #4362)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5889 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.2-netsec
Kevin P. Fleming 21 years ago
parent bd325f5219
commit 5736270107

@ -239,6 +239,7 @@ struct iax2_context {
#define IAX_RTNOUPDATE (1 << 18) /* Don't send a realtime update */
#define IAX_RTAUTOCLEAR (1 << 19) /* erase me on expire */
#define IAX_FORCEJITTERBUF (1 << 20) /* Force jitterbuffer, even when bridged to a channel that can take jitter */
#define IAX_RTIGNOREREGEXPIRE (1 << 21)
static int global_rtautoclear = 120;
@ -2579,7 +2580,7 @@ static struct iax2_peer *realtime_peer(const char *peername)
ast_set_flag(peer, IAX_TEMPONLY);
}
if (dynamic) {
if (!ast_test_flag(&globalflags, IAX_RTIGNOREREGEXPIRE) && dynamic) {
time(&nowtime);
if ((nowtime - regseconds) > IAX_DEFAULT_REG_EXPIRE) {
memset(&peer->addr, 0, sizeof(peer->addr));
@ -8371,6 +8372,8 @@ static int set_config(char *config_file, int reload)
ast_set2_flag((&globalflags), ast_true(v->value), IAX_MESSAGEDETAIL);
else if (!strcasecmp(v->name, "rtcachefriends"))
ast_set2_flag((&globalflags), ast_true(v->value), IAX_RTCACHEFRIENDS);
else if (!strcasecmp(v->name, "rtignoreregexpire"))
ast_set2_flag((&globalflags), ast_true(v->value), IAX_RTIGNOREREGEXPIRE);
else if (!strcasecmp(v->name, "rtnoupdate"))
ast_set2_flag((&globalflags), ast_true(v->value), IAX_RTNOUPDATE);
else if (!strcasecmp(v->name, "rtautoclear")) {

@ -400,6 +400,7 @@ struct sip_auth {
#define SIP_PAGE2_RTCACHEFRIENDS (1 << 0)
#define SIP_PAGE2_RTNOUPDATE (1 << 1)
#define SIP_PAGE2_RTAUTOCLEAR (1 << 2)
#define SIP_PAGE2_RTIGNOREREGEXPIRE (1 << 3)
static int global_rtautoclear = 120;
@ -5181,7 +5182,7 @@ static int parse_contact(struct sip_pvt *pvt, struct sip_peer *p, struct sip_req
p->expire = -1;
pvt->expiry = expiry;
snprintf(data, sizeof(data), "%s:%d:%d:%s:%s", ast_inet_ntoa(iabuf, sizeof(iabuf), p->addr.sin_addr), ntohs(p->addr.sin_port), expiry, p->username, p->fullcontact);
if (!ast_test_flag(p, SIP_REALTIME))
if (!(ast_test_flag(p, SIP_REALTIME) && ast_test_flag((&p->flags_page2), SIP_PAGE2_RTCACHEFRIENDS)))
ast_db_put("SIP/Registry", p->name, data);
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: SIP/%s\r\nPeerStatus: Registered\r\n", p->name);
if (inaddrcmp(&p->addr, &oldsin)) {
@ -10453,9 +10454,9 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int
peer->auth = add_realm_authentication(peer->auth, v->value, v->lineno);
else if (!strcasecmp(v->name, "callerid")) {
ast_callerid_split(v->value, peer->cid_name, sizeof(peer->cid_name), peer->cid_num, sizeof(peer->cid_num));
} else if (!strcasecmp(v->name, "context"))
} else if (!strcasecmp(v->name, "context")) {
ast_copy_string(peer->context, v->value, sizeof(peer->context));
else if (!strcasecmp(v->name, "fromdomain"))
} else if (!strcasecmp(v->name, "fromdomain"))
ast_copy_string(peer->fromdomain, v->value, sizeof(peer->fromdomain));
else if (!strcasecmp(v->name, "usereqphone"))
ast_set2_flag(peer, ast_true(v->value), SIP_USEREQPHONE);
@ -10593,7 +10594,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int
*/
v=v->next;
}
if (realtime && ast_test_flag(peer, SIP_DYNAMIC)) {
if (realtime && !ast_test_flag((&global_flags_page2), SIP_PAGE2_RTIGNOREREGEXPIRE) && ast_test_flag(peer, SIP_DYNAMIC)) {
time_t nowtime;
time(&nowtime);
@ -10707,6 +10708,8 @@ static int reload_config(void)
ast_set2_flag((&global_flags_page2), ast_true(v->value), SIP_PAGE2_RTCACHEFRIENDS);
} else if (!strcasecmp(v->name, "rtnoupdate")) {
ast_set2_flag((&global_flags_page2), ast_true(v->value), SIP_PAGE2_RTNOUPDATE);
} else if (!strcasecmp(v->name, "rtignoreregexpire")) {
ast_set2_flag((&global_flags_page2), ast_true(v->value), SIP_PAGE2_RTIGNOREREGEXPIRE);
} else if (!strcasecmp(v->name, "rtautoclear")) {
int i = atoi(v->value);
if (i > 0)

@ -264,6 +264,10 @@ autokill=yes
;
;rtautoclear=yes
;
;rtignoreexpire=yes ; when reading a peer from Realtime, if the peer's registration
; has expired based on its registration interval, used the stored
; address information regardless
; Guest sections for unauthenticated connection attempts. Just
; specify an empty secret, or provide no secret section.
;

@ -174,8 +174,11 @@ srvlookup=yes ; Enable DNS SRV lookups on outbound calls
; as if it had just registered when the registration expires
; the friend will vanish from the configuration until requested
; again. If set to an integer, friends expire
; within this number of seconds instead of the
; same as the registration interval
; within this number of seconds instead of the
; same as the registration interval
;rtignoreexpire=yes ; when reading a peer from Realtime, if the peer's registration
; has expired based on its registration interval, used the stored
; address information regardless
[authentication]

Loading…
Cancel
Save