Skip to content
Snippets Groups Projects
Commit 5a675988 authored by Tilghman Lesher's avatar Tilghman Lesher
Browse files

Merged revisions 94660 via svnmerge from

https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r94660 | tilghman | 2007-12-22 19:21:03 -0600 (Sat, 22 Dec 2007) | 2 lines

Argh... I suppose third time's the charm.

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@94662 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 67a70450
Branches
Tags
No related merge requests found
......@@ -3093,33 +3093,34 @@ static struct sip_peer *realtime_peer(const char *newpeername, struct sockaddr_i
varregs = ast_load_realtime("sipregs", "name", newpeername, NULL);
 
var = ast_load_realtime("sippeers", "name", newpeername, "host", "dynamic", NULL);
if (!var && sin) {
if (!var && sin)
var = ast_load_realtime("sippeers", "name", newpeername, "host", ast_inet_ntoa(sin->sin_addr), NULL);
if (!var) {
var = ast_load_realtime("sippeers", "name", newpeername, NULL);
/*!\note
* If this one loaded something, then we need to ensure that the host
* field matched. The only reason why we can't have this as a criteria
* is because we only have the IP address and the host field might be
* set as a name (and the reverse PTR might not match).
*/
if (var) {
for (tmp = var; tmp; tmp = tmp->next) {
if (!strcasecmp(var->name, "host")) {
struct in_addr sin2 = { 0, };
struct ast_dnsmgr_entry *dnsmgr = NULL;
if ((ast_dnsmgr_lookup(tmp->value, &sin2, &dnsmgr) < 0) || (memcmp(&sin2, &sin->sin_addr, sizeof(sin2)) != 0)) {
/* No match */
ast_variables_destroy(var);
var = NULL;
}
break;
if (!var) {
var = ast_load_realtime("sippeers", "name", newpeername, NULL);
/*!\note
* If this one loaded something, then we need to ensure that the host
* field matched. The only reason why we can't have this as a criteria
* is because we only have the IP address and the host field might be
* set as a name (and the reverse PTR might not match).
*/
if (var) {
for (tmp = var; tmp; tmp = tmp->next) {
if (!strcasecmp(var->name, "host")) {
struct in_addr sin2 = { 0, };
struct ast_dnsmgr_entry *dnsmgr = NULL;
if ((ast_dnsmgr_lookup(tmp->value, &sin2, &dnsmgr) < 0) || (memcmp(&sin2, &sin->sin_addr, sizeof(sin2)) != 0)) {
/* No match */
ast_variables_destroy(var);
var = NULL;
}
break;
}
}
}
}
} else if (sin) { /* Then check on IP address for dynamic peers */
}
if (!var && sin) { /* Then check on IP address for dynamic peers */
ast_copy_string(ipaddr, ast_inet_ntoa(sin->sin_addr), sizeof(ipaddr));
portnum = ntohs(sin->sin_port);
sprintf(portstring, "%u", portnum);
......@@ -3139,7 +3140,7 @@ static struct sip_peer *realtime_peer(const char *newpeername, struct sockaddr_i
var = ast_load_realtime("sippeers", "name", newpeername, NULL);
}
}
if(!var) { /*We couldn't match on ipaddress and port, so we need to check if port is insecure*/
if (!var) { /*We couldn't match on ipaddress and port, so we need to check if port is insecure*/
peerlist = ast_load_realtime_multientry("sippeers", "host", ipaddr, NULL);
if (peerlist) {
var = get_insecure_variable_from_config(peerlist);
......@@ -3163,7 +3164,7 @@ static struct sip_peer *realtime_peer(const char *newpeername, struct sockaddr_i
}
}
} else {
if(realtimeregs) {
if (realtimeregs) {
peerlist = ast_load_realtime_multientry("sipregs", "ipaddr", ipaddr, NULL);
if (peerlist) {
varregs = get_insecure_variable_from_config(peerlist);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment