X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/3cb05e5640b4a5dd4e8d078aff0fc1dbae87544c..440cd7e63ac2b059ea1a467a2e4e2244faf92cb3:/localuser/localuser.c?ds=sidebyside diff --git a/localuser/localuser.c b/localuser/localuser.c index 9f037db1..5d36358d 100644 --- a/localuser/localuser.c +++ b/localuser/localuser.c @@ -68,14 +68,14 @@ void _fini() { } /* - * registerlocaluserflags: + * registerlocaluserflagsip: * This function creates a local user, and broadcasts it's existence to the net (if connected). */ -nick *registerlocaluserflags(char *nickname, char *ident, char *host, char *realname, char *authname, unsigned long authid, flag_t accountflags, flag_t umodes, UserMessageHandler handler) { +nick *registerlocaluserflagsip(char *nickname, char *ident, char *host, char *realname, char *authname, unsigned long authid, flag_t accountflags, flag_t umodes, struct irc_in_addr *ipaddress, UserMessageHandler handler) { int i; nick *newuser,*np; - struct irc_in_addr ipaddress; + struct irc_in_addr tmpipaddress; i=0; currentlocalunum=(currentlocalunum+1)%262142; @@ -102,15 +102,19 @@ nick *registerlocaluserflags(char *nickname, char *ident, char *host, char *real newuser->realname->nicks=newuser; newuser->umodes=umodes; - memset(&ipaddress, 0, sizeof(ipaddress)); - ((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; + if (!ipaddress) { + ipaddress = &tmpipaddress; - memcpy(&newuser->ipaddress, &ipaddress, sizeof(ipaddress)); + memset(ipaddress, 0, sizeof(struct irc_in_addr)); + ((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; + } + + memcpy(&newuser->ipaddress, ipaddress, sizeof(struct irc_in_addr)); - newuser->ipnode = refnode(iptree, &ipaddress, PATRICIA_MAXBITS); + newuser->ipnode = refnode(iptree, ipaddress, PATRICIA_MAXBITS); node_increment_usercount(newuser->ipnode); newuser->timestamp=getnettime(); @@ -150,6 +154,10 @@ nick *registerlocaluserflags(char *nickname, char *ident, char *host, char *real } } + newuser->cloak_count = 0; + newuser->cloak_extra = NULL; + newuser->message = NULL; + if (connected) { /* Check for nick collision */ if ((np=getnickbynick(nickname))!=NULL) { @@ -202,7 +210,7 @@ int renamelocaluser(nick *np, char *newnick) { /* Case only name change */ strncpy(np->nick,newnick,NICKLEN); np->nick[NICKLEN]='\0'; - irc_send("%s N %s %jd",iptobase64(ipbuf, &(np->p_ipaddr), sizeof(ipbuf), 1),np->nick,(intmax_t)np->timestamp); + irc_send("%s N %s %jd",iptobase64(ipbuf, &(np->ipaddress), sizeof(ipbuf), 1),np->nick,(intmax_t)np->timestamp); triggerhook(HOOK_NICK_RENAME,harg); return 0; } else { @@ -309,7 +317,7 @@ void sendnickmsg(nick *np) { irc_send("%s N %s 1 %ld %s %s %s%s%s %s %s :%s", mynumeric->content,np->nick,np->timestamp,np->ident,np->host->name->content, - printflags(np->umodes,umodeflags),operbuf,accountbuf,iptobase64(ipbuf,&(np->p_ipaddr), + printflags(np->umodes,umodeflags),operbuf,accountbuf,iptobase64(ipbuf,&(np->ipaddress), sizeof(ipbuf),1),numericbuf,np->realname->name->content); } @@ -361,7 +369,7 @@ int handlemessageornotice(void *source, int cargc, char **cargv, int isnotice) { char *ch; char targetnick[NICKLEN+1]; int foundat; - void *nargs[2]; + void *nargs[3]; int i; /* Should have target and message */ @@ -369,15 +377,23 @@ int handlemessageornotice(void *source, int cargc, char **cargv, int isnotice) { return CMD_OK; } - if (cargv[0][0]=='#' || cargv[0][0]=='+') { - /* Channel message/notice */ - return CMD_OK; - } - if ((sender=getnickbynumericstr((char *)source))==NULL) { Error("localuser",ERR_WARNING,"PRIVMSG from non existant user %s",(char *)source); return CMD_OK; } + + freesstring(sender->message); + sender->message = getsstring(cargv[1], 512); + + nargs[0] = sender; + nargs[1] = cargv[1]; + nargs[2] = (void *)(uintptr_t)isnotice; + triggerhook(HOOK_NICK_MESSAGE, nargs); + + if (cargv[0][0]=='#' || cargv[0][0]=='+') { + /* Channel message/notice */ + return CMD_OK; + } /* Check for a "secure" message (foo@bar) */ foundat=0; @@ -645,3 +661,20 @@ void localusersetaccountflags(authname *anp, u_int64_t accountflags) { triggerhook(HOOK_AUTH_FLAGSUPDATED, arg); } + +void localuseraddcloaktarget(nick *np, nick *target) { + char snumeric[10], tnumeric[10]; + + strcpy(snumeric, longtonumeric(np->numeric,5)); + strcpy(tnumeric, longtonumeric(target->numeric,5)); + + irc_send("%s CA %s", snumeric, tnumeric); + + addcloaktarget(np, target); +} + +void localuserclearcloaktargets(nick *np) { + irc_send("%s CU", longtonumeric(np->numeric,5)); + clearcloaktargets(np); +} +