/* Q9 Version */
#define QVERSION "1.00"
+/* Achievements: Nothing before ACHIEVEMENTS_START
+ * opt-in only after ACHIEVEMENTS_END
+ * Titles are valid only between ACHIEVEMENTS_START and ACHIEVEMENTS_END */
+
+//#define ACH_TEST_APRIL1
+
+#ifdef ACH_TEST_APRIL1
+
+#define ACHIEVEMENTS_START 1269702917
+#define ACHIEVEMENTS_END 1270162800
+
+#elif defined(ACH_TEST_POSTAPRIL1)
+
+#define ACHIEVEMENTS_START 0
+#define ACHIEVEMENTS_END 1269702917
+
+#else
+
+#define ACHIEVEMENTS_START 1270076400
+#define ACHIEVEMENTS_END 1270162800
+
+#endif
+
/* Mini-hash of known users on channels to make lookups faster;
* how big do we make it? */
#define REGCHANUSERHASHSIZE 5
#define LINGERTIME 300
#define DUMPINTERVAL 300
#define EMAILLEN 60
-#define CHANTYPES 8
+#define CHANTYPES 9
#define CHANOPHISTORY 10
/* Suspension and g-line hit count limits */
#define MAXSUSPENDHIT 500
/* Maximum number of times a user may attempt to auth */
-#define MAXAUTHATTEMPT 10
+#define MAXAUTHATTEMPT 5
/* Maximum number of hellos in a session */
#define MAXHELLOS 2
#define CHALLENGEAUTHSITE "http://www.quakenet.org/development/challengeauth/"
/* Cleanup options */
-#define CLEANUP_ACCOUNT_INACTIVE 80
-#define CLEANUP_ACCOUNT_UNUSED 10
-#define CLEANUP_CHANNEL_INACTIVE 40
+#define CLEANUP_ACCOUNT_INACTIVE 240 /* make sure you update CLEANUP_AUTHHISTORY too... */
+#define CLEANUP_ACCOUNT_UNUSED 3
+#define CLEANUP_CHANNEL_INACTIVE 120
+
+#define CLEANUP_AUTHHISTORY 300
-#define CLEANUP_AUTHHISTORY 60
+#define CLEANUP_MIN_CHAN_SIZE 2
/* Sizes of the main hashes */
#define REGUSERHASHSIZE 60000
#define MAXCHANLEVS 500
#define MAXBANS 50
+/* Maximum number of channels a user may be known on */
+#define MAXCHANNELS 500
+
/* Sources of entropy and standard length defines */
#define ENTROPYSOURCE "/dev/urandom"
#define ENTROPYLEN 8
/* Minimum acceptable reason length for stuff like deluser */
-#define MIN_REASONLEN 20
+#define MIN_REASONLEN 15
#include "chanserv_messages.h"
#define QPRIV_VIEWCHANSUSPENSION 110
#define QPRIV_VIEWSUSPENDEDBY 111
#define QPRIV_VIEWWALLMESSAGE 112
+#define QPRIV_VIEWREALHOST 113
#define QPRIV_CHANGECHANFLAGS 200
#define QPRIV_CHANGECHANLEV 201
#define QPRIV_CHANGEBANTIMER 204
#define QPRIV_CHANGEUSERFLAGS 205
#define QPRIV_CHANGEWELCOME 206
+#define QPRIV_RESETCHANSTAT 207
/* List of access checks */
/* User flags */
-#define QUFLAG_NOINFO 0x0001 /* +s */
+/* to reenable this also grep for NOINFO... as some code has been commented out */
+//#define QUFLAG_NOINFO 0x0001 /* +s */
+#define QUFLAG_INACTIVE 0x0001 /* +I */
#define QUFLAG_GLINE 0x0002 /* +g */
#define QUFLAG_NOTICE 0x0004 /* +n */
#define QUFLAG_STAFF 0x0008 /* +q */
#define QUFLAG_TRUST 0x8000 /* +T */
#define QUFLAG_ALL 0xffff
-#define UIsNoInfo(x) ((x)->flags & QUFLAG_NOINFO)
+//#define UIsNoInfo(x) ((x)->flags & QUFLAG_NOINFO)
+#define UIsNoInfo(x) 0
+#define UIsInactive(x) ((x)->flags & QUFLAG_INACTIVE)
#define UIsGline(x) ((x)->flags & QUFLAG_GLINE)
#define UIsNotice(x) ((x)->flags & QUFLAG_NOTICE)
#define UIsSuspended(x) ((x)->flags & QUFLAG_SUSPENDED)
#define UHasOperPriv(x) ((x)->flags & (QUFLAG_OPER | QUFLAG_ADMIN | QUFLAG_DEV))
#define UHasAdminPriv(x) ((x)->flags & (QUFLAG_ADMIN | QUFLAG_DEV))
+#define USetInactive(x) ((x)->flags |= QUFLAG_INACTIVE)
#define USetGline(x) ((x)->flags |= QUFLAG_GLINE)
#define USetNotice(x) ((x)->flags |= QUFLAG_NOTICE)
#define USetSuspended(x) ((x)->flags |= QUFLAG_SUSPENDED)
#define USetCleanupExempt(x) ((x)->flags |= QUFLAG_CLEANUPEXEMPT)
#define USetTrust(x) ((x)->flags |= QUFLAG_TRUST)
+#define UClearInactive(x) ((x)->flags &= ~QUFLAG_INACTIVE)
#define UClearGline(x) ((x)->flags &= ~QUFLAG_GLINE)
#define UClearNotice(x) ((x)->flags &= ~QUFLAG_NOTICE)
#define UClearSuspended(x) ((x)->flags &= ~QUFLAG_SUSPENDED)
/* email */
#define MAX_RESEND_TIME 2*3600L /* cooling off period */
-#define VALID_EMAIL "^[-_.+[:alpha:][:digit:]]+(\\.[-_[:digit:][:alpha:]]+)*@([[:digit:][:alpha:]](-?[[:digit:][:alpha:]])*\\.)+[[:alpha:]]{2}([zmuvtgo]|fo|me|seum|op|ro)?$"
+#define VALID_EMAIL "\\A[^\\s\\+@]+@([a-z0-9][a-z0-9\\-]*\\.)+[a-z]{2,}\\Z"
-#define VALID_ACCOUNT_NAME "^[-a-z0-9]*$"
+#define VALID_ACCOUNT_NAME "\\A[a-z][a-z0-9\\-]+\\Z"
#define QMAIL_NEWACCOUNT 1 /* new account */
#define QMAIL_REQPW 2 /* requestpassword */
#define QMAIL_NEWPW 3 /* new password */
#define QMAIL_RESET 4 /* reset account */
#define QMAIL_NEWEMAIL 5 /* new email address */
+#define QMAIL_ACTIVATEEMAIL 6 /* new style new account */
/* Channel flags */
QCFLAG_PROTECT|QCFLAG_TOPICSAVE|QCFLAG_VOICEALL| \
QCFLAG_WELCOME|QCFLAG_KNOWNONLY|QCFLAG_ACHIEVEMENTS )
-#define QCFLAG_ALL 0x7fff
+#define QCFLAG_ALL 0xffff
/* Channel user ("chanlev") flags */
#define QCMD_ALIAS 0x0100 /* Don't list on SHOWCOMMANDS */
#define QCMD_HIDDEN QCMD_ALIAS
-#define QCMD_ACHIEVEMENTS 0x0400 /* Allows access to achievement commands */
+#define QCMD_ACHIEVEMENTS 0x0400 /* Achievement-related commands */
+#define QCMD_TITLES 0x0800 /* Title-related commands */
#define CS_INIT_DB 0x1 /* Loading database.. */
#define CS_INIT_NOUSER 0x2 /* Loaded DB, waiting for user to be created */
void chanserv_finalinit();
/* chanservalloc.c */
-void chanservallocinit();
-void csfreeall();
regchan *getregchan();
void freeregchan(regchan *rcp);
reguser *getreguser();
char *csdb_gethelpstr(char *command, int language);
void csdb_createmail(reguser *rup, int type);
void csdb_dohelp(nick *np, Command *cmd);
+void csdb_flushchannelcounters(void *arg);
#define q9asyncquery(handler, tag, format, ...) dbasyncqueryi(q9dbid, handler, tag, format , ##__VA_ARGS__)
#define q9a_asyncquery(handler, tag, format, ...) dbasyncqueryi(q9adbid, handler, tag, format , ##__VA_ARGS__)
#define q9u_asyncquery(handler, tag, format, ...) dbasyncqueryi(q9udbid, handler, tag, format , ##__VA_ARGS__)
#define q9c_asyncquery(handler, tag, format, ...) dbasyncqueryi(q9cdbid, handler, tag, format , ##__VA_ARGS__)
+#define q9cleanup_asyncquery(handler, tag, format, ...) dbasyncqueryi(q9cleanupdbid, handler, tag, format , ##__VA_ARGS__)
/* chanservcrypto.c */
typedef int (*CRAlgorithm)(char *, const char *, const char *, const char *);
void chanservcommandinit();
void chanservcommandclose();
void chanservstdmessage(nick *np, int messageid, ... );
+void chanservstdvmessage(nick *np, reguser *rup, int messageid, int max_line_len, void (*callback)(nick *, char *), va_list va);
void chanservaddcommand(char *command, int flags, int maxparams, CommandHandler handler, char *description, const char *help);
void chanservremovecommand(char *command, CommandHandler handler);
void chanservaddctcpcommand(char *command, CommandHandler hander);
int checkresponse(reguser *rup, const unsigned char *entropy, const char *response, CRAlgorithm algorithm);
int checkhashpass(reguser *rup, const char *junk, const char *hash);
flag_t cs_sanitisechanlev(flag_t flags);
-typedef int (*UnbanFN)(void *arg, struct chanban *ban);
-int cs_unbanfn(nick *sender, chanindex *cip, UnbanFN fn, void *arg, int removepermbans, int abortonfailure);
+int cs_unbanfn(nick *sender, chanindex *cip, int (*fn)(void *arg, struct chanban *ban), void *arg, int removepermbans, int abortonfailure);
void cs_logchanop(regchan *rcp, char *nick, reguser *rup);
int checkreason(nick *np, char *reason);
+regchan *cs_addchan(chanindex *cip, nick *sender, reguser *addedby, reguser *founder, flag_t flags, flag_t forcemodes, flag_t denymodes, short type);
/* chanservstdcmds.c */
int cs_doshowcommands(void *source, int cargc, char **cargv);
void cs_handleopchange(int hooknum, void *arg);
void cs_handlenewban(int hooknum, void *arg);
void cs_handlechanlostuser(int hooknum, void *arg);
+int cs_ischannelactive(channel *cp, regchan *rcp);
/* chanservmessages.c */
void initmessages();
/* chanservschedule.c */
void chanservdgline(void *arg);
-/* authlib.c */
-int csa_checkeboy(nick *sender, char *eboy);
-void csa_createrandompw(char *pw, int n);
-int csa_checkthrottled(nick *sender, reguser *rup, char *s);
-
/* chanservdb_updates.c */
void csdb_updateauthinfo(reguser *rup);
void csdb_updatelastjoin(regchanuser *rcup);
u_int64_t cs_accountflagmap(reguser *rup);
u_int64_t cs_accountflagmap_str(char *flags);
+/* chanserv_cleanupdb.c */
+void cs_cleanupdb(nick *np);
+
#endif