1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-02 22:03:14 +02:00

- Services coders: Added support for ESVID. Instead of a number you can

now store a string (of max NICKLEN size) as service stamp. See
  protoctl.txt and serverprotocol.html in doc/technical for more
  information.
  Patch from nenotopia (#3966).
This commit is contained in:
Bram Matthys
2011-12-25 14:26:53 +01:00
parent e8244902f8
commit d272d2d6a0
11 changed files with 61 additions and 43 deletions
+4
View File
@@ -2326,3 +2326,7 @@
and patch by fbi (#4035).
- Tweak: send actual channel name and not user supplied channel in KICK,
reported and patch by Stealth (#3298).
- Services coders: Added support for ESVID. Instead of a number you can
now store a string (of max NICKLEN size) as service stamp. See
protoctl.txt and serverprotocol.html in doc/technical for more information.
Patch from nenotopia (#3966).
+4
View File
@@ -154,3 +154,7 @@ EAUTH Early Authorization. This makes it possible for servers to authent
SERVERS Informs the other server about the other servers (numerics) on this network
(including our own numeric).
Syntax: SERVERS=numeric1,numeric2,numeric3,etc
ESVID This token indicates that the traditional services stamp value may take any
arbitrary value for the SVID field, such as an account name or other unique
identifier, including a traditional timestamp value.
+7 -6
View File
@@ -106,6 +106,7 @@
<li>NICKCHARS : Indicates the set of enabled nickchar options (see the regular documention for info about this).</li>
<li>CHANMODES : (Not required to be sent) This is the same as the CHANMODES value in the 005 for client connections. Useful for autodetecting things like what modes are valid for ChanServ MLOCK, for example.</li>
<li>CLK : Supports an extra field in NICK for sending the cloaked host (not vhost).</li>
<li>ESVID : Supports arbitrary values instead of just numeric timestamps for the services identifier field.</li>
</ul>
<p>The syntax examples here follow the conventions for TOKEN and also NS in cases of server-only messages.</p>
<h2><a name="S2_3"></a>2.3 SERVER - Server Negotiation</h2>
@@ -168,11 +169,11 @@
<h2><a name="S3_1"></a>3.1 NICK - User Introduction and Nick Change (TOKEN: &amp;)</h2>
<p><b>Syntax (nick change):</b> <tt>:<i>oldnick</i> &amp; <i>newnick</i> :<i>timestamp</i></tt></p>
<p>This format of the NICK message indicates an existing user is changing his or her nickname. If a collision occurs, see the section on Nick Collisions below. The timestamp is the new nickname's timestamp.</p>
<p><b>Syntax (normal):</b> <tt>&amp; <i>nick</i> <i>hopcount</i> <i>timestamp</i> <i>username</i> <i>hostname</i> <i>server</i> <i>servicestamp</i> :<i>realname</i></tt></p>
<p><b>Syntax (NICKv2):</b> <tt>&amp; <i>nick</i> <i>hopcount</i> <i>timestamp</i> <i>username</i> <i>hostname</i> <i>server</i> <i>servicestamp</i> <i>+usermodes</i> <i>virtualhost</i> :<i>realname</i></tt></p>
<p><b>Syntax (NICKv2+CLK):</b> <tt>&amp; <i>nick</i> <i>hopcount</i> <i>timestamp</i> <i>username</i> <i>hostname</i> <i>server</i> <i>servicestamp</i> <i>+usermodes</i> <i>virtualhost</i> <i>cloakhost</i> :<i>realname</i></tt>
<p><b>Syntax (NICKv2+NICKIP):</b> <tt>&amp; <i>nick</i> <i>hopcount</i> <i>timestamp</i> <i>username</i> <i>hostname</i> <i>server</i> <i>servicestamp</i> <i>+usermodes</i> <i>virtualhost</i> <i>nickipaddr</i> :<i>realname</i></tt></p>
<p><b>Syntax (NICKv2+NICKIP+CLK):</b> <tt>&amp; <i>nick</i> <i>hopcount</i> <i>timestamp</i> <i>username</i> <i>hostname</i> <i>server</i> <i>servicestamp</i> <i>+usermodes</i> <i>virtualhost</i> <i>cloakhost</i> <i>nickipaddr</i> :<i>realname</i></tt>
<p><b>Syntax (normal):</b> <tt>&amp; <i>nick</i> <i>hopcount</i> <i>timestamp</i> <i>username</i> <i>hostname</i> <i>server</i> <i>service-identifier-token</i> :<i>realname</i></tt></p>
<p><b>Syntax (NICKv2):</b> <tt>&amp; <i>nick</i> <i>hopcount</i> <i>timestamp</i> <i>username</i> <i>hostname</i> <i>server</i> <i>service-identifier-token</i> <i>+usermodes</i> <i>virtualhost</i> :<i>realname</i></tt></p>
<p><b>Syntax (NICKv2+CLK):</b> <tt>&amp; <i>nick</i> <i>hopcount</i> <i>timestamp</i> <i>username</i> <i>hostname</i> <i>server</i> <i>service-identifier-token</i> <i>+usermodes</i> <i>virtualhost</i> <i>cloakhost</i> :<i>realname</i></tt>
<p><b>Syntax (NICKv2+NICKIP):</b> <tt>&amp; <i>nick</i> <i>hopcount</i> <i>timestamp</i> <i>username</i> <i>hostname</i> <i>server</i> <i>service-identifier-token</i> <i>+usermodes</i> <i>virtualhost</i> <i>nickipaddr</i> :<i>realname</i></tt></p>
<p><b>Syntax (NICKv2+NICKIP+CLK):</b> <tt>&amp; <i>nick</i> <i>hopcount</i> <i>timestamp</i> <i>username</i> <i>hostname</i> <i>server</i> <i>service-identifier-token</i> <i>+usermodes</i> <i>virtualhost</i> <i>cloakhost</i> <i>nickipaddr</i> :<i>realname</i></tt>
<p><b>Note:</b> Because each server normally does its own cloak generation, Unreal does not expect to receive NICK messages with the CLK info, so do not send it. It will send this info to a server it has received a PROTOCTL CLK from however.</p>
<p>This format of the NICK message introduces a new user to the network. If PROTOCTL VHP is enabled, the user's cloaked host is put in the virtualhost field, otherwise it'll be * unless the user is +t. With the addition of CLK, VHP is no longer necessary for determining the cloak host.</p>
<h3><a name="S3_1_1"></a>3.1.1 Nick Collisions</h3>
@@ -306,7 +307,7 @@
<p><b>Syntax (SVSMODE):</b> <tt>:<i>source</i> n <i>target</i> +<i>usermodes</i></tt></p>
<p><b>Syntax (SVS2MODE):</b> <tt>:<i>source</i> v <i>target</i> +<i>usermodes</i></tt></p>
<p>Judging by these commands alone, you'd think they are identical. Both commands force a usermode change to occur. This is typically used by services to set +r on a user who has successfully identified. They differ in that SVS2MODE also sends the mode change to the user, while SVSMODE does not (hidden mode change).</p>
<p>SVSMODE and SVS2MODE also give special treatment to usermode +d. Rather than setting the deaf mode like you might expect, SVS(2)MODE +d allows services to change a user's services stamp (which is given in the NICK message). This could allow services to set the service stamp to an easily identifiable value that could then be used to say "hey, this person identified already". The syntax of this is: +d <i>newservicestamp</i> and can be combined with setting other usermodes as well. The deaf mode <b>can</b> be set by using +d without the service stamp parameter; however, in this case you <b>cannot</b> set the service stamp in the same SVS(2)MODE message.</p>
<p>SVSMODE and SVS2MODE also give special treatment to usermode +d. Rather than setting the deaf mode like you might expect, SVS(2)MODE +d allows services to change a user's services stamp (which is given in the NICK message). This could allow services to set the service stamp to an easily identifiable value that could then be used to say "hey, this person identified already". The syntax of this is: +d <i>newservice-identifier-token</i> and can be combined with setting other usermodes as well. The deaf mode <b>can</b> be set by using +d without the service stamp parameter; however, in this case you <b>cannot</b> set the service stamp in the same SVS(2)MODE message.</p>
<p><b>Note:</b> Do <b>NOT</b> use SVSMODE to remove IRCop status from a user. Use the SVSO command for that instead.</p>
<p>Alternatively, target can name a channel. In this case, the mode change parameter can consist of a - character, followed by any or all of: b, e, I, q, a, o, h, or v. These characters cause the corresponding lists to be cleared of all entries. For example: SVSMODE #channel -b removes ALL bans from #channel, and SVSMODE #channel -qaohv turns ALL users on #channel into normal users (removes all owner, admin, op, halfop, and voice status). In this case, the uplink will acknowledge with a MODE listing the bans, etc that were removed.</p>
<p>To completely clear a channel of all modes: MODE #channel -cfijklmnprstzACGMKLNOQRSTVu (plus any added by third-party module) followed by SVSMODE #channel -beIqaohv.</p>
+1 -1
View File
@@ -285,7 +285,7 @@ extern int send_queued(aClient *);
extern void sendto_locfailops(char *pattern, ...) __attribute__((format(printf,1,2)));
extern void sendto_connectnotice(char *nick, anUser *user, aClient *sptr, int disconnect, char *comment);
extern void sendto_serv_butone_nickcmd(aClient *one, aClient *sptr, char *nick, int hopcount,
long lastnick, char *username, char *realhost, char *server, long servicestamp, char *info, char *umodes,
long lastnick, char *username, char *realhost, char *server, char *svid, char *info, char *umodes,
char *virthost);
extern void sendto_message_one(aClient *to, aClient *from, char *sender,
char *cmd, char *nick, char *msg);
+9 -1
View File
@@ -802,7 +802,15 @@ struct User {
Link *silence; /* chain of silence pointer blocks */
Link *dccallow; /* chain of dccallowed entries */
char *away; /* pointer to away message */
u_int32_t servicestamp; /* Services' time stamp variable */
/*
* svid: a value that is assigned by services to this user record.
* in previous versions of Unreal, this was strictly a timestamp value,
* which is less useful in the modern world of IRC where nicks are grouped to
* accounts, so it is now a string.
*/
char svid[NICKLEN + 1];
signed char refcnt; /* Number of times this block is referenced */
unsigned short joined; /* number of channels joined */
char username[USERLEN + 1];
+1 -1
View File
@@ -195,7 +195,7 @@ anUser *make_user(aClient *cptr)
user->invited = NULL;
user->silence = NULL;
user->server = NULL;
user->servicestamp = 0;
strlcpy(user->svid, "*", sizeof(user->svid));
user->lopt = NULL;
user->whowas = NULL;
user->snomask = 0;
+1 -1
View File
@@ -1170,7 +1170,7 @@ int _register_user(aClient *cptr, aClient *sptr, char *nick, char *username, cha
/* NICKv2 Servers ! */
sendto_serv_butone_nickcmd(cptr, sptr, nick,
sptr->hopcount + 1, sptr->lastnick, user->username, user->realhost,
user->server, user->servicestamp, sptr->info,
user->server, user->svid, sptr->info,
(!buf || *buf == '\0' ? "+" : buf),
sptr->umodes & UMODE_SETHOST ? sptr->user->virthost : NULL);
+10 -10
View File
@@ -886,13 +886,13 @@ int m_server_synch(aClient *cptr, long numeric, ConfigItem_link *aconf)
if (!SupportNICKv2(cptr))
{
sendto_one(cptr,
"%s %s %d %ld %s %s %s %lu :%s",
"%s %s %d %ld %s %s %s %s :%s",
(IsToken(cptr) ? TOK_NICK : MSG_NICK),
acptr->name, acptr->hopcount + 1,
acptr->lastnick, acptr->user->username,
acptr->user->realhost,
acptr->user->server,
(unsigned long)acptr->user->servicestamp, acptr->info);
acptr->user->svid, acptr->info);
send_umode(cptr, acptr, 0, SEND_UMODES, buf);
if (IsHidden(acptr) && acptr->user->virthost)
sendto_one(cptr, ":%s %s %s",
@@ -912,9 +912,9 @@ int m_server_synch(aClient *cptr, long numeric, ConfigItem_link *aconf)
{
sendto_one(cptr,
((cptr->proto & PROTO_SJB64) ?
"%s %s %d %B %s %s %b %lu %s %s %s%s%s%s:%s"
"%s %s %d %B %s %s %b %s %s %s %s%s%s%s:%s"
:
"%s %s %d %lu %s %s %b %lu %s %s %s%s%s%s:%s"),
"%s %s %d %lu %s %s %b %s %s %s %s%s%s%s:%s"),
(IsToken(cptr) ? TOK_NICK : MSG_NICK),
acptr->name,
acptr->hopcount + 1,
@@ -922,7 +922,7 @@ int m_server_synch(aClient *cptr, long numeric, ConfigItem_link *aconf)
acptr->user->username,
acptr->user->realhost,
(long)(acptr->srvptr->serv->numeric),
(unsigned long)acptr->user->servicestamp,
acptr->user->svid,
(!buf || *buf == '\0' ? "+" : buf),
((IsHidden(acptr) && (acptr->umodes & UMODE_SETHOST)) ? acptr->user->virthost : "*"),
SupportCLK(cptr) ? getcloak(acptr) : "",
@@ -935,9 +935,9 @@ int m_server_synch(aClient *cptr, long numeric, ConfigItem_link *aconf)
{
sendto_one(cptr,
(cptr->proto & PROTO_SJB64 ?
"%s %s %d %B %s %s %s %lu %s %s %s%s%s%s:%s"
"%s %s %d %B %s %s %s %s %s %s %s%s%s%s:%s"
:
"%s %s %d %lu %s %s %s %lu %s %s %s%s%s%s:%s"),
"%s %s %d %lu %s %s %s %s %s %s %s%s%s%s:%s"),
(IsToken(cptr) ? TOK_NICK : MSG_NICK),
acptr->name,
acptr->hopcount + 1,
@@ -945,7 +945,7 @@ int m_server_synch(aClient *cptr, long numeric, ConfigItem_link *aconf)
acptr->user->username,
acptr->user->realhost,
acptr->user->server,
(unsigned long)acptr->user->servicestamp,
acptr->user->svid,
(!buf || *buf == '\0' ? "+" : buf),
((IsHidden(acptr) && (acptr->umodes & UMODE_SETHOST)) ? acptr->user->virthost : "*"),
SupportCLK(cptr) ? getcloak(acptr) : "",
@@ -957,7 +957,7 @@ int m_server_synch(aClient *cptr, long numeric, ConfigItem_link *aconf)
}
else
sendto_one(cptr,
"%s %s %d %ld %s %s %s %lu %s %s %s%s:%s",
"%s %s %d %ld %s %s %s %s %s %s %s%s:%s",
(IsToken(cptr) ? TOK_NICK :
MSG_NICK), acptr->name,
acptr->hopcount + 1,
@@ -969,7 +969,7 @@ int m_server_synch(aClient *cptr, long numeric, ConfigItem_link *aconf)
base64enc(acptr->srvptr->
serv->numeric) : acptr->
user->server) : acptr->user->
server), (unsigned long)acptr->user->servicestamp,
server), acptr->user->svid,
(!buf
|| *buf == '\0' ? "+" : buf),
GetHost(acptr),
+7 -8
View File
@@ -91,7 +91,7 @@ DLLFUNC CMD_FUNC(m_user)
#define UFLAGS (UMODE_INVISIBLE|UMODE_WALLOP|UMODE_SERVNOTICE)
char *username, *host, *server, *realname, *umodex = NULL, *virthost =
NULL, *ip = NULL;
u_int32_t sstamp = 0;
char *sstamp = NULL;
anUser *user;
aClient *acptr;
@@ -129,23 +129,20 @@ DLLFUNC CMD_FUNC(m_user)
if (parc == 6 && IsServer(cptr))
{
if (isdigit(*parv[4]))
sstamp = strtoul(parv[4], NULL, 10);
sstamp = (BadPtr(parv[4])) ? "*" : parv[4];
realname = (BadPtr(parv[5])) ? "<bad-realname>" : parv[5];
umodex = NULL;
}
else if (parc == 8 && IsServer(cptr))
{
if (isdigit(*parv[4]))
sstamp = strtoul(parv[4], NULL, 10);
sstamp = (BadPtr(parv[4])) ? "*" : parv[4];
realname = (BadPtr(parv[7])) ? "<bad-realname>" : parv[7];
umodex = parv[5];
virthost = parv[6];
}
else if (parc == 9 && IsServer(cptr))
{
if (isdigit(*parv[4]))
sstamp = strtoul(parv[4], NULL, 10);
sstamp = (BadPtr(parv[4])) ? "*" : parv[4];
realname = (BadPtr(parv[8])) ? "<bad-realname>" : parv[8];
umodex = parv[5];
virthost = parv[6];
@@ -202,7 +199,9 @@ DLLFUNC CMD_FUNC(m_user)
user->ip_str = strdup(Inet_ia2p(&sptr->ip));
user->server = me_hash;
user_finish:
user->servicestamp = sstamp;
if (sstamp != NULL)
strlcpy(user->svid, sstamp, sizeof(user->svid));
strlcpy(sptr->info, realname, sizeof(sptr->info));
if (sptr->name[0] && (IsServer(cptr) ? 1 : IsNotSpoof(sptr)))
/* NICK and no-spoof already received, now we have USER... */
+3 -1
View File
@@ -226,12 +226,14 @@ char *num = NULL;
* send_proto:
* sends PROTOCTL message to server, taking care of whether ZIP
* should be enabled or not.
*
* ESVID added to denote support of extended SVID values. --nenolod
*/
void send_proto(aClient *cptr, ConfigItem_link *aconf)
{
char buf[1024];
sprintf(buf, "CHANMODES=%s%s,%s%s,%s%s,%s%s NICKCHARS=%s",
sprintf(buf, "CHANMODES=%s%s,%s%s,%s%s,%s%s NICKCHARS=%s ESVID",
CHPAR1, EXPAR1, CHPAR2, EXPAR2, CHPAR3, EXPAR3, CHPAR4, EXPAR4, langsinuse);
#ifdef ZIP_LINKS
if (aconf->options & CONNECT_ZIP)
+14 -14
View File
@@ -1950,7 +1950,7 @@ void sendto_fconnectnotice(char *nick, anUser *user, aClient *sptr, int disconne
void sendto_serv_butone_nickcmd(aClient *one, aClient *sptr,
char *nick, int hopcount,
long lastnick, char *username, char *realhost, char *server,
long servicestamp, char *info, char *umodes, char *virthost)
char *svid, char *info, char *umodes, char *virthost)
{
int i;
aClient *cptr;
@@ -1992,14 +1992,14 @@ void sendto_serv_butone_nickcmd(aClient *one, aClient *sptr,
sendto_one(cptr,
(cptr->proto & PROTO_SJB64) ?
/* Ugly double %s to prevent excessive spaces */
"%s %s %d %B %s %s %b %lu %s %s %s%s%s%s:%s"
"%s %s %d %B %s %s %b %s %s %s %s%s%s%s:%s"
:
"%s %s %d %lu %s %s %b %lu %s %s %s%s%s%s:%s"
"%s %s %d %lu %s %s %b %s %s %s %s%s%s%s:%s"
,
(IsToken(cptr) ? TOK_NICK : MSG_NICK), nick,
hopcount, (long)lastnick, username, realhost,
(long)(sptr->srvptr->serv->numeric),
servicestamp, umodes, vhost,
svid, umodes, vhost,
SupportCLK(cptr) ? getcloak(sptr) : "",
SupportCLK(cptr) ? " " : "",
SupportNICKIP(cptr) ? encode_ip(sptr->user->ip_str) : "",
@@ -2007,11 +2007,11 @@ void sendto_serv_butone_nickcmd(aClient *one, aClient *sptr,
info);
else
sendto_one(cptr,
"%s %s %d %d %s %s %s %lu %s %s %s%s%s%s:%s",
"%s %s %d %d %s %s %s %s %s %s %s%s%s%s:%s",
(IsToken(cptr) ? TOK_NICK : MSG_NICK), nick,
hopcount, lastnick, username, realhost,
SupportNS(cptr) && sptr->srvptr->serv->numeric ? base64enc(sptr->srvptr->serv->numeric) : server,
servicestamp, umodes, vhost,
svid, umodes, vhost,
SupportCLK(cptr) ? getcloak(sptr) : "",
SupportCLK(cptr) ? " " : "",
SupportNICKIP(cptr) ? encode_ip(sptr->user->ip_str) : "",
@@ -2021,11 +2021,11 @@ void sendto_serv_butone_nickcmd(aClient *one, aClient *sptr,
}
else
{
sendto_one(cptr, "%s %s %d %d %s %s %s %lu :%s",
sendto_one(cptr, "%s %s %d %d %s %s %s %s :%s",
(IsToken(cptr) ? TOK_NICK : MSG_NICK),
nick, hopcount, lastnick, username,
realhost,
server, servicestamp, info);
server, svid, info);
if (strcmp(umodes, "+"))
{
sendto_one(cptr, ":%s %s %s :%s",
@@ -2081,14 +2081,14 @@ void sendto_one_nickcmd(aClient *cptr, aClient *sptr, char *umodes)
sendto_one(cptr,
(cptr->proto & PROTO_SJB64) ?
/* Ugly double %s to prevent excessive spaces */
"%s %s %d %B %s %s %b %lu %s %s %s%s:%s"
"%s %s %d %B %s %s %b %s %s %s %s%s:%s"
:
"%s %s %d %lu %s %s %b %lu %s %s %s%s:%s"
"%s %s %d %lu %s %s %b %s %s %s %s%s:%s"
,
(IsToken(cptr) ? TOK_NICK : MSG_NICK), sptr->name,
sptr->hopcount+1, (long)sptr->lastnick, sptr->user->username,
sptr->user->realhost, (long)(sptr->srvptr->serv->numeric),
sptr->user->servicestamp, umodes, vhost,
sptr->user->svid, umodes, vhost,
SupportNICKIP(cptr) ? encode_ip(sptr->user->ip_str) : "",
SupportNICKIP(cptr) ? " " : "", sptr->info);
else
@@ -2098,16 +2098,16 @@ void sendto_one_nickcmd(aClient *cptr, aClient *sptr, char *umodes)
sptr->hopcount+1, sptr->lastnick, sptr->user->username,
sptr->user->realhost, SupportNS(cptr) &&
sptr->srvptr->serv->numeric ? base64enc(sptr->srvptr->serv->numeric)
: sptr->user->server, sptr->user->servicestamp, umodes, vhost,
: sptr->user->server, sptr->user->svid, umodes, vhost,
SupportNICKIP(cptr) ? encode_ip(sptr->user->ip_str) : "",
SupportNICKIP(cptr) ? " " : "", sptr->info);
}
else
{
sendto_one(cptr, "%s %s %d %d %s %s %s %lu :%s",
sendto_one(cptr, "%s %s %d %d %s %s %s %s :%s",
(IsToken(cptr) ? TOK_NICK : MSG_NICK),
sptr->name, sptr->hopcount+1, sptr->lastnick, sptr->user->username,
sptr->user->realhost, sptr->user->server, sptr->user->servicestamp,
sptr->user->realhost, sptr->user->server, sptr->user->svid,
sptr->info);
if (strcmp(umodes, "+"))
{