}
/*
- * registerlocaluserwithuserid:
+ * registerlocaluserwithuseridflags:
* This function creates a local user, and broadcasts it's existence to the net (if connected).
*/
-nick *registerlocaluserwithuserid(char *nickname, char *ident, char *host, char *realname, char *authname, unsigned long authid, flag_t umodes, UserMessageHandler handler) {
+nick *registerlocaluserwithuseridflags(char *nickname, char *ident, char *host, char *realname, char *authname, unsigned long authid, flag_t umodes, flag_t accountflags, UserMessageHandler handler) {
int i;
nick *newuser,*np;
struct irc_in_addr ipaddress;
newuser->nextbyrealname=newuser->realname->nicks;
newuser->realname->nicks=newuser;
newuser->umodes=umodes;
+ newuser->accountflags=accountflags;
memset(&ipaddress, 0, sizeof(ipaddress));
- ((unsigned short *)(ipaddress.in6_16))[5] = 0;
+ ((unsigned short *)(ipaddress.in6_16))[5] = 65535;
((unsigned short *)(ipaddress.in6_16))[6] = 127;
((unsigned char *)(ipaddress.in6_16))[14] = 1;
((unsigned char *)(ipaddress.in6_16))[15] = (currentlocalunum%253)+1;
newuser->ipnode = refnode(iptree, &ipaddress, PATRICIA_MAXBITS);
+ node_increment_usercount(newuser->ipnode);
+
newuser->timestamp=getnettime();
newuser->shident=NULL;
newuser->sethost=NULL;
*/
int deregisterlocaluser(nick *np, char *reason) {
- int defaultreason=0;
long numeric;
+ char reasonstr[512];
+ void *harg[2];
if (np==NULL || (homeserver(np->numeric)!=mylongnum)) {
/* Non-existent user, or user not on this server */
}
if (reason==NULL || *reason=='\0') {
- defaultreason=1;
+ sprintf(reasonstr,"Quit");
+ } else {
+ snprintf(reasonstr,510,"Quit: %s",reason);
}
+ harg[0]=np;
+ harg[1]=reasonstr;
+
+ triggerhook(HOOK_NICK_QUIT, harg);
+
numeric=np->numeric;
umhandlers[np->numeric&MAXLOCALUSER]=NULL;
deletenick(np);
if (connected) {
- irc_send("%s Q :Quit: %s",longtonumeric(numeric,5),(defaultreason?"Leaving":reason));
+ irc_send("%s Q :%s",longtonumeric(numeric,5),reasonstr);
}
return 0;
numericbuf[5]='\0';
if (IsAccount(np)) {
- if (np->auth) {
- irc_send("%s N %s 1 %ld %s %s %s %s:%ld:%lu %s %s :%s",
+ if(np->accountflags) {
+ irc_send("%s N %s 1 %ld %s %s %s %s:%ld:%lu:" FLAG_T_SPECIFIER " %s %s :%s",
mynumeric->content,np->nick,np->timestamp,np->ident,np->host->name->content,
- printflags(np->umodes,umodeflags),np->authname,np->accountts,np->auth->userid,
+ printflags(np->umodes,umodeflags),np->authname,np->accountts,np->auth?np->auth->userid:0,np->accountflags,
iptobase64(ipbuf, &(np->p_ipaddr), sizeof(ipbuf), 1),numericbuf,np->realname->name->content);
+ } else if (np->auth) {
+ irc_send("%s N %s 1 %ld %s %s %s %s:%ld:%lu %s %s :%s",
+ mynumeric->content,np->nick,np->timestamp,np->ident,np->host->name->content,
+ printflags(np->umodes,umodeflags),np->authname,np->accountts,np->auth->userid,
+ iptobase64(ipbuf, &(np->p_ipaddr), sizeof(ipbuf), 1),numericbuf,np->realname->name->content);
} else if (np->accountts) {
irc_send("%s N %s 1 %ld %s %s %s %s:%ld %s %s :%s",
mynumeric->content,np->nick,np->timestamp,np->ident,np->host->name->content,
if (pk->target == target)
return;
- Error("localuser", ERR_INFO, "Adding pending kill for %s", target->nick);
+ Error("localuser", ERR_DEBUG, "Adding pending kill for %s", target->nick);
pk = (pendingkill *)malloc(sizeof(pendingkill));
pk->source = source;
pk->target = target;
}
}
+void sethostuser(nick *target, char *ident, char *host) {
+ irc_send("%s SH %s %s %s", mynumeric->content, longtonumeric(target->numeric, 5), ident, host);
+}
+
void _killuser(nick *source, nick *target, char *reason) {
char senderstr[6];
char sourcestring[HOSTLEN+NICKLEN+3];
pendingkilllist = pk->next;
if (pk->target) {
- Error("localuser", ERR_INFO, "Processing pending kill for %s", pk->target->nick);
+ Error("localuser", ERR_DEBUG, "Processing pending kill for %s", pk->target->nick);
_killuser(pk->source, pk->target, pk->reason->content);
}
}
/* Auth user */
-void localusersetaccountwithuserid(nick *np, char *accname, unsigned long accid) {
+void localusersetaccountwithuseridflagsts(nick *np, char *accname, unsigned long accid, flag_t accountflags, time_t authTS) {
if (IsAccount(np)) {
Error("localuser",ERR_WARNING,"Tried to set account on user %s already authed", np->nick);
return;
SetAccount(np);
strncpy(np->authname, accname, ACCOUNTLEN);
np->authname[ACCOUNTLEN]='\0';
- np->accountts=getnettime();
+ np->accountts=authTS?authTS:getnettime();
+ np->accountflags=accountflags;
if (accid) {
np->auth=findorcreateauthname(accid);
}
if (connected) {
- if (np->auth) {
+ if (np->accountflags) {
+ irc_send("%s AC %s %s %ld %lu %lu",mynumeric->content, longtonumeric(np->numeric,5), np->authname, np->accountts, np->auth?np->auth->userid:0, np->accountflags);
+ } else if (np->auth) {
irc_send("%s AC %s %s %ld %lu",mynumeric->content, longtonumeric(np->numeric,5), np->authname, np->accountts, np->auth->userid);
} else {
irc_send("%s AC %s %s %ld",mynumeric->content, longtonumeric(np->numeric,5), np->authname, np->accountts);