nick **nh;
char *fakehost;
char *accountts;
+ char *accountflags;
+ struct irc_in_addr ipaddress;
+ char *accountid;
+ unsigned long userid;
if (cargc==2) { /* rename */
/* Nyklon 1017697578 */
Error("nick",ERR_WARNING,"Received NICK with invalid numeric %s from %s.",cargv[cargc-2],sender);
return CMD_ERROR;
}
-
+
+ base64toip(cargv[cargc-3], &ipaddress);
+ if (!irc_in_addr_valid(&ipaddress)) {
+ Error("nick",ERR_ERROR,"Received NICK with invalid ipaddress for %s from %s.",cargv[0],sender);
+ return CMD_ERROR;
+ }
+
/* At this stage the nick is cleared to proceed */
np=newnick();
strncpy(np->nick,cargv[0],NICKLEN);
np->nextbyrealname=np->realname->nicks;
np->realname->nicks=np;
np->timestamp=timestamp;
- np->ipaddress=numerictolong(cargv[cargc-3],6);
+
+ base64toip(cargv[cargc-3], &ipaddress);
+ /* todo: use a single node for /64 prefixes */
+ np->ipnode = refnode(iptree, &ipaddress, irc_in_addr_is_ipv4(&ipaddress) ? PATRICIA_MAXBITS : 64);
+ np->ipnode->usercount++;
+
np->shident=NULL;
np->sethost=NULL;
np->umodes=0;
np->marker=0;
memset(np->exts, 0, MAXNICKEXTS * sizeof(void *));
np->authname[0]='\0';
+ np->auth=NULL;
+ np->accountflags=0;
if(cargc>=9) {
setflags(&(np->umodes),UMODE_ALL,cargv[5],umodeflags,REJECT_NONE);
if (IsAccount(np)) {
if ((accountts=strchr(cargv[6],':'))) {
*accountts++='\0';
- np->accountts=strtoul(accountts,NULL,10);
+ np->accountts=strtoul(accountts,&accountid,10);
+ if(accountid) {
+ userid=strtoul(accountid + 1,&accountflags,10);
+ if(!userid) {
+ np->auth=NULL;
+ } else {
+ np->auth=findorcreateauthname(userid);
+ np->auth->usercount++;
+ np->nextbyauthname=np->auth->nicks;
+ np->auth->nicks=np;
+ }
+ if(accountflags)
+ np->accountflags=strtoul(accountflags + 1,NULL,10);
+ } else {
+ np->auth=NULL;
+ }
} else {
np->accountts=0;
+ np->auth=NULL;
}
strncpy(np->authname,cargv[6],ACCOUNTLEN);
np->authname[ACCOUNTLEN]='\0';
nick *np;
void *harg[2];
- if (cargc>1) {
- harg[1]=(void *)cargv[1];
+ if (cargc>0) {
+ harg[1]=(void *)cargv[0];
} else {
harg[1]="";
}
int handlekillmsg(void *source, int cargc, char **cargv) {
nick *np;
-
+ void *harg[2];
+#warning Fix me to use source
+
if (cargc<1) {
Error("nick",ERR_WARNING,"Kill message with too few parameters");
return CMD_ERROR;
}
+
+ if (cargc>1) {
+ harg[1]=(void *)cargv[1];
+ } else {
+ harg[1]="";
+ }
+
np=getnickbynumericstr(cargv[0]);
if (np) {
+ harg[0]=(void *)np;
+ triggerhook(HOOK_NICK_KILL, harg);
deletenick(np);
} else {
Error("nick",ERR_WARNING,"Kill for non-existant numeric %s",cargv[0]);
}
if (homeserver(target->numeric)==mylongnum && !IsService(target) && !IsHideIdle(target)) {
irc_send(":%s 317 %s %s %ld %ld :seconds idle, signon time",myserver->content,sender->nick,target->nick,
- (getnettime() - target->timestamp) % ((target->numeric + target->timestamp) % 983),target->timestamp);
+ (getnettime() - target->timestamp) % (((target->numeric + target->timestamp) % 983) + 7),target->timestamp);
}
}
int handleaccountmsg(void *source, int cargc, char **cargv) {
nick *target;
+ unsigned long userid;
if (cargc<2) {
return CMD_OK;
SetAccount(target);
strncpy(target->authname,cargv[1],ACCOUNTLEN);
target->authname[ACCOUNTLEN]='\0';
-
- triggerhook(HOOK_NICK_ACCOUNT, (void *)target);
+ if (cargc>=3) {
+ target->accountts=strtoul(cargv[2],NULL,10);
+ if (cargc>=4) {
+ userid=strtoul(cargv[3],NULL,10);
+ if(!userid) {
+ target->auth=NULL;
+ } else {
+ target->auth=findorcreateauthname(userid);
+ target->auth->usercount++;
+ target->nextbyauthname = target->auth->nicks;
+ target->auth->nicks = target;
+ }
+ if (cargc>=5)
+ target->accountflags=strtoul(cargv[4],NULL,10);
+ } else {
+ target->auth=NULL;
+ }
+ } else {
+ target->accountts=0;
+ target->auth=NULL;
+ }
+
+ triggerhook(HOOK_NICK_ACCOUNT, (void *)target);
+
return CMD_OK;
}