Use stored secret if available, properly

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1281 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2003-08-09 19:33:40 +00:00
parent 51b800f40a
commit f37a567e8c
2 changed files with 44 additions and 15 deletions

View File

@@ -1498,7 +1498,7 @@ static int iax2_fixup(struct ast_channel *oldchannel, struct ast_channel *newcha
return 0;
}
static int create_addr(struct sockaddr_in *sin, int *capability, int *sendani, int *maxtime, char *peer, char *context, int *trunk, int *notransfer)
static int create_addr(struct sockaddr_in *sin, int *capability, int *sendani, int *maxtime, char *peer, char *context, int *trunk, int *notransfer, char *secret, int seclen)
{
struct hostent *hp;
struct iax2_peer *p;
@@ -1527,6 +1527,8 @@ static int create_addr(struct sockaddr_in *sin, int *capability, int *sendani, i
*trunk = p->trunk;
if (capability)
*capability = p->capability;
if (secret)
strncpy(secret, p->secret, seclen);
if (p->addr.sin_addr.s_addr) {
sin->sin_addr = p->addr.sin_addr;
sin->sin_port = p->addr.sin_port;
@@ -1590,6 +1592,7 @@ static int iax2_call(struct ast_channel *c, char *dest, int timeout)
char *opts = "";
struct chan_iax2_pvt *p = c->pvt->pvt;
char *stringp=NULL;
char storedsecret[80];
if ((c->_state != AST_STATE_DOWN) && (c->_state != AST_STATE_RESERVED)) {
ast_log(LOG_WARNING, "Line is already in use (%s)?\n", c->name);
return -1;
@@ -1631,7 +1634,7 @@ static int iax2_call(struct ast_channel *c, char *dest, int timeout)
strsep(&stringp, ":");
portno = strsep(&stringp, ":");
}
if (create_addr(&sin, NULL, NULL, NULL, hname, context, NULL, NULL)) {
if (create_addr(&sin, NULL, NULL, NULL, hname, context, NULL, NULL, storedsecret, sizeof(storedsecret) - 1)) {
ast_log(LOG_WARNING, "No address associated with '%s'\n", hname);
return -1;
}
@@ -1676,6 +1679,8 @@ static int iax2_call(struct ast_channel *c, char *dest, int timeout)
iax_ie_append_str(&ied, IAX_IE_CALLED_CONTEXT, rcontext);
if (username)
iax_ie_append_str(&ied, IAX_IE_USERNAME, username);
if (!secret && strlen(storedsecret))
secret = storedsecret;
if (secret) {
if (secret[0] == '[') {
/* This is an RSA key, not a normal secret */
@@ -4619,7 +4624,7 @@ static struct ast_channel *iax2_request(char *type, int format, void *data)
if (!st)
st = s;
/* Populate our address from the given */
if (create_addr(&sin, &capability, &sendani, &maxtime, st, NULL, &trunk, &notransfer)) {
if (create_addr(&sin, &capability, &sendani, &maxtime, st, NULL, &trunk, &notransfer, NULL, 0)) {
return NULL;
}
callno = find_callno(0, 0, &sin, NEW_FORCE, 1);
@@ -5250,7 +5255,7 @@ static int cache_get_callno(char *data)
host = st;
}
/* Populate our address from the given */
if (create_addr(&sin, NULL, NULL, NULL, host, NULL, NULL, NULL)) {
if (create_addr(&sin, NULL, NULL, NULL, host, NULL, NULL, NULL, NULL, 0)) {
return -1;
}
ast_log(LOG_DEBUG, "host: %s, user: %s, password: %s, context: %s\n", host, username, password, context);

View File

@@ -30,6 +30,41 @@ maxlogins=3
; Change the email body, variables: VM_NAME, VM_DUR, VM_MSGNUM, VM_MAILBOX, VM_CALLERID, VM_DATE
;emailbody=Dear ${VM_NAME}:\n\n\tjust wanted to let you know you were just left a ${VM_DUR} long message (number ${VM_MSGNUM})\nin mailbox ${VM_MAILBOX} from ${VM_CALLERID}, on ${VM_DATE} so you might\nwant to check it when you get a chance. Thanks!\n\n\t\t\t\t--Asterisk\n
;
; Users may be located in different timezones, or may have different
; message announcements for their introductory message when they enter
; the voicemail system. Set the message and the timezone each user
; hears here. Set the user into one of these zones with the tz= attribute
; in the options field of the mailbox. Of course, language substitution
; still applies here so you may have several directory trees that have
; alternate language choices.
;
; Look in /usr/share/zoneinfo/ for names of timezones.
; Look at the manual page for strftime for a quick tutorial on how the
; variable substitution is done on the values below.
;
; Supported values:
; 'filename' = filename of a soundfile
; '${VAR}' = variable substitution
; 'A' or 'a' = Day of week (Saturday, Sunday, ...)
; 'B' or 'b' or 'h' = Month name (January, February, ...)
; 'd' or 'e' = numeric day of month (first, second, ..., thirty-first)
; 'Y' = Year
; 'I' or 'l' = hour, 12 hour clock
; 'H' or 'k' = hour, 24 hour clock (single digit hours preceeded by "oh")
; 'M' = minute
; 'P' or 'p' = AM or PM
; 'Q' = "today", "yesterday" or ABdY (*note: not standard strftime value)
; 'q' = "today", "yesterday", weekday, or ABdY (*note: not standard strftime value)
; 'R' = 24 hour time, including minute
;
;
[zonemessages]
eastern=America/NewYork|'vm-received' Q 'digits/at' IMp
central=America/Chicago|'vm-received' Q 'digits/at' IMp
central24=America/Chicago|'vm-received' 'digits/at' H 'digits/hundred' M
;
; Each mailbox is listed in the form <mailbox>=<password>,<name>,<email>,<pager_email>,<options>
; if the e-mail is specified, a message will be sent when a message is
@@ -50,14 +85,3 @@ maxlogins=3
[other]
1234 => 5678,Company2 User,root@localhost
;
; Users may be located in different timezones. Set the message and the
; timezone each user hears here. Set the user into one of these zones with
; the tz= attribute in the options field of the mailbox.
;
[zonemessages]
eastern=America/NewYork|'vm-received' Q 'digits/at' IMp
central=America/Chicago|'vm-received' Q 'digits/at' IMp
central24=America/Chicago|'vm-received' 'digits/at' H 'digits/hundred' M