diff options
author | David Troy <dave@popvox.com> | 2006-04-01 18:07:37 +0000 |
---|---|---|
committer | David Troy <dave@popvox.com> | 2006-04-01 18:07:37 +0000 |
commit | cf834d379b5a6a7393d0c25386c55959f5df4550 (patch) | |
tree | 184cdfdb2eb85b5f5cc47ca3a83beb400973b406 | |
parent | f723379bb0de062ba8203e0dba098b146075fb15 (diff) | |
download | astmanproxy-cf834d379b5a6a7393d0c25386c55959f5df4550.tar.gz astmanproxy-cf834d379b5a6a7393d0c25386c55959f5df4550.tar.xz astmanproxy-cf834d379b5a6a7393d0c25386c55959f5df4550.zip |
git-svn-id: http://svncommunity.digium.com/svn/astmanproxy/branches/1.20pre@52 f02b47b9-160a-0410-81a6-dc3441afb0ec
-rw-r--r-- | src/astmanproxy.c | 2 | ||||
-rw-r--r-- | src/proxyfunc.c | 19 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/astmanproxy.c b/src/astmanproxy.c index 065c05a..31af40d 100644 --- a/src/astmanproxy.c +++ b/src/astmanproxy.c @@ -277,6 +277,8 @@ void *session_do(struct mansession *s) ProxyLogin(s, astman_get_header(&m, "UserName"), astman_get_header(&m, "Secret")); else if ( !strcasecmp(action, "Logoff") ) ProxyLogoff(s); + else if ( !strcasecmp(action, "Challenge") ) + ProxyChallenge(s, &m); else if ( !(*proxyaction == '\0') ) proxyaction_do(proxyaction, &m, s); else if ( ValidateAction(&m, s ,0) ) { diff --git a/src/proxyfunc.c b/src/proxyfunc.c index 31094f8..ed4770e 100644 --- a/src/proxyfunc.c +++ b/src/proxyfunc.c @@ -64,6 +64,25 @@ void *ProxySetOutputFormat(struct mansession *s, struct message *m) { return 0; } +int ProxyChallenge(struct mansession *s, struct message *m) { + struct message mo; + + if ( strcasecmp("MD5", astman_get_header(m, "AuthType")) ) { + SendError(s, "Must specify AuthType"); + return 1; + } + + if (!*s->challenge) + snprintf(s->challenge, sizeof(s->challenge), "%d", rand()); + + memset(&mo, 0, sizeof(struct message)); + AddHeader(&mo, "Response: Success"); + AddHeader(&mo, "Challenge: %d", s->challenge); + + s->output->write(s, &mo); + return 0; +} + void *ProxySetAutoFilter(struct mansession *s, struct message *m) { struct message mo; char *value; |