]> jfr.im git - irc/quakenet/newserv.git/blobdiff - localuser/localuser.c
Add opername support to newserv, also add displaying of oper names in noperserv warni...
[irc/quakenet/newserv.git] / localuser / localuser.c
index 43837ed197ab909dceb255fd083ed5a23598b93a..463918f4eaf1f446d2d5018cab4768709ec420ca 100644 (file)
@@ -100,7 +100,6 @@ nick *registerlocaluserwithuseridflags(char *nickname, char *ident, char *host,
   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] = 65535;
@@ -109,7 +108,7 @@ nick *registerlocaluserwithuseridflags(char *nickname, char *ident, char *host,
   ((unsigned char *)(ipaddress.in6_16))[15] = (currentlocalunum%253)+1;
 
   newuser->ipnode = refnode(iptree, &ipaddress, PATRICIA_MAXBITS);
-  newuser->ipnode->usercount++;
+  node_increment_usercount(newuser->ipnode);
 
   newuser->timestamp=getnettime();
   newuser->shident=NULL;
@@ -125,6 +124,7 @@ nick *registerlocaluserwithuseridflags(char *nickname, char *ident, char *host,
       newuser->auth->usercount++;
       newuser->nextbyauthname=newuser->auth->nicks;
       newuser->auth->nicks=newuser;
+      newuser->auth->flags=accountflags;
     } else {
       newuser->auth=NULL;
     }
@@ -259,39 +259,38 @@ UserMessageHandler hooklocaluserhandler(nick *np, UserMessageHandler newhandler)
 
 void sendnickmsg(nick *np) {
   char numericbuf[6];
-  char ipbuf[25];
+  char ipbuf[25], operbuf[ACCOUNTLEN + 5];
+  char accountbuf[100];
 
   strncpy(numericbuf,longtonumeric(np->numeric,5),5);
   numericbuf[5]='\0';
-  
+
+  if(IsOper(np) && (serverlist[myhub].flags & SMODE_OPERNAME)) {
+    snprintf(operbuf,sizeof(operbuf)," %s",np->opername?np->opername->content:"-");
+  } else {
+    operbuf[0] = '\0';
+  }
+
   if (IsAccount(np)) {
-    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?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);
+    if (np->auth) {
+      if(np->auth->flags) {
+        snprintf(accountbuf,sizeof(accountbuf)," %s:%ld:%lu:" FLAG_T_SPECIFIER,np->authname,np->accountts,np->auth->userid,np->auth->flags);
+      } else {
+        snprintf(accountbuf,sizeof(accountbuf)," %s:%ld:%lu",np->authname,np->accountts,np->auth->userid);
+      }
     } 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,
-        printflags(np->umodes,umodeflags),np->authname,np->accountts,
-        iptobase64(ipbuf, &(np->p_ipaddr), sizeof(ipbuf), 1),numericbuf,np->realname->name->content);
+      snprintf(accountbuf,sizeof(accountbuf)," %s:%ld",np->authname,np->accountts);
     } else {
-      irc_send("%s N %s 1 %ld %s %s %s %s %s %s :%s",
-        mynumeric->content,np->nick,np->timestamp,np->ident,np->host->name->content,
-        printflags(np->umodes,umodeflags),np->authname,
-        iptobase64(ipbuf, &(np->p_ipaddr), sizeof(ipbuf), 1),numericbuf,np->realname->name->content);
+      snprintf(accountbuf,sizeof(accountbuf)," %s",np->authname);
     }
   } else {
-    irc_send("%s N %s 1 %ld %s %s %s %s %s :%s",
-      mynumeric->content,np->nick,np->timestamp,np->ident,np->host->name->content,
-      printflags(np->umodes,umodeflags),iptobase64(ipbuf, &(np->p_ipaddr), sizeof(ipbuf), 1),
-      numericbuf,np->realname->name->content);
+    accountbuf[0]='\0';
   }
+
+  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),
+    sizeof(ipbuf),1),numericbuf,np->realname->name->content);
 }
 
 void sendnickburst(int hooknum, void *arg) {
@@ -563,22 +562,24 @@ void localusersetaccountwithuseridflagsts(nick *np, char *accname, unsigned long
   strncpy(np->authname, accname, ACCOUNTLEN);
   np->authname[ACCOUNTLEN]='\0';
   np->accountts=authTS?authTS:getnettime();
-  np->accountflags=accountflags;
 
   if (accid) {
     np->auth=findorcreateauthname(accid, accname);
     np->auth->usercount++;
     np->nextbyauthname=np->auth->nicks;
     np->auth->nicks=np;
+    np->auth->flags=accountflags;
   } else {
     np->auth=NULL;
   }
 
   if (connected) {
-    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);
+    if (np->auth) {
+      if (np->auth->flags) {
+        irc_send("%s AC %s %s %ld %lu %lu",mynumeric->content, longtonumeric(np->numeric,5), np->authname, np->accountts, np->auth->userid, np->auth->flags);
+      } else {
+        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);
     }