]>
Commit | Line | Data |
---|---|---|
0ba70e7b CP |
1 | /* |
2 | * CMDNAME: challenge | |
3 | * CMDLEVEL: QCMD_SECURE | QCMD_NOTAUTHED | |
4 | * CMDARGS: 0 | |
5 | * CMDDESC: Returns a challenge for use in challengeauth. | |
6 | * CMDFUNC: csa_dochallenge | |
7 | * CMDPROTO: int csa_dochallenge(void *source, int cargc, char **cargv); | |
c131e6ed CP |
8 | * CMDHELP: Usage: challenge |
9 | * CMDHELP: Supplies you with a challenge and a list of algorithms accepted | |
10 | * CMDHELP: for challenge response authentication, see CHALLENGEAUTH help | |
11 | * CMDHELP: for more details. | |
0ba70e7b CP |
12 | */ |
13 | ||
14 | #include "../chanserv.h" | |
15 | #include "../authlib.h" | |
16 | #include "../../lib/irc_string.h" | |
0ba70e7b CP |
17 | #include <stdio.h> |
18 | #include <string.h> | |
19 | #include <time.h> | |
20 | ||
21 | int csa_dochallenge(void *source, int cargc, char **cargv) { | |
22 | nick *sender=source; | |
23 | activeuser* aup; | |
b7a95f03 | 24 | time_t t; |
45770ae6 | 25 | |
0ba70e7b CP |
26 | if (!(aup=getactiveuserfromnick(sender))) |
27 | return CMD_ERROR; | |
28 | ||
b7a95f03 | 29 | t = time(NULL); |
0ba70e7b CP |
30 | if(t > aup->entropyttl) { |
31 | cs_getrandbytes(aup->entropy,ENTROPYLEN); | |
32 | aup->entropyttl=t + 30; | |
33 | } | |
34 | ||
721cc8ce | 35 | chanservsendmessage(sender,"CHALLENGE %s %s",cs_calcchallenge(aup->entropy),cs_cralgorithmlist()); |
0ba70e7b CP |
36 | cs_log(sender,"CHALLENGE"); |
37 | ||
38 | return CMD_OK; | |
39 | } |