1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-10 16:43:12 +02:00

Rip out support for servers lacking SJ3

This commit is contained in:
Bram Matthys
2019-10-13 09:33:39 +02:00
parent 545c2560e6
commit a9890448d8
6 changed files with 31 additions and 472 deletions
-4
View File
@@ -334,7 +334,6 @@ typedef enum ClientStatus {
#define PROTO_UMODE2 0x000010 /* Negotiated UMODE2 protocol */
#define PROTO_TKLEXT2 0x000020 /* TKL extension 2: 11 parameters instead of 8 or 10 */
#define PROTO_VL 0x000040 /* Negotiated VL protocol */
#define PROTO_SJ3 0x000080 /* Negotiated SJ3 protocol */
#define PROTO_VHP 0x000100 /* Send hostnames in NICKv2 even if not sethosted */
#define PROTO_TKLEXT 0x000400 /* TKL extension: 10 parameters instead of 8 (3.2RC2) */
#define PROTO_CLK 0x001000 /* Send cloaked host in the NICK command (regardless of +x/-x) */
@@ -505,7 +504,6 @@ typedef enum ClientStatus {
#define SupportUMODE2(x) (CHECKPROTO(x, PROTO_UMODE2))
#define SupportVL(x) (CHECKPROTO(x, PROTO_VL))
#define SupportSJ3(x) (CHECKPROTO(x, PROTO_SJ3))
#define SupportSJSBY(x) (CHECKPROTO(x, PROTO_SJSBY))
#define SupportVHP(x) (CHECKPROTO(x, PROTO_VHP))
#define SupportTKLEXT(x) (CHECKPROTO(x, PROTO_TKLEXT))
@@ -515,7 +513,6 @@ typedef enum ClientStatus {
#define SetUMODE2(x) ((x)->local->proto |= PROTO_UMODE2)
#define SetVL(x) ((x)->local->proto |= PROTO_VL)
#define SetSJ3(x) ((x)->local->proto |= PROTO_SJ3)
#define SetSJSBY(x) ((x)->local->proto |= PROTO_SJSBY)
#define SetVHP(x) ((x)->local->proto |= PROTO_VHP)
#define SetTKLEXT(x) ((x)->local->proto |= PROTO_TKLEXT)
@@ -526,7 +523,6 @@ typedef enum ClientStatus {
#define ClearUMODE2(x) ((x)->local->proto &= ~PROTO_UMODE2)
#define ClearVL(x) ((x)->local->proto &= ~PROTO_VL)
#define ClearVHP(x) ((x)->local->proto &= ~PROTO_VHP)
#define ClearSJ3(x) ((x)->local->proto &= ~PROTO_SJ3)
#define ClearTKLEXT(x) ((x)->local->proto &= ~PROTO_TKLEXT)
#define ClearTKLEXT2(x) ((x)->local->proto &= ~PROTO_TKLEXT2)
-28
View File
@@ -246,9 +246,6 @@ void _join_channel(Channel *channel, Client *client, MessageTag *recv_mtags, int
send_join_to_local_users(client, channel, mtags);
/* old non-SJOINv3 servers */
sendto_server(client, 0, PROTO_SJ3, mtags, ":%s JOIN :%s", client->name, channel->chname);
sendto_server(client, 0, 0, mtags_sjoin, ":%s SJOIN %lld %s :%s%s ",
me.id, (long long)channel->creationtime,
channel->chname, chfl_to_sjoin_symbol(flags), ID(client));
@@ -267,31 +264,6 @@ void _join_channel(Channel *channel, Client *client, MessageTag *recv_mtags, int
me.name, channel->chname, (long long)channel->creationtime);
}
del_invite(client, channel);
if (flags && !(flags & CHFL_DEOPPED))
{
/* We could generate mtags here but this is only for
* old non-SJ3 servers, so we don't bother since they
* won't support mtags anyway.
*/
#ifndef PREFIX_AQ
if ((flags & CHFL_CHANOWNER) || (flags & CHFL_CHANADMIN))
{
/* +ao / +qo for when PREFIX_AQ is off */
sendto_server(client, 0, PROTO_SJ3, NULL, ":%s MODE %s +o%c %s %s %lld",
me.name,
channel->chname, chfl_to_chanmode(flags), client->name, client->name,
(long long)channel->creationtime);
} else {
#endif
/* +v/+h/+o (and +a/+q if PREFIX_AQ is on) */
sendto_server(client, 0, PROTO_SJ3, NULL, ":%s MODE %s +%c %s %lld",
me.name,
channel->chname, chfl_to_chanmode(flags), client->name,
(long long)channel->creationtime);
#ifndef PREFIX_AQ
}
#endif
}
if (channel->topic)
{
+21 -28
View File
@@ -191,39 +191,32 @@ void nick_collision(Client *cptr, char *newnick, char *newid, Client *new, Clien
* So we re-introduce the user here.
* This is not ideal but if we don't do this then 'cptr'-side would be desynced.
*/
Membership *lp;
char flags[16], *p;
introduce_user(cptr, existing);
if (!SupportSJ3(cptr))
{
/* Wow. Old. */
send_user_joins(cptr, existing);
/* Didn't bother to do the +vhoaq stuff for this. Shouldn't we rip out SJOIN/SJOIN2 anyway? */
} else
{
/* Hmmm duplicate code... hmmmmmm. taken from send_channel_modes_sjoin3. */
Membership *lp;
char flags[16], *p;
for (lp = existing->user->channel; lp; lp = lp->next)
{
p = flags;
if (lp->flags & MODE_CHANOP)
*p++ = '@';
if (lp->flags & MODE_VOICE)
*p++ = '+';
if (lp->flags & MODE_HALFOP)
*p++ = '%';
if (lp->flags & MODE_CHANOWNER)
*p++ = '*';
if (lp->flags & MODE_CHANADMIN)
*p++ = '~';
*p = '\0';
for (lp = existing->user->channel; lp; lp = lp->next)
{
p = flags;
if (lp->flags & MODE_CHANOP)
*p++ = '@';
if (lp->flags & MODE_VOICE)
*p++ = '+';
if (lp->flags & MODE_HALFOP)
*p++ = '%';
if (lp->flags & MODE_CHANOWNER)
*p++ = '*';
if (lp->flags & MODE_CHANADMIN)
*p++ = '~';
*p = '\0';
sendto_one(cptr, NULL, ":%s SJOIN %ld %s + :%s%s",
me.name, lp->channel->creationtime, lp->channel->chname,
flags, existing->name);
}
sendto_one(cptr, NULL, ":%s SJOIN %ld %s + :%s%s",
me.name, lp->channel->creationtime, lp->channel->chname,
flags, existing->name);
}
/* Could synch channel-member-data here. But this is apparently an old server anyway.. */
// TODO, wait, perhaps the whole reintroduce_existing_user can be removed? or not?
}
#endif
}
-4
View File
@@ -110,10 +110,6 @@ CMD_FUNC(cmd_protoctl)
{
SetCLK(client);
}
else if (!strcmp(name, "SJ3"))
{
SetSJ3(client);
}
else if (!strcmp(name, "SJSBY") && iConf.ban_setter_sync)
{
SetSJSBY(client);
-390
View File
@@ -23,8 +23,6 @@
#include "unrealircd.h"
/* Forward declarations */
void send_channel_modes(Client *to, Channel *channel);
void send_channel_modes_sjoin(Client *to, Channel *channel);
void send_channel_modes_sjoin3(Client *to, Channel *channel);
CMD_FUNC(cmd_server);
CMD_FUNC(cmd_server_remote);
@@ -1084,394 +1082,6 @@ int server_sync(Client *cptr, ConfigItem_link *aconf)
return 0;
}
/** Send MODE +vhoaq list (depending on 'mask' and 'flag') to remote server.
* Previously this function was called send_mode_list() when it was dual-function.
* (only for old severs lacking SJOIN/SJ3
*/
static void send_channel_modes_members(Client *to, Channel *channel, int mask, char flag)
{
Member *lp;
char *cp, *name;
int count = 0, send = 0;
cp = modebuf + strlen(modebuf);
if (*parabuf) /* mode +l or +k xx */
count = 1;
for (lp = channel->members; lp; lp = lp->next)
{
if (!(lp->flags & mask))
continue;
name = lp->client->name;
if (strlen(parabuf) + strlen(name) + 11 < (size_t)MODEBUFLEN)
{
if (*parabuf)
strlcat(parabuf, " ", sizeof parabuf);
strlcat(parabuf, name, sizeof parabuf);
count++;
*cp++ = flag;
*cp = '\0';
}
else if (*parabuf)
send = 1;
if (count == RESYNCMODES)
send = 1;
if (send)
{
/* to is always a server! So we send creationtime */
sendmodeto_one(to, me.name, channel->chname, modebuf, parabuf, channel->creationtime);
send = 0;
*parabuf = '\0';
cp = modebuf;
*cp++ = '+';
if (count != RESYNCMODES)
{
strlcpy(parabuf, name, sizeof parabuf);
*cp++ = flag;
}
count = 0;
*cp = '\0';
}
}
}
/** Send list modes such as +beI to remote server.
* Previously this was combined with +vhoaq stuff in the send_mode_list() function.
* (only for old severs lacking SJOIN/SJ3
*/
static void send_channel_modes_list_mode(Client *to, Channel *channel, Ban *lp, char flag)
{
char *cp, *name;
int count = 0, send = 0;
cp = modebuf + strlen(modebuf);
if (*parabuf) /* mode +l or +k xx */
count = 1;
for (; lp; lp = lp->next)
{
name = lp->banstr;
if (strlen(parabuf) + strlen(name) + 11 < (size_t)MODEBUFLEN)
{
if (*parabuf)
strlcat(parabuf, " ", sizeof parabuf);
strlcat(parabuf, name, sizeof parabuf);
count++;
*cp++ = flag;
*cp = '\0';
}
else if (*parabuf)
send = 1;
if (count == RESYNCMODES)
send = 1;
if (send)
{
/* to is always a server! So we send creationtime */
sendmodeto_one(to, me.name, channel->chname, modebuf, parabuf, channel->creationtime);
send = 0;
*parabuf = '\0';
cp = modebuf;
*cp++ = '+';
if (count != RESYNCMODES)
{
strlcpy(parabuf, name, sizeof parabuf);
*cp++ = flag;
}
count = 0;
*cp = '\0';
}
}
}
/* (only for old severs lacking SJOIN/SJ3 */
static inline void send_channel_mode(Client *to, char *from, Channel *channel)
{
if (*parabuf)
sendto_one(to, NULL, ":%s MODE %s %s %s %lld", from,
channel->chname,
modebuf, parabuf, (long long)channel->creationtime);
else
sendto_one(to, NULL, ":%s MODE %s %s %lld", from,
channel->chname,
modebuf, (long long)channel->creationtime);
}
/** Send "to" a full list of the MODEs for channel channel.
* Note that this function is only used for servers lacking SJOIN/SJOIN3.
*/
void send_channel_modes(Client *to, Channel *channel)
{
if (*channel->chname != '#')
return;
/* Send the "property" channel modes like +lks */
*modebuf = *parabuf = '\0';
channel_modes(to, modebuf, parabuf, sizeof(modebuf), sizeof(parabuf), channel);
send_channel_mode(to, me.name, channel);
/* Then send the +qaohv in one go */
modebuf[0] = '+';
modebuf[1] = '\0';
parabuf[0] = '\0';
send_channel_modes_members(to, channel, CHFL_CHANOWNER, 'q');
send_channel_modes_members(to, channel, CHFL_CHANADMIN, 'a');
send_channel_modes_members(to, channel, CHFL_CHANOP, 'o');
send_channel_modes_members(to, channel, CHFL_HALFOP, 'h');
send_channel_modes_members(to, channel, CHFL_VOICE, 'v');
/* ..including any remainder in the buffer.. */
if (modebuf[1] || *parabuf)
sendmodeto_one(to, me.name, channel->chname, modebuf, parabuf, channel->creationtime);
/* Then send the +beI in one go */
modebuf[0] = '+';
modebuf[1] = '\0';
parabuf[0] = '\0';
send_channel_modes_list_mode(to, channel, channel->banlist, 'b');
send_channel_modes_list_mode(to, channel, channel->exlist, 'e');
send_channel_modes_list_mode(to, channel, channel->invexlist, 'I');
/* ..including any remainder in the buffer.. */
if (modebuf[1] || *parabuf)
sendmodeto_one(to, me.name, channel->chname, modebuf, parabuf, channel->creationtime);
/* send MLOCK here too... --nenolod */
if (CHECKPROTO(to, PROTO_MLOCK))
{
sendto_one(to, NULL, "MLOCK %lld %s :%s",
(long long)channel->creationtime, channel->chname,
BadPtr(channel->mode_lock) ? "" : channel->mode_lock);
}
}
/* (only for old severs lacking SJ3) */
static int send_ban_list(Client *to, char *chname, time_t creationtime, Channel *channel)
{
Ban *top;
Ban *lp;
char *cp, *name;
int count = 0, send = 0, sent = 0;
cp = modebuf + strlen(modebuf);
if (*parabuf) /* mode +l or +k xx */
count = 1;
top = channel->banlist;
for (lp = top; lp; lp = lp->next)
{
name = lp->banstr;
if (strlen(parabuf) + strlen(name) + 11 < (size_t)MODEBUFLEN)
{
if (*parabuf)
(void)strcat(parabuf, " ");
(void)strcat(parabuf, name);
count++;
*cp++ = 'b';
*cp = '\0';
}
else if (*parabuf)
send = 1;
if (count == MODEPARAMS)
send = 1;
if (send)
{
/* to is always a server! So we send creationtimes */
sendto_one(to, NULL, "MODE %s %s %s %lld",
chname, modebuf, parabuf, (long long)creationtime);
sent = 1;
send = 0;
*parabuf = '\0';
cp = modebuf;
*cp++ = '+';
if (count != MODEPARAMS)
{
(void)strlcpy(parabuf, name, sizeof parabuf);
*cp++ = 'b';
}
count = 0;
*cp = '\0';
}
}
top = channel->exlist;
for (lp = top; lp; lp = lp->next)
{
name = lp->banstr;
if (strlen(parabuf) + strlen(name) + 11 < (size_t)MODEBUFLEN)
{
if (*parabuf)
(void)strcat(parabuf, " ");
(void)strcat(parabuf, name);
count++;
*cp++ = 'e';
*cp = '\0';
}
else if (*parabuf)
send = 1;
if (count == MODEPARAMS)
send = 1;
if (send)
{
/* to is always a server! So we send creationtimes */
sendto_one(to, NULL, "MODE %s %s %s %lld",
chname, modebuf, parabuf, (long long)creationtime);
sent = 1;
send = 0;
*parabuf = '\0';
cp = modebuf;
*cp++ = '+';
if (count != MODEPARAMS)
{
(void)strlcpy(parabuf, name, sizeof parabuf);
*cp++ = 'e';
}
count = 0;
*cp = '\0';
}
}
top = channel->invexlist;
for (lp = top; lp; lp = lp->next)
{
name = lp->banstr;
if (strlen(parabuf) + strlen(name) + 11 < (size_t)MODEBUFLEN)
{
if (*parabuf)
(void)strcat(parabuf, " ");
(void)strcat(parabuf, name);
count++;
*cp++ = 'I';
*cp = '\0';
}
else if (*parabuf)
send = 1;
if (count == MODEPARAMS)
send = 1;
if (send)
{
/* to is always a server! So we send creationtimes */
sendto_one(to, NULL, "MODE %s %s %s %lld",
chname, modebuf, parabuf, (long long)creationtime);
sent = 1;
send = 0;
*parabuf = '\0';
cp = modebuf;
*cp++ = '+';
if (count != MODEPARAMS)
{
(void)strlcpy(parabuf, name, sizeof parabuf);
*cp++ = 'I';
}
count = 0;
*cp = '\0';
}
}
return sent;
}
/*
* This will send "to" a full list of the modes for channel channel,
* NOTE: this is only for old servers who do not support SJ3.
*/
void send_channel_modes_sjoin(Client *to, Channel *channel)
{
Member *members;
Member *lp;
char *name;
char *bufptr;
int n = 0;
if (*channel->chname != '#')
return;
members = channel->members;
/* First we'll send channel, channel modes and members and status */
*modebuf = *parabuf = '\0';
channel_modes(to, modebuf, parabuf, sizeof(modebuf), sizeof(parabuf), channel);
if (*parabuf)
{
}
else
{
strlcpy(parabuf, "<->", sizeof parabuf);
}
ircsnprintf(buf, sizeof(buf), "SJOIN %lld %s %s %s :",
(long long)channel->creationtime, channel->chname, modebuf, parabuf);
bufptr = buf + strlen(buf);
for (lp = members; lp; lp = lp->next)
{
if (lp->flags & MODE_CHANOP)
*bufptr++ = '@';
if (lp->flags & MODE_VOICE)
*bufptr++ = '+';
if (lp->flags & MODE_HALFOP)
*bufptr++ = '%';
if (lp->flags & MODE_CHANOWNER)
*bufptr++ = '*';
if (lp->flags & MODE_CHANADMIN)
*bufptr++ = '~';
name = ID(lp->client);
strcpy(bufptr, name);
bufptr += strlen(bufptr);
*bufptr++ = ' ';
n++;
if (bufptr - buf > BUFSIZE - 80)
{
*bufptr++ = '\0';
if (bufptr[-1] == ' ')
bufptr[-1] = '\0';
sendto_one(to, NULL, "%s", buf);
ircsnprintf(buf, sizeof(buf), "SJOIN %lld %s %s %s :",
(long long)channel->creationtime, channel->chname, modebuf,
parabuf);
n = 0;
bufptr = buf + strlen(buf);
}
}
if (n)
{
*bufptr++ = '\0';
if (bufptr[-1] == ' ')
bufptr[-1] = '\0';
sendto_one(to, NULL, "%s", buf);
}
/* Then we'll send the ban-list */
*parabuf = '\0';
*modebuf = '+';
modebuf[1] = '\0';
send_ban_list(to, channel->chname, channel->creationtime, channel);
if (modebuf[1] || *parabuf)
sendto_one(to, NULL, "MODE %s %s %s %lld",
channel->chname, modebuf, parabuf,
(long long)channel->creationtime);
return;
}
/** This will send "to" a full list of the modes for channel channel,
*
* Half of it recoded by Syzop: the whole buffering and size checking stuff
+10 -18
View File
@@ -162,19 +162,11 @@ CMD_FUNC(cmd_sjoin)
merge = nopara = nomode = removeours = removetheirs = 0;
if (SupportSJ3(client->direction) && (parc < 6))
if (parc < 6)
nopara = 1;
if (SupportSJ3(client->direction))
{
if (parc < 5)
nomode = 1;
}
else
{
if (parv[3][0] && (parv[3][1] == '\0'))
nomode = 1;
}
if (parc < 5)
nomode = 1;
channel = get_channel(client, parv[2], CREATE);
@@ -534,7 +526,7 @@ getnick:
if (strlen(uid_buf) + strlen(prefix) + IDLEN > BUFSIZE - 10)
{
/* Send what we have and start a new buffer */
sendto_server(client, PROTO_SJ3, PROTO_SJSBY, recv_mtags, "%s", uid_buf);
sendto_server(client, 0, PROTO_SJSBY, recv_mtags, "%s", uid_buf);
snprintf(uid_buf, sizeof(uid_buf), ":%s SJOIN %lld %s :", ID(client), (long long)ts, sj3_parabuf);
/* Double-check the new buffer is sufficient to concat the data */
if (strlen(uid_buf) + strlen(prefix) + strlen(ID(acptr)) > BUFSIZE - 5)
@@ -550,7 +542,7 @@ getnick:
if (strlen(uid_sjsby_buf) + strlen(prefix) + IDLEN > BUFSIZE - 10)
{
/* Send what we have and start a new buffer */
sendto_server(client, PROTO_SJ3, PROTO_SJSBY, recv_mtags, "%s", uid_sjsby_buf);
sendto_server(client, 0, PROTO_SJSBY, recv_mtags, "%s", uid_sjsby_buf);
snprintf(uid_sjsby_buf, sizeof(uid_sjsby_buf), ":%s SJOIN %lld %s :", ID(client), (long long)ts, sj3_parabuf);
/* Double-check the new buffer is sufficient to concat the data */
if (strlen(uid_sjsby_buf) + strlen(prefix) + strlen(ID(acptr)) > BUFSIZE - 5)
@@ -609,7 +601,7 @@ getnick:
if (strlen(uid_buf) + strlen(prefix) + strlen(nick) > BUFSIZE - 10)
{
/* Send what we have and start a new buffer */
sendto_server(client, PROTO_SJ3, PROTO_SJSBY, recv_mtags, "%s", uid_buf);
sendto_server(client, 0, PROTO_SJSBY, recv_mtags, "%s", uid_buf);
snprintf(uid_buf, sizeof(uid_buf), ":%s SJOIN %lld %s :", ID(client), (long long)ts, sj3_parabuf);
/* Double-check the new buffer is sufficient to concat the data */
if (strlen(uid_buf) + strlen(prefix) + strlen(nick) > BUFSIZE - 5)
@@ -631,7 +623,7 @@ getnick:
if (strlen(uid_sjsby_buf) + strlen(scratch_buf) > BUFSIZE - 10)
{
/* Send what we have and start a new buffer */
sendto_server(client, PROTO_SJ3 | PROTO_SJSBY, 0, recv_mtags, "%s", uid_sjsby_buf);
sendto_server(client, PROTO_SJSBY, 0, recv_mtags, "%s", uid_sjsby_buf);
snprintf(uid_sjsby_buf, sizeof(uid_sjsby_buf), ":%s SJOIN %lld %s :", ID(client), (long long)ts, sj3_parabuf);
/* Double-check the new buffer is sufficient to concat the data */
if (strlen(uid_sjsby_buf) + strlen(scratch_buf) > BUFSIZE - 5)
@@ -647,9 +639,9 @@ getnick:
}
/* Send out any possible remainder.. */
Debug((DEBUG_DEBUG, "Sending '%li %s :%s' to sj3", ts, parabuf, parv[parc - 1]));
sendto_server(client, PROTO_SJ3, PROTO_SJSBY, recv_mtags, "%s", uid_buf);
sendto_server(client, PROTO_SJ3 | PROTO_SJSBY, 0, recv_mtags, "%s", uid_sjsby_buf);
Debug((DEBUG_DEBUG, "Sending '%li %s :%s' to ", ts, parabuf, parv[parc - 1]));
sendto_server(client, 0, PROTO_SJSBY, recv_mtags, "%s", uid_buf);
sendto_server(client, PROTO_SJSBY, 0, recv_mtags, "%s", uid_sjsby_buf);
if (modebuf[1])
{