X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=src%2Fngircd%2Fnumeric.c;h=8edb76e2169150951fbcdf9cb5611102b346d16f;hb=07cb8ed9ae14307b7b9335faa957baa340632e57;hp=c5bf4bd3c22f5a4a8367b1f9600f803221431642;hpb=43fb18f2f5a506c4d78967e4b6e961b7339c98dc;p=ngircd-alex.git diff --git a/src/ngircd/numeric.c b/src/ngircd/numeric.c index c5bf4bd3..8edb76e2 100644 --- a/src/ngircd/numeric.c +++ b/src/ngircd/numeric.c @@ -1,6 +1,6 @@ /* * ngIRCd -- The Next Generation IRC Daemon - * Copyright (c)2001-2008 Alexander Barton (alex@barton.de) + * Copyright (c)2001-2015 Alexander Barton (alex@barton.de) and Contributors. * * 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 @@ -16,29 +16,23 @@ * Handlers for IRC numerics sent to the server */ -#include "imp.h" #include #include #include #include +#include -#include "defines.h" -#include "conn.h" -#include "conf.h" -#include "conn.h" #include "conn-func.h" +#include "conf.h" #include "channel.h" #include "class.h" #include "irc-write.h" #include "lists.h" #include "log.h" -#include "messages.h" #include "parse.h" -#include "exp.h" #include "numeric.h" - /** * Announce a channel and its users in the network. */ @@ -151,7 +145,27 @@ Announce_Server(CLIENT * Client, CLIENT * Server) #ifdef IRCPLUS /** - * Synchronize invite, ban, G- and K-Line lists between servers. + * Send a specific list to a remote server. + */ +static bool +Send_List(CLIENT *Client, CHANNEL *Chan, struct list_head *Head, char Type) +{ + struct list_elem *elem; + + elem = Lists_GetFirst(Head); + while (elem) { + if (!IRC_WriteStrClient(Client, "MODE %s +%c %s", + Channel_Name(Chan), Type, + Lists_GetMask(elem))) { + return DISCONNECTED; + } + elem = Lists_GetNext(elem); + } + return CONNECTED; +} + +/** + * Synchronize invite, ban, except, and G-Line lists between servers. * * @param Client New server. * @return CONNECTED or DISCONNECTED. @@ -162,6 +176,7 @@ Synchronize_Lists(CLIENT * Client) CHANNEL *c; struct list_head *head; struct list_elem *elem; + time_t t; assert(Client != NULL); @@ -169,9 +184,10 @@ Synchronize_Lists(CLIENT * Client) head = Class_GetList(CLASS_GLINE); elem = Lists_GetFirst(head); while (elem) { + t = Lists_GetValidity(elem) - time(NULL); if (!IRC_WriteStrClient(Client, "GLINE %s %ld :%s", Lists_GetMask(elem), - Lists_GetValidity(elem) - time(NULL), + t > 0 ? (long)t : 0, Lists_GetReason(elem))) return DISCONNECTED; elem = Lists_GetNext(elem); @@ -179,30 +195,12 @@ Synchronize_Lists(CLIENT * Client) c = Channel_First(); while (c) { - /* ban list */ - head = Channel_GetListBans(c); - elem = Lists_GetFirst(head); - while (elem) { - if (!IRC_WriteStrClient(Client, "MODE %s +b %s", - Channel_Name(c), - Lists_GetMask(elem))) { - return DISCONNECTED; - } - elem = Lists_GetNext(elem); - } - - /* invite list */ - head = Channel_GetListInvites(c); - elem = Lists_GetFirst(head); - while (elem) { - if (!IRC_WriteStrClient(Client, "MODE %s +I %s", - Channel_Name(c), - Lists_GetMask(elem))) { - return DISCONNECTED; - } - elem = Lists_GetNext(elem); - } - + if (!Send_List(Client, c, Channel_GetListExcepts(c), 'e')) + return DISCONNECTED; + if (!Send_List(Client, c, Channel_GetListBans(c), 'b')) + return DISCONNECTED; + if (!Send_List(Client, c, Channel_GetListInvites(c), 'I')) + return DISCONNECTED; c = Channel_Next(c); } return CONNECTED; @@ -216,11 +214,12 @@ Synchronize_Lists(CLIENT * Client) static bool Send_CHANINFO(CLIENT * Client, CHANNEL * Chan) { - char *modes, *topic; + char *modes, *topic, *key; bool has_k, has_l; #ifdef DEBUG - Log(LOG_DEBUG, "Sending CHANINFO commands ..."); + Log(LOG_DEBUG, "Sending CHANINFO commands for \"%s\" ...", + Channel_Name(Chan)); #endif modes = Channel_Modes(Chan); @@ -244,9 +243,10 @@ Send_CHANINFO(CLIENT * Client, CHANNEL * Chan) Channel_Name(Chan), modes, topic); } /* "CHANINFO + :" */ + key = Channel_Key(Chan); return IRC_WriteStrClient(Client, "CHANINFO %s +%s %s %lu :%s", Channel_Name(Chan), modes, - has_k ? Channel_Key(Chan) : "*", + has_k ? (key && *key ? key : "*") : "*", has_l ? Channel_MaxUsers(Chan) : 0, topic); } /* Send_CHANINFO */