Implement local channels (prefix "&")
This patch implements server-local channels, prefix "&", that are only visible to users of the same local server and not in the network. Patch written by Scott Perry (2008-06-04), see: - http://arthur.barton.de/cgi-bin/bugzilla/show_bug.cgi?id=87 - http://arthur.barton.de/cgi-bin/bugzilla/attachment.cgi?id=24&action=view
This commit is contained in:
parent
7b69bc2ae8
commit
2cc21caf32
|
@ -509,7 +509,7 @@ Channel_IsValidName( const char *Name )
|
||||||
if (strlen(Name) <= 1)
|
if (strlen(Name) <= 1)
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
if (strchr("+#", Name[0]) == NULL)
|
if (strchr("#&+", Name[0]) == NULL)
|
||||||
return false;
|
return false;
|
||||||
if (strlen(Name) >= CHANNEL_NAME_LEN)
|
if (strlen(Name) >= CHANNEL_NAME_LEN)
|
||||||
return false;
|
return false;
|
||||||
|
@ -875,6 +875,11 @@ Remove_Client( int Type, CHANNEL *Chan, CLIENT *Client, CLIENT *Origin, const ch
|
||||||
assert( Origin != NULL );
|
assert( Origin != NULL );
|
||||||
assert( Reason != NULL );
|
assert( Reason != NULL );
|
||||||
|
|
||||||
|
/* Do not inform other servers if the channel is local to this server,
|
||||||
|
* regardless of what the caller requested! */
|
||||||
|
if(InformServer)
|
||||||
|
InformServer = !Channel_IsLocal(Chan);
|
||||||
|
|
||||||
last_cl2chan = NULL;
|
last_cl2chan = NULL;
|
||||||
cl2chan = My_Cl2Chan;
|
cl2chan = My_Cl2Chan;
|
||||||
while( cl2chan )
|
while( cl2chan )
|
||||||
|
@ -896,14 +901,16 @@ Remove_Client( int Type, CHANNEL *Chan, CLIENT *Client, CLIENT *Origin, const ch
|
||||||
switch( Type )
|
switch( Type )
|
||||||
{
|
{
|
||||||
case REMOVE_QUIT:
|
case REMOVE_QUIT:
|
||||||
/* QUIT: other servers have already been notified, see Client_Destroy();
|
/* QUIT: other servers have already been notified,
|
||||||
* so only inform other clients in same channel. */
|
* see Client_Destroy(); so only inform other clients
|
||||||
|
* in same channel. */
|
||||||
assert( InformServer == false );
|
assert( InformServer == false );
|
||||||
LogDebug("User \"%s\" left channel \"%s\" (%s).",
|
LogDebug("User \"%s\" left channel \"%s\" (%s).",
|
||||||
Client_Mask( Client ), c->name, Reason );
|
Client_Mask( Client ), c->name, Reason );
|
||||||
break;
|
break;
|
||||||
case REMOVE_KICK:
|
case REMOVE_KICK:
|
||||||
/* User was KICKed: inform other servers and all users in channel */
|
/* User was KICKed: inform other servers (public
|
||||||
|
* channels) and all users in the channel */
|
||||||
if( InformServer )
|
if( InformServer )
|
||||||
IRC_WriteStrServersPrefix( Client_NextHop( Origin ),
|
IRC_WriteStrServersPrefix( Client_NextHop( Origin ),
|
||||||
Origin, "KICK %s %s :%s", c->name, Client_ID( Client ), Reason);
|
Origin, "KICK %s %s :%s", c->name, Client_ID( Client ), Reason);
|
||||||
|
@ -1062,5 +1069,4 @@ Delete_Channel( CHANNEL *Chan )
|
||||||
return true;
|
return true;
|
||||||
} /* Delete_Channel */
|
} /* Delete_Channel */
|
||||||
|
|
||||||
|
|
||||||
/* -eof- */
|
/* -eof- */
|
||||||
|
|
|
@ -124,5 +124,10 @@ GLOBAL bool Channel_AddBan PARAMS((CHANNEL *c, const char *Mask ));
|
||||||
|
|
||||||
GLOBAL bool Channel_ShowBans PARAMS((CLIENT *client, CHANNEL *c));
|
GLOBAL bool Channel_ShowBans PARAMS((CLIENT *client, CHANNEL *c));
|
||||||
GLOBAL bool Channel_ShowInvites PARAMS((CLIENT *client, CHANNEL *c));
|
GLOBAL bool Channel_ShowInvites PARAMS((CLIENT *client, CHANNEL *c));
|
||||||
|
|
||||||
|
#define Channel_IsLocal(c) (Channel_Name(c)[0] == '&')
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* -eof- */
|
/* -eof- */
|
||||||
|
|
|
@ -156,16 +156,24 @@ join_forward(CLIENT *Client, CLIENT *target, CHANNEL *chan,
|
||||||
else
|
else
|
||||||
modes[0] = '\0';
|
modes[0] = '\0';
|
||||||
|
|
||||||
/* forward to other servers */
|
/* forward to other servers (if it is not a local channel) */
|
||||||
snprintf(str, sizeof(str), "%s%s", channame, modes);
|
if (!Channel_IsLocal(chan)) {
|
||||||
IRC_WriteStrServersPrefixFlag_CB(Client, target, '\0', cb_join_forward, str);
|
snprintf(str, sizeof(str), "%s%s", channame, modes);
|
||||||
|
IRC_WriteStrServersPrefixFlag_CB(Client, target, '\0',
|
||||||
|
cb_join_forward, str);
|
||||||
|
}
|
||||||
|
|
||||||
/* tell users in this channel about the new client */
|
/* tell users in this channel about the new client */
|
||||||
IRC_WriteStrChannelPrefix(Client, chan, target, false, "JOIN :%s", channame);
|
IRC_WriteStrChannelPrefix(Client, chan, target, false,
|
||||||
if (modes[1])
|
"JOIN :%s", channame);
|
||||||
IRC_WriteStrChannelPrefix(Client, chan, target, false, "MODE %s +%s %s",
|
|
||||||
channame, &modes[1], Client_ID(target));
|
/* syncronize channel modes */
|
||||||
}
|
if (modes[1]) {
|
||||||
|
IRC_WriteStrChannelPrefix(Client, chan, target, false,
|
||||||
|
"MODE %s +%s %s", channame,
|
||||||
|
&modes[1], Client_ID(target));
|
||||||
|
}
|
||||||
|
} /* join_forward */
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -423,12 +431,18 @@ IRC_TOPIC( CLIENT *Client, REQUEST *Req )
|
||||||
Client_TypeText(from), Client_Mask(from), Channel_Name(chan),
|
Client_TypeText(from), Client_Mask(from), Channel_Name(chan),
|
||||||
Req->argv[1][0] ? Req->argv[1] : "<none>");
|
Req->argv[1][0] ? Req->argv[1] : "<none>");
|
||||||
|
|
||||||
/* im Channel bekannt machen und an Server weiterleiten */
|
/* Update channel and forward new topic to other servers */
|
||||||
IRC_WriteStrServersPrefix( Client, from, "TOPIC %s :%s", Req->argv[0], Req->argv[1] );
|
if (!Channel_IsLocal(chan))
|
||||||
IRC_WriteStrChannelPrefix( Client, chan, from, false, "TOPIC %s :%s", Req->argv[0], Req->argv[1] );
|
IRC_WriteStrServersPrefix(Client, from, "TOPIC %s :%s",
|
||||||
|
Req->argv[0], Req->argv[1]);
|
||||||
|
IRC_WriteStrChannelPrefix(Client, chan, from, false, "TOPIC %s :%s",
|
||||||
|
Req->argv[0], Req->argv[1]);
|
||||||
|
|
||||||
if( Client_Type( Client ) == CLIENT_USER ) return IRC_WriteStrClientPrefix( Client, Client, "TOPIC %s :%s", Req->argv[0], Req->argv[1] );
|
if (Client_Type(Client) == CLIENT_USER)
|
||||||
else return CONNECTED;
|
return IRC_WriteStrClientPrefix(Client, Client, "TOPIC %s :%s",
|
||||||
|
Req->argv[0], Req->argv[1]);
|
||||||
|
else
|
||||||
|
return CONNECTED;
|
||||||
} /* IRC_TOPIC */
|
} /* IRC_TOPIC */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -932,7 +932,14 @@ IRC_WHOIS( CLIENT *Client, REQUEST *Req )
|
||||||
cl2chan = Channel_NextChannelOf( c, cl2chan );
|
cl2chan = Channel_NextChannelOf( c, cl2chan );
|
||||||
|
|
||||||
/* Secret channel? */
|
/* Secret channel? */
|
||||||
if( strchr( Channel_Modes( chan ), 's' ) && ! Channel_IsMemberOf( chan, Client )) continue;
|
if (strchr(Channel_Modes(chan), 's')
|
||||||
|
&& !Channel_IsMemberOf(chan, Client))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Local channel and request is not from a user? */
|
||||||
|
if (Client_Type(Client) == CLIENT_SERVER
|
||||||
|
&& Channel_IsLocal(chan))
|
||||||
|
continue;
|
||||||
|
|
||||||
/* Concatenate channel names */
|
/* Concatenate channel names */
|
||||||
if( str[strlen( str ) - 1] != ':' ) strlcat( str, " ", sizeof( str ));
|
if( str[strlen( str ) - 1] != ':' ) strlcat( str, " ", sizeof( str ));
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* ngIRCd -- The Next Generation IRC Daemon
|
* ngIRCd -- The Next Generation IRC Daemon
|
||||||
* Copyright (c)2001-2005 Alexander Barton (alex@barton.de)
|
* Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -558,7 +558,15 @@ chan_exit:
|
||||||
the_modes[len] = '\0';
|
the_modes[len] = '\0';
|
||||||
|
|
||||||
if (Client_Type(Client) == CLIENT_SERVER) {
|
if (Client_Type(Client) == CLIENT_SERVER) {
|
||||||
/* Forward mode changes to channel users and other servers */
|
/* MODE requests for local channels from other servers
|
||||||
|
* are definitely invalid! */
|
||||||
|
if (Channel_IsLocal(Channel)) {
|
||||||
|
Log(LOG_ALERT, "Got remote MODE command for local channel!? Ignored.");
|
||||||
|
return CONNECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Forward mode changes to channel users and all the
|
||||||
|
* other remote servers: */
|
||||||
IRC_WriteStrServersPrefix(Client, Origin, "MODE %s %s%s", Channel_Name( Channel ), the_modes, the_args);
|
IRC_WriteStrServersPrefix(Client, Origin, "MODE %s %s%s", Channel_Name( Channel ), the_modes, the_args);
|
||||||
IRC_WriteStrChannelPrefix(Client, Channel, Origin, false, "MODE %s %s%s", Channel_Name(Channel), the_modes, the_args);
|
IRC_WriteStrChannelPrefix(Client, Channel, Origin, false, "MODE %s %s%s", Channel_Name(Channel), the_modes, the_args);
|
||||||
} else {
|
} else {
|
||||||
|
@ -567,10 +575,14 @@ chan_exit:
|
||||||
/* Send reply to client and inform other servers and channel users */
|
/* Send reply to client and inform other servers and channel users */
|
||||||
ok = IRC_WriteStrClientPrefix(Client, Origin, "MODE %s %s%s",
|
ok = IRC_WriteStrClientPrefix(Client, Origin, "MODE %s %s%s",
|
||||||
Channel_Name(Channel), the_modes, the_args);
|
Channel_Name(Channel), the_modes, the_args);
|
||||||
IRC_WriteStrServersPrefix(Client, Origin, "MODE %s %s%s",
|
/* Only forward requests for non-local channels */
|
||||||
Channel_Name(Channel), the_modes, the_args);
|
if (!Channel_IsLocal(Channel))
|
||||||
IRC_WriteStrChannelPrefix(Client, Channel, Origin, false, "MODE %s %s%s",
|
IRC_WriteStrServersPrefix(Client, Origin,
|
||||||
Channel_Name(Channel), the_modes, the_args);
|
"MODE %s %s%s", Channel_Name(Channel),
|
||||||
|
the_modes, the_args);
|
||||||
|
IRC_WriteStrChannelPrefix(Client, Channel, Origin,
|
||||||
|
false, "MODE %s %s%s", Channel_Name(Channel),
|
||||||
|
the_modes, the_args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* ngIRCd -- The Next Generation IRC Daemon
|
* ngIRCd -- The Next Generation IRC Daemon
|
||||||
* Copyright (c)2001-2004 Alexander Barton <alex@barton.de>
|
* Copyright (c)2001-2008 Alexander Barton <alex@barton.de>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -8,8 +8,6 @@
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
* Please read the file COPYING, README and AUTHORS for more information.
|
* Please read the file COPYING, README and AUTHORS for more information.
|
||||||
*
|
*
|
||||||
* $Id: messages.h,v 1.75 2008/02/17 13:26:42 alex Exp $
|
|
||||||
*
|
|
||||||
* IRC numerics (Header)
|
* IRC numerics (Header)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -22,7 +20,7 @@
|
||||||
#define RPL_YOURHOST_MSG "002 %s :Your host is %s, running version ngircd-%s (%s/%s/%s)"
|
#define RPL_YOURHOST_MSG "002 %s :Your host is %s, running version ngircd-%s (%s/%s/%s)"
|
||||||
#define RPL_CREATED_MSG "003 %s :This server has been started %s"
|
#define RPL_CREATED_MSG "003 %s :This server has been started %s"
|
||||||
#define RPL_MYINFO_MSG "004 %s %s ngircd-%s %s %s"
|
#define RPL_MYINFO_MSG "004 %s %s ngircd-%s %s %s"
|
||||||
#define RPL_ISUPPORT1_MSG "005 %s RFC2812 CASEMAPPING=ascii PREFIX=(ov)@+ CHANTYPES=# CHANMODES=bI,k,l,imnPst CHANLIMIT=#:%d :are supported on this server"
|
#define RPL_ISUPPORT1_MSG "005 %s RFC2812 CASEMAPPING=ascii PREFIX=(ov)@+ CHANTYPES=#&+ CHANMODES=bI,k,l,imnPst CHANLIMIT=#&+:%d :are supported on this server"
|
||||||
#define RPL_ISUPPORT2_MSG "005 %s CHANNELLEN=%d NICKLEN=%d TOPICLEN=%d AWAYLEN=%d KICKLEN=%d PENALTY :are supported on this server"
|
#define RPL_ISUPPORT2_MSG "005 %s CHANNELLEN=%d NICKLEN=%d TOPICLEN=%d AWAYLEN=%d KICKLEN=%d PENALTY :are supported on this server"
|
||||||
|
|
||||||
#define RPL_TRACELINK_MSG "200 %s Link %s-%s %s %s V%s %ld %d %d"
|
#define RPL_TRACELINK_MSG "200 %s Link %s-%s %s %s V%s %ld %d %d"
|
||||||
|
|
|
@ -341,6 +341,10 @@ IRC_Num_ENDOFMOTD(CLIENT * Client, UNUSED REQUEST * Req)
|
||||||
/* Announce all channels to the new server */
|
/* Announce all channels to the new server */
|
||||||
chan = Channel_First();
|
chan = Channel_First();
|
||||||
while (chan) {
|
while (chan) {
|
||||||
|
if (Channel_IsLocal(chan)) {
|
||||||
|
chan = Channel_Next(chan);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
#ifdef IRCPLUS
|
#ifdef IRCPLUS
|
||||||
/* Send CHANINFO if the peer supports it */
|
/* Send CHANINFO if the peer supports it */
|
||||||
if (strchr(Client_Flags(Client), 'C')) {
|
if (strchr(Client_Flags(Client), 'C')) {
|
||||||
|
|
Loading…
Reference in New Issue