]> jfr.im git - solanum.git/blobdiff - src/s_serv.c
Add MLOCK message to netjoin burst.
[solanum.git] / src / s_serv.c
index 88fecddc97ed877e64e45285acf3a68e131bac27..ec7d38811498c92d4792f375239ff083143a43bc 100644 (file)
@@ -88,6 +88,8 @@ struct Capability captab[] = {
        { "SAVE",       CAP_SAVE },
        { "EUID",       CAP_EUID },
        { "EOPMOD",     CAP_EOPMOD },
+       { "BAN",        CAP_BAN },
+       { "MLOCK",      CAP_MLOCK },
        {0, 0}
 };
 
@@ -391,6 +393,67 @@ send_capabilities(struct Client *client_p, int cap_can_send)
        sendto_one(client_p, "CAPAB :%s", msgbuf);
 }
 
+static void
+burst_ban(struct Client *client_p)
+{
+       rb_dlink_node *ptr;
+       struct ConfItem *aconf;
+       const char *type, *oper;
+       /* +5 for !,@,{,} and null */
+       char operbuf[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5];
+       char *p;
+       size_t melen;
+
+       melen = strlen(me.name);
+       RB_DLINK_FOREACH(ptr, prop_bans.head)
+       {
+               aconf = ptr->data;
+
+               /* Skip expired stuff. */
+               if(aconf->lifetime < rb_current_time())
+                       continue;
+               switch(aconf->status & ~CONF_ILLEGAL)
+               {
+                       case CONF_KILL: type = "K"; break;
+                       case CONF_DLINE: type = "D"; break;
+                       case CONF_XLINE: type = "X"; break;
+                       case CONF_RESV_NICK: type = "R"; break;
+                       case CONF_RESV_CHANNEL: type = "R"; break;
+                       default:
+                               continue;
+               }
+               oper = aconf->info.oper;
+               if(aconf->flags & CONF_FLAGS_MYOPER)
+               {
+                       /* Our operator{} names may not be meaningful
+                        * to other servers, so rewrite to our server
+                        * name.
+                        */
+                       rb_strlcpy(operbuf, aconf->info.oper, sizeof buf);
+                       p = strrchr(operbuf, '{');
+                       if (p != NULL &&
+                                       operbuf + sizeof operbuf - p > (ptrdiff_t)(melen + 2))
+                       {
+                               memcpy(p + 1, me.name, melen);
+                               p[melen + 1] = '}';
+                               p[melen + 2] = '\0';
+                               oper = operbuf;
+                       }
+               }
+               sendto_one(client_p, ":%s BAN %s %s %s %lu %d %d %s :%s%s%s",
+                               me.id,
+                               type,
+                               aconf->user ? aconf->user : "*", aconf->host,
+                               (unsigned long)aconf->created,
+                               (int)(aconf->hold - aconf->created),
+                               (int)(aconf->lifetime - aconf->created),
+                               oper,
+                               aconf->passwd,
+                               aconf->spasswd ? "|" : "",
+                               aconf->spasswd ? aconf->spasswd : "");
+       }
+}
+
 /* burst_modes_TS6()
  *
  * input       - client to burst to, channel name, list to burst, mode flag
@@ -474,8 +537,6 @@ burst_TS6(struct Client *client_p)
 
        RB_DLINK_FOREACH(ptr, global_client_list.head)
        {
-               const char *awaymsg = NULL;
-
                target_p = ptr->data;
 
                if(!IsPerson(target_p))
@@ -508,6 +569,10 @@ burst_TS6(struct Client *client_p)
                                   IsIPSpoof(target_p) ? "0" : target_p->sockhost,
                                   target_p->id, target_p->info);
 
+               if(!EmptyString(target_p->certfp))
+                       sendto_one(client_p, ":%s ENCAP * CERTFP :%s",
+                                       use_id(target_p), target_p->certfp);
+
                if(!IsCapable(client_p, CAP_EUID))
                {
                        if(IsDynSpoof(target_p))
@@ -518,10 +583,10 @@ burst_TS6(struct Client *client_p)
                                                use_id(target_p), target_p->user->suser);
                }
 
-               if(ConfigFileEntry.burst_away && (awaymsg = get_metadata(target_p, "away")) != NULL)
+               if(ConfigFileEntry.burst_away && !EmptyString(target_p->user->away))
                        sendto_one(client_p, ":%s AWAY :%s",
                                   use_id(target_p),
-                                  awaymsg);
+                                  target_p->user->away);
 
                hclientinfo.target = target_p;
                call_hook(h_burst_client, &hclientinfo);
@@ -593,6 +658,11 @@ burst_TS6(struct Client *client_p)
                                   ConfigChannel.burst_topicwho ? " " : "",
                                   chptr->topic);
 
+               if(IsCapable(client_p, CAP_MLOCK))
+                       sendto_one(client_p, ":%s MLOCK %ld %s %s",
+                                  me.id, (long) chptr->channelts, chptr->chname,
+                                  channel_mlock(client_p, chptr));
+
                hchaninfo.chptr = chptr;
                call_hook(h_burst_channel, &hchaninfo);
        }
@@ -858,6 +928,9 @@ server_estab(struct Client *client_p)
                                        target_p->serv->fullcaps);
        }
 
+       if(IsCapable(client_p, CAP_BAN))
+               burst_ban(client_p);
+
        burst_TS6(client_p);
 
        /* Always send a PING after connect burst is done */